From 2ac08937655e943f42b4b322ae43264766995902 Mon Sep 17 00:00:00 2001
From: Sean Doyle Navigation
diff --git a/src/tests/functional/navigation_tests.js b/src/tests/functional/navigation_tests.js index e5c3986f8..73871e1c2 100644 --- a/src/tests/functional/navigation_tests.js +++ b/src/tests/functional/navigation_tests.js @@ -27,19 +27,16 @@ test.beforeEach(async ({ page }) => { await readEventLogs(page) }) -test("navigating renders a progress bar", async ({ page }) => { - assert.equal( - await page.locator("style").evaluate((style) => style.nonce), - "123", - "renders progress bar stylesheet inline with nonce" - ) - +test("navigating renders a progress bar until the next turbo:load", async ({ page }) => { await page.evaluate(() => window.Turbo.setProgressBarDelay(0)) await page.click("#delayed-link") await waitUntilSelector(page, ".turbo-progress-bar") assert.ok(await hasSelector(page, ".turbo-progress-bar"), "displays progress bar") + await nextEventNamed(page, "turbo:render") + assert.ok(await hasSelector(page, ".turbo-progress-bar"), "displays progress bar") + await nextEventNamed(page, "turbo:load") await waitUntilNoSelector(page, ".turbo-progress-bar") @@ -53,6 +50,14 @@ test("navigating does not render a progress bar before expiring the delay", asyn assert.notOk(await hasSelector(page, ".turbo-progress-bar"), "does not show progress bar before delay") }) +test("navigating hides the progress bar on failure", async ({ page }) => { + await page.evaluate(() => window.Turbo.setProgressBarDelay(0)) + await page.click("#delayed-failure-link") + + await waitUntilSelector(page, ".turbo-progress-bar") + await waitUntilNoSelector(page, ".turbo-progress-bar") +}) + test("after loading the page", async ({ page }) => { assert.equal(pathname(page.url()), "/src/tests/fixtures/navigation.html") assert.equal(await visitAction(page), "load") diff --git a/src/tests/server.mjs b/src/tests/server.mjs index 0d35cb57d..5cb585b4c 100644 --- a/src/tests/server.mjs +++ b/src/tests/server.mjs @@ -79,8 +79,9 @@ router.get("/headers", (request, response) => { }) router.get("/delayed_response", (request, response) => { + const { status } = request.query const fixture = path.join(__dirname, "../../src/tests/fixtures/one.html") - setTimeout(() => response.status(200).sendFile(fixture), 1000) + setTimeout(() => response.status(parseInt(status || "200")).sendFile(fixture), 1000) }) router.post("/messages", (request, response) => {