mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-21 15:33:30 +10:00
Add Playwright E2E test setup (#3169)
* docs: design e2e test setup Co-authored-by: Amruth Pillai <im.amruth@gmail.com> * docs: plan e2e test implementation Co-authored-by: Amruth Pillai <im.amruth@gmail.com> * test: add playwright e2e scripts Co-authored-by: Amruth Pillai <im.amruth@gmail.com> * test: configure playwright Co-authored-by: Amruth Pillai <im.amruth@gmail.com> * test: add core e2e fixtures and specs Co-authored-by: Amruth Pillai <im.amruth@gmail.com> * ci: run e2e tests on pull requests Co-authored-by: Amruth Pillai <im.amruth@gmail.com> * [autofix.ci] apply automated fixes * test: stabilize e2e suite Co-authored-by: Amruth Pillai <im.amruth@gmail.com> * test: ignore playwright artifacts Co-authored-by: Amruth Pillai <im.amruth@gmail.com> * Update .github/workflows/e2e.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * test: address e2e review feedback Co-authored-by: Amruth Pillai <im.amruth@gmail.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import type { BrowserContext, Page } from "@playwright/test";
|
||||
import type { E2EAccount } from "./data";
|
||||
import { test as base, expect } from "@playwright/test";
|
||||
import { createAuthenticatedContext } from "./auth";
|
||||
import { createAccount } from "./data";
|
||||
import { deleteE2EUser } from "./db";
|
||||
|
||||
type Fixtures = {
|
||||
account: E2EAccount;
|
||||
authContext: BrowserContext;
|
||||
authPage: Page;
|
||||
};
|
||||
|
||||
export const test = base.extend<Fixtures>({
|
||||
account: async ({ baseURL }, use, testInfo) => {
|
||||
void baseURL;
|
||||
const account = createAccount(testInfo);
|
||||
|
||||
try {
|
||||
await use(account);
|
||||
} finally {
|
||||
await deleteE2EUser(account);
|
||||
}
|
||||
},
|
||||
authContext: async ({ browser, request, account }, use, testInfo) => {
|
||||
const baseURL = String(testInfo.project.use.baseURL ?? "http://localhost:3000");
|
||||
const context = await createAuthenticatedContext(browser, request, account, baseURL);
|
||||
|
||||
try {
|
||||
await use(context);
|
||||
} finally {
|
||||
await context.close();
|
||||
}
|
||||
},
|
||||
authPage: async ({ authContext }, use) => {
|
||||
const page = await authContext.newPage();
|
||||
|
||||
try {
|
||||
await use(page);
|
||||
} finally {
|
||||
await page.close();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export { expect };
|
||||
Reference in New Issue
Block a user