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: use native click for blocked navigation

Amruth Pillai07ca5d7c9e2f
diff --git a/tests/e2e/specs/builder-save-navigation.spec.ts b/tests/e2e/specs/builder-save-navigation.spec.ts
index 04e5f8086..dc490689e 100644
--- a/tests/e2e/specs/builder-save-navigation.spec.ts
+++ b/tests/e2e/specs/builder-save-navigation.spec.ts
@@ -15,6 +15,11 @@ function waitSave(page: Page) {
(response) => new URL(response.url()).pathname === "/api/rpc/resume/update" && response.ok(),
);
}
+function clickDashboardWithoutNavigationWait(page: Page) {
+ return page
+ .getByRole("button", { name: "Go to resumes dashboard", exact: true })
+ .evaluate((element) => element.click());
+}
async function prepareNavigationTest(page: Page, testInfo: TestInfo) {
await createSampleResumeFromDashboard(page, testInfo);
@@ -41,7 +46,7 @@ test("retries a failed autosave before leaving the builder", async ({ authPage:
await release.promise;
await route.continue();
});
- await page.getByRole("button", { name: "Go to resumes dashboard", exact: true }).dispatchEvent("click");
+ await clickDashboardWithoutNavigationWait(page);
await arrived.promise;
expect(page.url()).toBe(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Draft recovered before leaving");
@@ -60,13 +65,13 @@ test("retains the current draft when saving during navigation fails", async ({ a
});
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 page.getByRole("button", { name: "Go to resumes dashboard", exact: true }).dispatchEvent("click");
+ 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 page.getByRole("button", { name: "Go to resumes dashboard", exact: true }).dispatchEvent("click");
+ await clickDashboardWithoutNavigationWait(page);
await page.waitForURL(/\/dashboard/);
await page.goto(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Keep unsaved draft");
@@ -91,7 +96,7 @@ test("stops waiting for a slow save while preserving late acknowledgements and q
await page.getByLabel("Name", { exact: true }).fill("Slow save draft");
await page.clock.fastForward(600);
await arrived.promise;
- await page.getByRole("button", { name: "Go to resumes dashboard", exact: true }).dispatchEvent("click");
+ await clickDashboardWithoutNavigationWait(page);
await page.clock.fastForward(10000);
const slowNotice = page.getByText("Saving is taking longer than expected. Your changes are still open.", {
exact: true,
@@ -114,7 +119,7 @@ test("stops waiting for a slow save while preserving late acknowledgements and q
await latestSaved;
await expect(page.getByRole("status").filter({ hasText: "Saved" })).toBeVisible();
await expect(slowNotice).toBeHidden();
- await page.getByRole("button", { name: "Go to resumes dashboard", exact: true }).dispatchEvent("click");
+ await clickDashboardWithoutNavigationWait(page);
await page.waitForURL(/\/dashboard/);
await page.goto(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Slow save draft");