Files
Reactive-Resume/tests/e2e/specs/builder-save-navigation.spec.ts
T
Amruth PillaiandClaude Opus 5 ffe889b832 test: remove flaky slow-save navigation e2e test
The "stops waiting for a slow save while preserving late acknowledgements
and queued edits" test races Playwright's fake clock against real debounce
and network timing, and has failed intermittently on main and in PRs since
it landed. Six prior stabilization attempts, including bumping its timeout
to 60s, did not hold; the latest run on main still exceeded that budget.

The same behavior is covered deterministically with fake timers in
apps/web/src/features/resume/builder/draft.test.ts ("ends a stalled
navigation wait without aborting or discarding the pending save", plus
the queued-edit and pending-snapshot cases), so removing the e2e test
loses no coverage.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018z9CKmSSEuS2UFMoqhHWtQ
2026-09-09 12:09:54 +02:00

80 lines
3.2 KiB
TypeScript

import type { Page, TestInfo } from "@playwright/test";
import { createSampleResumeFromDashboard } from "../fixtures/resume";
import { expect, test } from "../fixtures/test";
const updateUrl = "**/api/rpc/resume/update";
function barrier() {
let resolve!: () => void;
const promise = new Promise<void>((done) => {
resolve = done;
});
return { promise, resolve };
}
function waitSave(page: Page) {
return page.waitForResponse(
(response) => new URL(response.url()).pathname === "/api/rpc/resume/update" && response.ok(),
);
}
async function clickDashboardWithoutNavigationWait(page: Page) {
const dashboardButton = page.getByRole("button", { name: "Go to resumes dashboard", exact: true });
const box = await dashboardButton.boundingBox();
if (!box) throw new Error("Dashboard navigation button is not visible.");
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
}
async function prepareNavigationTest(page: Page, testInfo: TestInfo) {
await createSampleResumeFromDashboard(page, testInfo);
await page.reload();
const warmup = waitSave(page);
await page.getByLabel("Headline", { exact: true }).fill("Navigation fixture ready");
await warmup;
return page.url();
}
test("retries a failed autosave before leaving the builder", async ({ authPage: page }, testInfo) => {
const url = await prepareNavigationTest(page, testInfo);
await page.route(updateUrl, async (route) => {
await route.abort("failed");
});
await page.getByLabel("Name", { exact: true }).fill("Draft recovered before leaving");
await expect(page.getByText("Your latest changes could not be saved.", { exact: true })).toBeVisible();
await page.unroute(updateUrl);
const arrived = barrier();
const release = barrier();
await page.route(updateUrl, async (route) => {
arrived.resolve();
await release.promise;
await route.continue();
});
await clickDashboardWithoutNavigationWait(page);
await arrived.promise;
expect(page.url()).toBe(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Draft recovered before leaving");
release.resolve();
await page.waitForURL(/\/dashboard/);
await page.goto(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Draft recovered before leaving");
});
test("retains the current draft when saving during navigation fails", async ({ authPage: page }, testInfo) => {
const url = await prepareNavigationTest(page, testInfo);
let attempts = 0;
await page.route(updateUrl, async (route) => {
attempts++;
await route.abort("failed");
});
await page.getByLabel("Name", { exact: true }).fill("Keep unsaved draft");
await expect(page.getByText("Your latest changes could not be saved.", { exact: true })).toBeVisible();
await clickDashboardWithoutNavigationWait(page);
await expect.poll(() => attempts).toBe(2);
await expect(page.getByRole("status").filter({ hasText: "Couldn't save" })).toBeVisible();
expect(page.url()).toBe(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Keep unsaved draft");
await page.unroute(updateUrl);
await clickDashboardWithoutNavigationWait(page);
await page.waitForURL(/\/dashboard/);
await page.goto(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Keep unsaved draft");
});