Unverified Commit 3c296ea2 authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

[test] Stabilize the cache revalidation navigation test (#100514)

The navigation test added in #100447 could fail in CI with a
`Network.getResponseBody` protocol error. It tried to read the browser
response after `createRouterAct` had intercepted and fulfilled the
request.

The test now relies on the existing `act` response assertion, DOM check,
and cached return navigation instead of reading the intercepted response
body again.

[Flakiness
metrics](https://app.datadoghq.com/ci/ci-cd/explorer/executions?query=test_level%3Atest%20%40git.repository.id%3A%22github.com%2Fvercel%2Fnext.js%22%20%40test.name%3A%22use-cache-swr%20serves%20the%20same%20stale%20value%20in%20navigation%20data%20and%20the%20embedded%20runtime%20prefetch%20while%20revalidation%20is%20pending%22%20%40test.type%3A%22turbopack%22%20%40test.status%3A%22fail%22&agg_m=count&agg_m_source=base&agg_t=count&ci_cd_explorer_tab=tests&fromUser=false&start=1791981691285&end=1792586491285&paused=false)
parent 1984f672
...@@ -156,7 +156,7 @@ describe('use-cache-swr', () => { ...@@ -156,7 +156,7 @@ describe('use-cache-swr', () => {
}, },
}) })
const act = createRouterAct(page, { includeAppShellRequests: true }) const act = createRouterAct(page, { includeAppShellRequests: true })
return { browser, page, act, response } return { browser, act, response }
} }
async function expectCachedRdcNavigation( async function expectCachedRdcNavigation(
...@@ -214,16 +214,10 @@ describe('use-cache-swr', () => { ...@@ -214,16 +214,10 @@ describe('use-cache-swr', () => {
const key = `rdc-navigation-${randomUUID()}` const key = `rdc-navigation-${randomUUID()}`
const foregroundCacheKey = `${key}:foreground` const foregroundCacheKey = `${key}:foreground`
await prepareStaleCacheEntry(key) await prepareStaleCacheEntry(key)
const { browser, page, act } = await createRdcBrowser( const { browser, act } = await createRdcBrowser(key, foregroundCacheKey)
key,
foregroundCacheKey
)
await using _ = defer(() => browser.deleteCookies()) await using _ = defer(() => browser.deleteCookies())
heldResponseKeys.add(key) heldResponseKeys.add(key)
heldResponseKeys.add(foregroundCacheKey) heldResponseKeys.add(foregroundCacheKey)
const pendingNavigationResponse = page.waitForResponse(
(response) => new URL(response.url()).pathname === '/rdc'
)
const pendingNavigation = act( const pendingNavigation = act(
async () => { async () => {
await browser await browser
...@@ -242,8 +236,6 @@ describe('use-cache-swr', () => { ...@@ -242,8 +236,6 @@ describe('use-cache-swr', () => {
releaseDataResponses(foregroundCacheKey) releaseDataResponses(foregroundCacheKey)
await pendingNavigation await pendingNavigation
expect(await browser.elementById('rdc-value').text()).toBe(`${key}-v1`) expect(await browser.elementById('rdc-value').text()).toBe(`${key}-v1`)
const response = await pendingNavigationResponse
expectConsistentCacheValue(await response.text(), key, 1)
await expectCachedRdcNavigation(browser, act, key) await expectCachedRdcNavigation(browser, act, key)
} finally { } finally {
releaseDataResponses(foregroundCacheKey) releaseDataResponses(foregroundCacheKey)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment