2026-05-06 21:36:33 +05:30
|
|
|
import type { APIRequestContext } from "@playwright/test";
|
|
|
|
|
import { authHeaders, BACKEND_URL } from "../helpers/api/auth";
|
2026-07-06 15:12:40 +05:30
|
|
|
import type { WorkspaceFixtures } from "./workspace.fixture";
|
2026-05-06 21:36:33 +05:30
|
|
|
|
|
|
|
|
export type ChatThreadRow = {
|
|
|
|
|
id: number;
|
|
|
|
|
title: string;
|
2026-07-05 23:17:13 -07:00
|
|
|
workspace_id: number;
|
2026-05-06 21:36:33 +05:30
|
|
|
visibility: string;
|
|
|
|
|
created_by_id: string | null;
|
|
|
|
|
created_at: string;
|
|
|
|
|
updated_at: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type ChatThreadFixtures = {
|
|
|
|
|
chatThread: ChatThreadRow;
|
|
|
|
|
};
|
|
|
|
|
|
2026-07-06 15:12:40 +05:30
|
|
|
type ChatThreadFixtureArgs = WorkspaceFixtures & {
|
2026-05-06 21:36:33 +05:30
|
|
|
request: APIRequestContext;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const chatThreadFixtures = {
|
|
|
|
|
chatThread: async (
|
2026-07-06 15:12:40 +05:30
|
|
|
{ request, apiToken, workspace }: ChatThreadFixtureArgs,
|
2026-05-06 21:36:33 +05:30
|
|
|
use: (thread: ChatThreadRow) => Promise<void>
|
|
|
|
|
) => {
|
|
|
|
|
const response = await request.post(`${BACKEND_URL}/api/v1/threads`, {
|
|
|
|
|
headers: authHeaders(apiToken),
|
|
|
|
|
data: {
|
|
|
|
|
title: "e2e-drive-journey",
|
2026-07-06 15:12:40 +05:30
|
|
|
workspace_id: workspace.id,
|
2026-05-06 21:36:33 +05:30
|
|
|
visibility: "PRIVATE",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
if (!response.ok()) {
|
|
|
|
|
throw new Error(`create chat thread failed (${response.status()}): ${await response.text()}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await use((await response.json()) as ChatThreadRow);
|
|
|
|
|
},
|
|
|
|
|
};
|