Skip to content

Commit ad1b477

Browse files
committed
test(org): let the prefetch deliver Links' loading state before holding the click's read
The hold also caught the rail link's prefetch, and the router can only show a loading boundary it already has, so Home stayed up with nothing to announce.
1 parent 2974a6c commit ad1b477

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

  • apps/sim/scripts/org-redesign-e2e/checks

‎apps/sim/scripts/org-redesign-e2e/checks/links.ts‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
import {
1515
check,
1616
expect,
17-
onHome,
1817
orgUrl,
1918
PHONE,
2019
refused,
@@ -383,15 +382,22 @@ export async function linksChecks() {
383382
await check(
384383
'loading, failure with Retry, and the empty state',
385384
async () => {
386-
await onHome(MEMBER, async ({ page }) => {
385+
await withSession(MEMBER, async ({ page }) => {
387386
const hold = createDeferred<void>()
388-
await page.route(
389-
(address) => address.pathname === `${root}/links` && address.searchParams.has('_rsc'),
390-
async (route) => {
391-
await hold.promise
392-
await route.continue()
393-
}
387+
const isLinksPayload = (address: URL) =>
388+
address.pathname === `${root}/links` && address.searchParams.has('_rsc')
389+
// Only the click's own read: the router shows the loading state from what a prefetch delivered.
390+
await page.route(isLinksPayload, async (route) => {
391+
if (route.request().headers()['next-router-prefetch'] === undefined) await hold.promise
392+
await route.continue()
393+
})
394+
const loadingPrefetched = page.waitForResponse(
395+
async (response) =>
396+
isLinksPayload(new URL(response.url())) &&
397+
(await response.text()).includes('Loading links')
394398
)
399+
await page.goto(orgUrl('/home'))
400+
await loadingPrefetched
395401
await mainNav(page).getByRole('link', { name: 'Links', exact: true }).click()
396402
await expect(page.getByRole('status', { name: 'Loading links' })).toBeVisible()
397403
await expect(page.getByRole('button', { name: 'New link', exact: true })).toBeVisible()

0 commit comments

Comments
 (0)