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: avoid awaiting blocked builder navigation

Amruth Pillaid7b2a843ca49
diff --git a/tests/e2e/specs/builder-save-navigation.spec.ts b/tests/e2e/specs/builder-save-navigation.spec.ts
index 0e4de1824..f62e3ba59 100644
--- a/tests/e2e/specs/builder-save-navigation.spec.ts
+++ b/tests/e2e/specs/builder-save-navigation.spec.ts
@@ -41,11 +41,12 @@ 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 }).click();
+ const navigation = page.getByRole("button", { name: "Go to resumes dashboard", exact: true }).click();
await arrived.promise;
expect(page.url()).toBe(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Draft recovered before leaving");
release.resolve();
+ await navigation;
await page.waitForURL(/\/dashboard/);
await page.goto(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Draft recovered before leaving");
@@ -60,13 +61,14 @@ 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 }).click();
+ const blockedNavigation = page.getByRole("button", { name: "Go to resumes dashboard", exact: true }).click();
+ void blockedNavigation.catch(() => undefined);
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 }).click();
+ await page.getByRole("button", { name: "Go to resumes dashboard", exact: true }).click({ noWaitAfter: true });
await page.waitForURL(/\/dashboard/);
await page.goto(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Keep unsaved draft");
@@ -91,7 +93,8 @@ 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 }).click();
+ const blockedNavigation = page.getByRole("button", { name: "Go to resumes dashboard", exact: true }).click();
+ void blockedNavigation.catch(() => undefined);
await page.clock.fastForward(10000);
const slowNotice = page.getByText("Saving is taking longer than expected. Your changes are still open.", {
exact: true,
@@ -114,7 +117,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 }).click();
+ await page.getByRole("button", { name: "Go to resumes dashboard", exact: true }).click({ noWaitAfter: true });
await page.waitForURL(/\/dashboard/);
await page.goto(url);
await expect(page.getByLabel("Name", { exact: true })).toHaveValue("Slow save draft");