2025-09-21 11:02:31 -07:00
|
|
|
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
|
|
|
|
2025-09-21 11:02:31 -07:00
|
|
|
type Fixtures = {
|
2025-12-14 21:26:49 +00:00
|
|
|
authenticatedContext: UserContext;
|
2025-09-21 11:02:31 -07:00
|
|
|
};
|
2025-04-22 18:55:17 -07:00
|
|
|
|
2025-09-21 11:02:31 -07:00
|
|
|
export const test = baseTest.extend<object, Fixtures>({
|
2025-12-14 21:26:49 +00:00
|
|
|
authenticatedContext: [
|
2025-04-25 23:40:15 -07:00
|
|
|
async ({ browser }, use, workerInfo) => {
|
2025-12-14 21:26:49 +00:00
|
|
|
const userContext = await createAuthenticatedContext({
|
2025-04-22 18:55:17 -07:00
|
|
|
browser,
|
2025-12-14 21:26:49 +00:00
|
|
|
name: `user-${workerInfo.workerIndex}-${getUnixTime(new Date())}`,
|
2025-04-22 18:55:17 -07:00
|
|
|
});
|
2025-04-25 23:40:15 -07:00
|
|
|
|
2025-12-14 21:26:49 +00:00
|
|
|
await use(userContext);
|
|
|
|
|
await userContext.context.close();
|
2025-04-25 23:40:15 -07:00
|
|
|
},
|
2025-09-21 11:02:31 -07:00
|
|
|
{ scope: "worker" },
|
2025-04-25 23:40:15 -07:00
|
|
|
],
|
2025-04-22 18:55:17 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const expect = baseExpect;
|