From 18b3ba1cfb64bf3667c03e28cab3c1c7c3843de8 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 20 Jun 2026 04:24:31 +0000 Subject: [PATCH] test: stabilize e2e suite Co-authored-by: Amruth Pillai --- .github/workflows/e2e.yml | 6 +++++- tests/e2e/README.md | 6 ++++-- tests/e2e/fixtures/auth.ts | 12 ++++++------ tests/e2e/fixtures/resume.ts | 4 ++-- tests/e2e/specs/json-export-import.spec.ts | 20 +++++++++++--------- tests/e2e/specs/public-sharing.spec.ts | 6 +++--- tests/e2e/specs/resume-lifecycle.spec.ts | 4 ++++ 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b8979f44f..fb1094d3d 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -13,7 +13,8 @@ env: APP_URL: http://localhost:3000 PORT: "3000" DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres - AUTH_SECRET: e2e-test-secret + AUTH_SECRET: 3f95d9f2687e4d1f9571a7adf0b2e89a7cc98f5b1fb72ad8c9d4b67a42fdf613 + ENCRYPTION_SECRET: 2f724ef46009b17ea8c5f88e9ea28fd93d12529e7ff71731a8d2875566551d91 FLAG_DISABLE_SIGNUPS: "false" FLAG_DISABLE_EMAIL_AUTH: "false" FLAG_DISABLE_API_RATE_LIMIT: "true" @@ -61,6 +62,9 @@ jobs: - name: Prepare Storage run: mkdir -p "$LOCAL_STORAGE_PATH" + - name: Run Database Migrations + run: pnpm db:migrate + - name: Build run: pnpm build diff --git a/tests/e2e/README.md b/tests/e2e/README.md index 30f0ff8f5..5828d05b3 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -10,11 +10,13 @@ Start PostgreSQL: Build the production app: -`APP_URL=http://localhost:3000 PORT=3000 DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres AUTH_SECRET=e2e-test-secret FLAG_DISABLE_SIGNUPS=false FLAG_DISABLE_EMAIL_AUTH=false FLAG_DISABLE_API_RATE_LIMIT=true LOCAL_STORAGE_PATH=/workspace/data/e2e pnpm build` +`APP_URL=http://localhost:3000 PORT=3000 DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres AUTH_SECRET=3f95d9f2687e4d1f9571a7adf0b2e89a7cc98f5b1fb72ad8c9d4b67a42fdf613 ENCRYPTION_SECRET=2f724ef46009b17ea8c5f88e9ea28fd93d12529e7ff71731a8d2875566551d91 FLAG_DISABLE_SIGNUPS=false FLAG_DISABLE_EMAIL_AUTH=false FLAG_DISABLE_API_RATE_LIMIT=true LOCAL_STORAGE_PATH=/workspace/data/e2e pnpm db:migrate` + +`APP_URL=http://localhost:3000 PORT=3000 DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres AUTH_SECRET=3f95d9f2687e4d1f9571a7adf0b2e89a7cc98f5b1fb72ad8c9d4b67a42fdf613 ENCRYPTION_SECRET=2f724ef46009b17ea8c5f88e9ea28fd93d12529e7ff71731a8d2875566551d91 FLAG_DISABLE_SIGNUPS=false FLAG_DISABLE_EMAIL_AUTH=false FLAG_DISABLE_API_RATE_LIMIT=true LOCAL_STORAGE_PATH=/workspace/data/e2e pnpm build` Run tests: -`APP_URL=http://localhost:3000 PORT=3000 DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres AUTH_SECRET=e2e-test-secret FLAG_DISABLE_SIGNUPS=false FLAG_DISABLE_EMAIL_AUTH=false FLAG_DISABLE_API_RATE_LIMIT=true LOCAL_STORAGE_PATH=/workspace/data/e2e pnpm test:e2e` +`APP_URL=http://localhost:3000 PORT=3000 DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres AUTH_SECRET=3f95d9f2687e4d1f9571a7adf0b2e89a7cc98f5b1fb72ad8c9d4b67a42fdf613 ENCRYPTION_SECRET=2f724ef46009b17ea8c5f88e9ea28fd93d12529e7ff71731a8d2875566551d91 FLAG_DISABLE_SIGNUPS=false FLAG_DISABLE_EMAIL_AUTH=false FLAG_DISABLE_API_RATE_LIMIT=true LOCAL_STORAGE_PATH=/workspace/data/e2e pnpm test:e2e` ## Coverage diff --git a/tests/e2e/fixtures/auth.ts b/tests/e2e/fixtures/auth.ts index b4123ca53..5221cbed3 100644 --- a/tests/e2e/fixtures/auth.ts +++ b/tests/e2e/fixtures/auth.ts @@ -9,19 +9,19 @@ async function assertAuthResponse(response: Awaited { - const resumeName = await createSampleResumeFromDashboard(page, testInfo); + await createSampleResumeFromDashboard(page, testInfo); - await openSidebarSection(page, "Export"); + await openSidebarSection(page, "Export", "right"); const downloadPromise = page.waitForEvent("download"); await page.getByRole("button", { name: /^JSON/ }).click(); const download = await downloadPromise; expect(download.suggestedFilename()).toMatch(/\.json$/); - const downloadPath = await download.path(); - if (!downloadPath) throw new Error("Expected Playwright to provide a downloaded JSON path."); + const downloadPath = testInfo.outputPath(download.suggestedFilename()); + await download.saveAs(downloadPath); + const exportedData = JSON.parse(await readFile(downloadPath, "utf-8")) as { basics: { name: string } }; await page.goto("/dashboard/resumes"); await page.getByText("Import an existing resume").click(); - await page.getByRole("combobox").click(); + const dialog = page.getByRole("dialog", { name: "Import an existing resume" }); + await dialog.getByRole("combobox").click(); await page.getByRole("option", { name: "Reactive Resume (JSON)" }).click(); - await page.locator('input[type="file"]').setInputFiles(downloadPath); - await page.getByRole("button", { name: "Import" }).click(); + await dialog.locator('input[type="file"]').setInputFiles(downloadPath); + await dialog.getByRole("button", { name: "Import", exact: true }).click(); await page.waitForURL(/\/builder\/.+/); await openSidebarSection(page, "Basics"); - await expect(page.getByLabel("Name")).toHaveValue(/.+/); - await expect(page.getByText(resumeName)).toBeVisible(); + await expect(page.getByLabel("Name")).toHaveValue(exportedData.basics.name); }); diff --git a/tests/e2e/specs/public-sharing.spec.ts b/tests/e2e/specs/public-sharing.spec.ts index 34849e7c5..b3bf0b738 100644 --- a/tests/e2e/specs/public-sharing.spec.ts +++ b/tests/e2e/specs/public-sharing.spec.ts @@ -3,10 +3,10 @@ import { expect, test } from "../fixtures/test"; test("publishes a resume and renders it for an anonymous visitor", async ({ browser, authPage: page }, testInfo) => { await createSampleResumeFromDashboard(page, testInfo); - await openSidebarSection(page, "Sharing"); + await openSidebarSection(page, "Sharing", "right"); - await page.getByLabel("Allow Public Access").click(); - const publicUrl = await page.getByLabel("URL").inputValue(); + await page.getByRole("switch", { name: /Allow Public Access/ }).click(); + const publicUrl = await page.locator("#sharing-url").inputValue(); expect(publicUrl).toMatch(/\/e2e_/); const anonymous = await browser.newPage(); diff --git a/tests/e2e/specs/resume-lifecycle.spec.ts b/tests/e2e/specs/resume-lifecycle.spec.ts index 0c64c240b..6d66d1049 100644 --- a/tests/e2e/specs/resume-lifecycle.spec.ts +++ b/tests/e2e/specs/resume-lifecycle.spec.ts @@ -6,7 +6,11 @@ test("creates a sample resume and persists a basics edit", async ({ authPage: pa const updatedName = `E2E Edited ${Date.now()}`; await openSidebarSection(page, "Basics"); + const savePromise = page.waitForResponse( + (response) => response.url().includes("/api/rpc") && response.request().method() === "POST" && response.ok(), + ); await page.getByLabel("Name").fill(updatedName); + await savePromise; await page.reload(); await openSidebarSection(page, "Basics");