Files
kandev/apps/web/e2e/tests/search/shared.ts
T
2026-08-04 22:15:32 +01:00

43 lines
1.5 KiB
TypeScript

import { type Page } from "@playwright/test";
import type { SeedData } from "../../fixtures/test-base";
import type { ApiClient } from "../../helpers/api-client";
import { SessionPage } from "../../pages/session-page";
import { multiMessageScript, planScript } from "../../helpers/seed-session-messages";
const MODIFIER = process.platform === "darwin" ? "Meta" : "Control";
export { MODIFIER };
/** Create a task+session seeded with a mock-agent script, navigate to it, wait for idle. */
export async function seedTask(
page: Page,
apiClient: ApiClient,
seedData: SeedData,
title: string,
opts: { description: string },
): Promise<{ session: SessionPage; taskId: string; sessionId: string }> {
const task = await apiClient.createTaskWithAgent(
seedData.workspaceId,
title,
seedData.agentProfileId,
{
description: opts.description,
workflow_id: seedData.workflowId,
workflow_step_id: seedData.startStepId,
repository_ids: [seedData.repositoryId],
},
);
await page.goto(`/t/${task.id}`);
const session = new SessionPage(page);
await session.waitForLoad();
await session.waitForChatIdle({ timeout: 30_000 });
return { session, taskId: task.id, sessionId: task.session_id! };
}
/** Seed N agent messages with distinct content in a single turn. */
export function seedMessagesDescription(lines: string[]): string {
return multiMessageScript(lines, 5);
}
/** Build a plan-seeding description. */
export { planScript };