test: stabilize e2e suite

Co-authored-by: Amruth Pillai <im.amruth@gmail.com>
This commit is contained in:
Cursor Agent
2026-06-20 04:24:31 +00:00
parent 4b2d3289b9
commit 18b3ba1cfb
7 changed files with 35 additions and 23 deletions
+11 -9
View File
@@ -1,28 +1,30 @@
import { readFile } from "node:fs/promises";
import { createSampleResumeFromDashboard, openSidebarSection } from "../fixtures/resume";
import { expect, test } from "../fixtures/test";
test("exports and imports a resume JSON backup", async ({ authPage: page }, testInfo) => {
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);
});
+3 -3
View File
@@ -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();
+4
View File
@@ -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");