diff --git a/src/core/drive/visit.ts b/src/core/drive/visit.ts index 6d709f2ff..0763aa13a 100644 --- a/src/core/drive/visit.ts +++ b/src/core/drive/visit.ts @@ -322,7 +322,6 @@ export class Visit implements FetchRequestDelegate { if (this.redirectedToLocation && !this.followedRedirect && this.response?.redirected) { this.adapter.visitProposedToLocation(this.redirectedToLocation, { action: "replace", - willRender: false, response: this.response, }) this.followedRedirect = true diff --git a/src/tests/fixtures/navigation.html b/src/tests/fixtures/navigation.html index 54cd56547..5d89a8df0 100644 --- a/src/tests/fixtures/navigation.html +++ b/src/tests/fixtures/navigation.html @@ -68,6 +68,7 @@

Navigation

Delayed link

Targets iframe

+

Redirect to cache_observer.html

diff --git a/src/tests/functional/cache_observer_tests.ts b/src/tests/functional/cache_observer_tests.ts index edc923391..0b61fc7ee 100644 --- a/src/tests/functional/cache_observer_tests.ts +++ b/src/tests/functional/cache_observer_tests.ts @@ -2,15 +2,25 @@ import { test } from "@playwright/test" import { assert } from "chai" import { hasSelector, nextBody } from "../helpers/page" -test.beforeEach(async ({ page }) => { +test("test removes stale elements", async ({ page }) => { await page.goto("/src/tests/fixtures/cache_observer.html") -}) -test("test removes stale elements", async ({ page }) => { - assert(await hasSelector(page, "#flash")) - page.click("#link") + assert.equal(await page.textContent("#flash"), "Rendering") + + await page.click("#link") await nextBody(page) await page.goBack() await nextBody(page) + assert.notOk(await hasSelector(page, "#flash")) }) + +test("test following a redirect renders a [data-turbo-cache=false] element before the cache omits it", async ({ + page, +}) => { + await page.goto("/src/tests/fixtures/navigation.html") + await page.click("#redirect-to-cache-observer") + await nextBody(page) + + assert.equal(await page.textContent("#flash"), "Rendering") +})