Skip to content

Commit 49f992e

Browse files
authored
Add e2e test for spa mode disabling sigle fetch (#13013)
1 parent 1b7b6b8 commit 49f992e

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

integration/vite-spa-mode-test.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,61 @@ test.describe("SPA Mode", () => {
637637
expect(html.match(/window.__reactRouterContext =/g)?.length).toBe(1);
638638
expect(html.match(/💿 Hey developer 👋/g)?.length).toBe(1);
639639
});
640+
641+
test("does not inherit single fetch revalidation behavior", async ({
642+
page,
643+
}) => {
644+
fixture = await createFixture({
645+
spaMode: true,
646+
files: {
647+
"react-router.config.ts": reactRouterConfig({
648+
ssr: false,
649+
splitRouteModules,
650+
}),
651+
"app/routes/_index.tsx": js`
652+
import { Link } from 'react-router';
653+
export default function Component() {
654+
return <Link to="/parent">Go to parent</Link>;
655+
}
656+
`,
657+
"app/routes/parent.tsx": js`
658+
import { Link, Outlet } from 'react-router';
659+
let count = 0;
660+
export function clientLoader() {
661+
return ++count;
662+
}
663+
export default function Component({ loaderData }) {
664+
return (
665+
<>
666+
<h1>Parent: {loaderData}</h1>
667+
<Link to="./child">Go to child</Link>
668+
<Outlet />
669+
</>
670+
)
671+
}
672+
`,
673+
"app/routes/parent.child.tsx": js`
674+
import { Link } from 'react-router';
675+
export default function Component({ loaderData }) {
676+
return <h2>Child</h2>;
677+
}
678+
`,
679+
},
680+
});
681+
appFixture = await createAppFixture(fixture);
682+
683+
let app = new PlaywrightFixture(appFixture, page);
684+
await app.goto("/", true);
685+
await page.waitForSelector('a[href="/parent"]');
686+
await app.clickLink("/parent");
687+
await page.waitForSelector("h1");
688+
expect(await page.locator("h1").textContent()).toBe("Parent: 1");
689+
690+
await app.clickLink("/parent/child");
691+
await page.waitForSelector("h2");
692+
expect(await page.locator("h1").textContent()).toBe("Parent: 1");
693+
expect(await page.locator("h2").textContent()).toBe("Child");
694+
});
640695
});
641696

642697
test.describe("normal apps", () => {

0 commit comments

Comments
 (0)