Unverified Commit cd5d0058 authored by Janka Uryga's avatar Janka Uryga Committed by GitHub

test: attempt to unflake useLinkStatus interrupted navigation test (#77969)

This test flaked for me here:
https://github.com/vercel/next.js/actions/runs/14353556171/job/40239845657#step:33:678

I suspect this is because \[the assertion that the pending state should
disappear\] sometimes runs too soon. I made it wait until the
side-effect of clicking the "debug mode" button becomes visible before
checking if the pending state is gone. If this fix doesn't improve the
situation, it indicates a bug in `useLinkStatus`, because the pending
state is still hanging around for some reason.

(i chose not to just wrap the assertion in a `retry()`, because we want
to ensure that the indicator disappears immediately, not at some
unspecified point in the future)
parent 78523679
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { waitFor } from 'next-test-utils' import { retry, waitFor } from 'next-test-utils'
describe('useLinkStatus', () => { describe('useLinkStatus', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
...@@ -39,6 +39,13 @@ describe('useLinkStatus', () => { ...@@ -39,6 +39,13 @@ describe('useLinkStatus', () => {
// Trigger shallow routing by clicking debug mode button // Trigger shallow routing by clicking debug mode button
await browser.elementById('enable-debug-btn').click() await browser.elementById('enable-debug-btn').click()
// Wait for the new render to commit to make sure that the navigation transition is interrupted
await retry(async () => {
expect(
await browser.elementByCss('[data-testid="debug-mode"]').text()
).toBe('Debug Mode Enabled')
})
// Pending state should be gone // Pending state should be gone
const post1LoadingElements = await browser.elementsByCss('#post-1-loading') const post1LoadingElements = await browser.elementsByCss('#post-1-loading')
expect(post1LoadingElements.length).toBe(0) expect(post1LoadingElements.length).toBe(0)
......
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