chatbot-template/tests/fixtures.ts

25 lines
688 B
TypeScript
Raw Normal View History

import { expect as baseExpect, test as baseTest } from "@playwright/test";
import { getUnixTime } from "date-fns";
import { createAuthenticatedContext, type UserContext } from "./helpers";
2025-04-22 18:55:17 -07:00
type Fixtures = {
authenticatedContext: UserContext;
};
2025-04-22 18:55:17 -07:00
export const test = baseTest.extend<object, Fixtures>({
authenticatedContext: [
2025-04-25 23:40:15 -07:00
async ({ browser }, use, workerInfo) => {
const userContext = await createAuthenticatedContext({
2025-04-22 18:55:17 -07:00
browser,
name: `user-${workerInfo.workerIndex}-${getUnixTime(new Date())}`,
2025-04-22 18:55:17 -07:00
});
2025-04-25 23:40:15 -07:00
await use(userContext);
await userContext.context.close();
2025-04-25 23:40:15 -07:00
},
{ scope: "worker" },
2025-04-25 23:40:15 -07:00
],
2025-04-22 18:55:17 -07:00
});
export const expect = baseExpect;