chatbot-template/tests/fixtures.ts

52 lines
1.4 KiB
TypeScript
Raw Normal View History

2025-04-22 18:55:17 -07:00
import { expect as baseExpect, test as baseTest } from '@playwright/test';
2025-04-25 23:40:15 -07:00
import { createAuthenticatedContext, type UserContext } from './helpers';
import { getUnixTime } from 'date-fns';
2025-04-22 18:55:17 -07:00
interface Fixtures {
adaContext: UserContext;
babbageContext: UserContext;
2025-04-25 23:40:15 -07:00
curieContext: UserContext;
2025-04-22 18:55:17 -07:00
}
export const test = baseTest.extend<{}, Fixtures>({
2025-04-22 18:55:17 -07:00
adaContext: [
2025-04-25 23:40:15 -07:00
async ({ browser }, use, workerInfo) => {
2025-04-22 18:55:17 -07:00
const ada = await createAuthenticatedContext({
browser,
2025-04-25 23:40:15 -07:00
name: `ada-${workerInfo.workerIndex}-${getUnixTime(new Date())}`,
2025-04-22 18:55:17 -07:00
});
2025-04-25 23:40:15 -07:00
2025-04-22 18:55:17 -07:00
await use(ada);
await ada.context.close();
},
{ scope: 'worker' },
],
babbageContext: [
2025-04-25 23:40:15 -07:00
async ({ browser }, use, workerInfo) => {
2025-04-22 18:55:17 -07:00
const babbage = await createAuthenticatedContext({
browser,
2025-04-25 23:40:15 -07:00
name: `babbage-${workerInfo.workerIndex}-${getUnixTime(new Date())}`,
2025-04-22 18:55:17 -07:00
});
2025-04-25 23:40:15 -07:00
2025-04-22 18:55:17 -07:00
await use(babbage);
await babbage.context.close();
},
{ scope: 'worker' },
],
2025-04-25 23:40:15 -07:00
curieContext: [
async ({ browser }, use, workerInfo) => {
const curie = await createAuthenticatedContext({
browser,
name: `curie-${workerInfo.workerIndex}-${getUnixTime(new Date())}`,
chatModel: 'chat-model-reasoning',
});
await use(curie);
await curie.context.close();
},
{ scope: 'worker' },
],
2025-04-22 18:55:17 -07:00
});
export const expect = baseExpect;