Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

test: read committed workspace with a fresh authenticated client

Amruth Pillaiffa92f62badb
diff --git a/tests/e2e/specs/career-workspace-undo.spec.ts b/tests/e2e/specs/career-workspace-undo.spec.ts
index ee5146014..e8adac37b 100644
--- a/tests/e2e/specs/career-workspace-undo.spec.ts
+++ b/tests/e2e/specs/career-workspace-undo.spec.ts
@@ -1,4 +1,5 @@
import type { Page } from "@playwright/test";
+import { request } from "@playwright/test";
import { Pool } from "pg";
import { createAuthenticatedContext } from "../fixtures/auth";
import { createAccount } from "../fixtures/data";
@@ -39,6 +40,21 @@ async function removeFirst(page: Page) {
await expect(page.getByRole("button", { name: "Undo", exact: true })).toBeVisible();
}
+async function readCommittedWorkspace(page: Page, applicationId: string) {
+ // Undo outlives the server's idle HTTP connection; read once as an independent authenticated client.
+ const reader = await request.newContext({
+ baseURL: new URL(page.url()).origin,
+ storageState: await page.context().storageState(),
+ });
+ try {
+ const response = await reader.get(`/api/openapi/career/workspace/${applicationId}`);
+ await expect(response).toBeOK();
+ return await response.json();
+ } finally {
+ await reader.dispose();
+ }
+}
+
for (const mode of ["reload", "close"] as const)
test(`acknowledged question removal survives ${mode} without sending the whole large workspace`, async ({
authPage: page,
@@ -85,9 +101,7 @@ test("question removal preserves another client's independent answer edit", asyn
const bytes = response.request().postDataBuffer()?.byteLength ?? 0;
expect(bytes).toBeGreaterThan(0);
expect(bytes).toBeLessThan(60 * 1024);
- await expect
- .poll(async () => (await (await page.request.get(`/api/openapi/career/workspace/${saved.id}`)).json()).answers)
- .toEqual(newer.slice(1));
+ expect((await readCommittedWorkspace(page, saved.id)).answers).toEqual(newer.slice(1));
await expect(page.getByText("Fictional newer question", { exact: true })).toBeVisible();
await page.reload();
await expect(page.getByText("Fictional question 0", { exact: true })).toHaveCount(0);
@@ -110,9 +124,7 @@ test("prepared question removal rejects a stale target and shows its current wor
);
await conflict;
await expect(page.getByText("Fictional updated question", { exact: true })).toBeVisible();
- const current = await page.request.get(`/api/openapi/career/workspace/${saved.id}`);
- await expect(current).toBeOK();
- expect((await current.json()).answers).toEqual(newer);
+ expect((await readCommittedWorkspace(page, saved.id)).answers).toEqual(newer);
});
test("question Undo cancels deletion and cannot recreate an answer erased elsewhere", async ({