Skip to content

Commit 1bc5701

Browse files
moeki0seanpdoyle
authored andcommitted
Add test for download
1 parent c285fe8 commit 1bc5701

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/tests/fixtures/rendering.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ <h1>Rendering</h1>
4747
<p><a id="delayed-link" href="/__turbo/delayed_response">Delayed link</a></p>
4848
<p><a id="redirect-link" href="/__turbo/redirect">Redirect link</a></p>
4949
<p><a id="es_locale_link" href="/src/tests/fixtures/es_locale.html">Change html[lang]</a></p>
50+
<p><a id="download-link" href="/__turbo/download">Download link</a></p>
5051
<form>
5152
<input type="text" id="text-input">
5253
<input type="radio" id="radio-input">

src/tests/functional/rendering_tests.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,14 @@ test("rendering a redirect response replaces the body once and only once", async
568568
expect(await noNextBodyMutation(page), "replaces <body> element once").toEqual(true)
569569
})
570570

571+
572+
test("hides progress bar when reloading due to request failure", async ({ page }) => {
573+
await page.click("#download-link")
574+
await page.waitForEvent("download")
575+
576+
await expect(page.locator(".turbo-progress-bar"), "hides progress bar").not.toBeAttached()
577+
})
578+
571579
function deepElementsEqual(page, left, right) {
572580
return page.evaluate(
573581
([left, right]) => left.length == right.length && left.every((element) => right.includes(element)),

src/tests/server.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ router.get("/file.unknown_html", (request, response) => {
189189
response.sendFile(path.join(__dirname, "../../src/tests/fixtures/visit.html"))
190190
})
191191

192+
router.get("/download", (request, response) => {
193+
response.download(path.join(__dirname, "../../src/tests/fixtures/svg.svg"))
194+
})
195+
192196
function receiveMessage(content, id, target) {
193197
const data = renderSSEData(renderMessage(content, id, target))
194198
for (const response of streamResponses) {

0 commit comments

Comments
 (0)