Skip to content

Commit f0ad983

Browse files
authored
Merge branch 'main' into race-condition-e2e
2 parents f3d887d + 68f3208 commit f0ad983

15 files changed

Lines changed: 648 additions & 412 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use client';
2+
3+
import { useRouter } from 'waku';
4+
5+
export function SkipNavToBButton() {
6+
const router = useRouter();
7+
return (
8+
<button
9+
data-testid="skip-go-b"
10+
onClick={() => router.push('/skip/b')}
11+
type="button"
12+
>
13+
Go skip/b
14+
</button>
15+
);
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { ReactNode } from 'react';
2+
3+
export default function SkipLayout({ children }: { children: ReactNode }) {
4+
return (
5+
<main>
6+
<h2 data-testid="skip-static-layout-marker">SKIP_STATIC_LAYOUT_MARKER</h2>
7+
{children}
8+
</main>
9+
);
10+
}
11+
12+
export const getConfig = () => {
13+
return {
14+
render: 'static',
15+
} as const;
16+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { SkipNavToBButton } from '../../components/skip-nav.js';
2+
3+
export default function SkipPageA() {
4+
return (
5+
<div>
6+
<h1>SKIP_A_PAGE_MARKER</h1>
7+
<SkipNavToBButton />
8+
</div>
9+
);
10+
}
11+
12+
export const getConfig = () => {
13+
return {
14+
render: 'dynamic',
15+
} as const;
16+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default function SkipPageB() {
2+
return (
3+
<div>
4+
<h1>SKIP_B_PAGE_MARKER</h1>
5+
</div>
6+
);
7+
}
8+
9+
export const getConfig = () => {
10+
return {
11+
render: 'dynamic',
12+
} as const;
13+
};

e2e/fixtures/waku-jotai-integration/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"react-dom": "~19.2.4",
1515
"react-server-dom-webpack": "~19.2.4",
1616
"waku": "latest",
17-
"waku-jotai": "^0.2.1"
17+
"waku-jotai": "https://pkg.pr.new/waku-jotai@8"
1818
},
1919
"devDependencies": {
2020
"@types/react": "^19.2.14",

e2e/router-client-no-404.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ test.describe('router-client-no-404', () => {
3131
await expect(page.getByRole('heading', { name: 'Custom 404' })).toHaveCount(
3232
0,
3333
);
34-
await expect(page).toHaveURL(/\/start$/);
34+
await expect(page).toHaveURL(/\/missing$/);
3535
});
3636
});

e2e/router-client.spec.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,49 @@ test.describe('router-client', () => {
341341
await expect(page.getByTestId('route-query')).toHaveText('x=1');
342342
});
343343

344+
test('skip header omits static layout payload on soft navigation', async ({
345+
page,
346+
}) => {
347+
await page.goto(`http://localhost:${port}/skip/a`);
348+
await waitForHydration(page);
349+
350+
await expect(page.getByTestId('skip-static-layout-marker')).toHaveText(
351+
'SKIP_STATIC_LAYOUT_MARKER',
352+
);
353+
await expect(
354+
page.getByRole('heading', { name: 'SKIP_A_PAGE_MARKER' }),
355+
).toBeVisible();
356+
357+
const rscResponsePromise = page.waitForResponse(
358+
(response) =>
359+
response.url().includes('/RSC/R/skip/b.txt') &&
360+
response.request().method() === 'GET',
361+
);
362+
363+
await page.getByTestId('skip-go-b').click();
364+
365+
const response = await rscResponsePromise;
366+
const request = response.request();
367+
const skipHeader = request.headers()['x-waku-router-skip'];
368+
369+
expect(skipHeader).toBeTruthy();
370+
const skipIds = JSON.parse(skipHeader as string) as unknown;
371+
expect(Array.isArray(skipIds)).toBe(true);
372+
expect(skipIds).toContain('root');
373+
374+
const payload = await response.text();
375+
expect(payload).toContain('SKIP_B_PAGE_MARKER');
376+
expect(payload).not.toContain('SKIP_STATIC_LAYOUT_MARKER');
377+
expect(payload).not.toContain('SKIP_A_PAGE_MARKER');
378+
379+
await expect(
380+
page.getByRole('heading', { name: 'SKIP_B_PAGE_MARKER' }),
381+
).toBeVisible();
382+
await expect(page.getByTestId('skip-static-layout-marker')).toHaveText(
383+
'SKIP_STATIC_LAYOUT_MARKER',
384+
);
385+
});
386+
344387
test('unstable_prefetchOnView triggers prefetch when link enters viewport', async ({
345388
page,
346389
}) => {
@@ -459,7 +502,7 @@ test.describe('router-client', () => {
459502
page.getByRole('heading', { name: 'Custom 404' }),
460503
).toBeVisible();
461504
await expect(page.getByTestId('route-path')).toHaveText('/404');
462-
await expect(page).toHaveURL(/\/start$/);
505+
await expect(page).toHaveURL(/\/missing$/);
463506
consoleErrors = dropExpectedErrorFlowConsoleErrors(consoleErrors);
464507
});
465508
});

examples/08_jotai-demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"react-dom": "~19.2.4",
1515
"react-server-dom-webpack": "~19.2.4",
1616
"waku": "1.0.0-alpha.4",
17-
"waku-jotai": "^0.2.1"
17+
"waku-jotai": "https://pkg.pr.new/waku-jotai@8"
1818
},
1919
"devDependencies": {
2020
"@tailwindcss/vite": "^4.1.18",

examples/54_jotai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"react-dom": "~19.2.4",
1515
"react-server-dom-webpack": "~19.2.4",
1616
"waku": "1.0.0-alpha.4",
17-
"waku-jotai": "^0.2.1"
17+
"waku-jotai": "https://pkg.pr.new/waku-jotai@8"
1818
},
1919
"devDependencies": {
2020
"@types/react": "^19.2.14",

0 commit comments

Comments
 (0)