From 0826b8152c0e97f19d459c1a1c364fa89cc62829 Mon Sep 17 00:00:00 2001 From: Dom Christie Date: Fri, 25 Aug 2023 09:56:43 +0100 Subject: [PATCH] Dispatch turbo:load after loading 404 response (#960) * Dispatch turbo:load after loading 404 response * Test turbo:load dispatched on error pages --- src/core/drive/visit.ts | 1 + src/tests/functional/rendering_tests.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index ec2efda92..1a311b640 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -202,6 +202,7 @@ export class Visit implements FetchRequestDelegate { if (this.state == VisitState.started) { this.state = VisitState.failed this.adapter.visitFailed(this) + this.delegate.visitCompleted(this) } } diff --git a/src/tests/functional/rendering_tests.ts b/src/tests/functional/rendering_tests.ts index a621191d8..bb8e33885 100644 --- a/src/tests/functional/rendering_tests.ts +++ b/src/tests/functional/rendering_tests.ts @@ -46,7 +46,7 @@ test("test includes isPreview in render event details", async ({ page }) => { assert.equal(await isPreview, false) }) -test("test triggers before-render and render events for error pages", async ({ page }) => { +test("test triggers before-render, render, and load events for error pages", async ({ page }) => { await page.click("#nonexistent-link") const { newBody } = await nextEventNamed(page, "turbo:before-render") @@ -54,6 +54,8 @@ test("test triggers before-render and render events for error pages", async ({ p await nextEventNamed(page, "turbo:render") assert.equal(await newBody, await page.evaluate(() => document.body.outerHTML)) + + await nextEventNamed(page, "turbo:load") }) test("test reloads when tracked elements change", async ({ page }) => {