Unverified Commit 8231013e authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Stabilize navigation timing tests

Co-authored-by: 's avatarWill Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
parent c1685111
...@@ -921,6 +921,7 @@ describe('instant-nav-panel', () => { ...@@ -921,6 +921,7 @@ describe('instant-nav-panel', () => {
await clickStartCapturing(browser) await clickStartCapturing(browser)
await clickLink(browser, '/target-page/my-post?search=foo') await clickLink(browser, '/target-page/my-post?search=foo')
await expectSpaPanel(browser) await expectSpaPanel(browser)
await expectTargetPageSpaShell(browser)
await retry(async () => { await retry(async () => {
expect(await browser.url()).toContain('/target-page/my-post') expect(await browser.url()).toContain('/target-page/my-post')
}, 10000) }, 10000)
......
...@@ -305,33 +305,46 @@ describe('searchparams-reuse-loading', () => { ...@@ -305,33 +305,46 @@ describe('searchparams-reuse-loading', () => {
) )
await id3FullPrefetchResponse await id3FullPrefetchResponse
interceptRequests = true interceptRequests = true
// The first link we click is "auto" prefetched.
// Exercise the full prefetch immediately after observing its response.
// Running the two stalled dynamic navigations first can exceed the
// prefetch cache's stale time on a slow CI worker.
shouldStallDynamicRequests = false
await browser await browser
.elementByCss(`[href="${searchParamsPagePath}?id=1"]`) .elementByCss(`[href="${searchParamsPagePath}?id=3"]`)
.click() .click()
// We expect to click it and immediately see a loading state const params3 = await browser.waitForElementByCss('#params').text()
expect(params3).toBe('{"id":"3"}')
expect(nonPrefetchRscRequests.has(`${searchParamsPagePath}?id=3`)).toBe(
false
)
await browser.elementByCss(`[href='${path}']`).click()
shouldStallDynamicRequests = true
// The first "auto" prefetched link should show its loading state while
// the dynamic request is stalled.
await browser
.elementByCss(`[href="${searchParamsPagePath}?id=1"]`)
.click()
expect(await browser.elementById('loading').text()).toBe('Loading...') expect(await browser.elementById('loading').text()).toBe('Loading...')
// We only resolve the dynamic request after we've confirmed loading exists,
// to avoid a race where the dynamic request handles the loading state instead.
let dynamicRequest = rscRequestPromise.get( let dynamicRequest = rscRequestPromise.get(
`${searchParamsPagePath}?id=1` `${searchParamsPagePath}?id=1`
) )
expect(dynamicRequest).toBeDefined() expect(dynamicRequest).toBeDefined()
// resolve the promise
await dynamicRequest.resolve() await dynamicRequest.resolve()
dynamicRequest = undefined dynamicRequest = undefined
// Confirm the params are correct
const params = await browser.waitForElementByCss('#params').text() const params = await browser.waitForElementByCss('#params').text()
expect(params).toBe('{"id":"1"}') expect(params).toBe('{"id":"1"}')
await browser.elementByCss(`[href='${path}']`).click() await browser.elementByCss(`[href='${path}']`).click()
// Do the exact same thing again, for another prefetch auto link, to ensure // Repeat with another auto-prefetched link to ensure the loading state
// loading works as expected and we get different search params // is reused with different search params.
await browser await browser
.elementByCss(`[href="${searchParamsPagePath}?id=2"]`) .elementByCss(`[href="${searchParamsPagePath}?id=2"]`)
.click() .click()
...@@ -339,29 +352,11 @@ describe('searchparams-reuse-loading', () => { ...@@ -339,29 +352,11 @@ describe('searchparams-reuse-loading', () => {
dynamicRequest = rscRequestPromise.get(`${searchParamsPagePath}?id=2`) dynamicRequest = rscRequestPromise.get(`${searchParamsPagePath}?id=2`)
expect(dynamicRequest).toBeDefined() expect(dynamicRequest).toBeDefined()
// resolve the promise
await dynamicRequest.resolve() await dynamicRequest.resolve()
dynamicRequest = undefined dynamicRequest = undefined
const params2 = await browser.waitForElementByCss('#params').text() const params2 = await browser.waitForElementByCss('#params').text()
expect(params2).toBe('{"id":"2"}') expect(params2).toBe('{"id":"2"}')
// Dev mode doesn't perform full prefetches, so this test is conditional
await browser.elementByCss(`[href='${path}']`).click()
// A full prefetch should satisfy this navigation without a dynamic RSC
// request. Let an unexpected fallback complete so the assertion below
// reports the prefetch miss instead of hanging on an intercepted request.
shouldStallDynamicRequests = false
await browser
.elementByCss(`[href="${searchParamsPagePath}?id=3"]`)
.click()
const params3 = await browser.waitForElementByCss('#params').text()
expect(params3).toBe('{"id":"3"}')
expect(nonPrefetchRscRequests.has(`${searchParamsPagePath}?id=3`)).toBe(
false
)
}) })
}) })
......
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