diff --git a/src/core/native/browser_adapter.js b/src/core/native/browser_adapter.js index 6f4c73bfe..115821ae1 100644 --- a/src/core/native/browser_adapter.js +++ b/src/core/native/browser_adapter.js @@ -43,12 +43,13 @@ export class BrowserAdapter { case SystemStatusCode.networkFailure: case SystemStatusCode.timeoutFailure: case SystemStatusCode.contentTypeMismatch: - return this.reload({ + this.reload({ reason: "request_failed", context: { statusCode } }) + return visit.fail() default: return visit.loadResponse() } diff --git a/src/tests/fixtures/rendering.html b/src/tests/fixtures/rendering.html index f03e725a8..788c2a959 100644 --- a/src/tests/fixtures/rendering.html +++ b/src/tests/fixtures/rendering.html @@ -47,6 +47,7 @@

Rendering

Delayed link

Redirect link

Change html[lang]

+

Download link

diff --git a/src/tests/functional/rendering_tests.js b/src/tests/functional/rendering_tests.js index 66a9d1af0..16e1a0b85 100644 --- a/src/tests/functional/rendering_tests.js +++ b/src/tests/functional/rendering_tests.js @@ -3,6 +3,7 @@ import { assert } from "chai" import { clearLocalStorage, disposeAll, + hasSelector, isScrolledToTop, nextBeat, nextBody, @@ -17,7 +18,8 @@ import { sleep, strictElementEquals, textContent, - visitAction + visitAction, + waitUntilNoSelector, } from "../helpers/page" test.beforeEach(async ({ page }) => { @@ -580,6 +582,15 @@ test("rendering a redirect response replaces the body once and only once", async assert.ok(await noNextBodyMutation(page), "replaces element once") }) + +test.only("hides progress bar when reloading due to request failure", async ({ page }) => { + await page.click("#download-link") + await page.waitForEvent('download') + + await waitUntilNoSelector(page, ".turbo-progress-bar") + assert.notOk(await hasSelector(page, ".turbo-progress-bar"), "hides progress bar") +}) + function deepElementsEqual(page, left, right) { return page.evaluate( ([left, right]) => left.length == right.length && left.every((element) => right.includes(element)), diff --git a/src/tests/server.mjs b/src/tests/server.mjs index 1978ca601..23f2c4620 100644 --- a/src/tests/server.mjs +++ b/src/tests/server.mjs @@ -189,6 +189,10 @@ router.get("/file.unknown_html", (request, response) => { response.sendFile(path.join(__dirname, "../../src/tests/fixtures/visit.html")) }) +router.get("/download", (request, response) => { + response.download(path.join(__dirname, "../../src/tests/fixtures/svg.svg")) +}) + function receiveMessage(content, id, target) { const data = renderSSEData(renderMessage(content, id, target)) for (const response of streamResponses) {