Skip to content

Commit bebaa00

Browse files
authored
fix: short circuit links and meta for routes that are not rendered due to errors (#6107)
1 parent 71a608f commit bebaa00

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

integration/link-test.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ test.describe("route module link export", () => {
220220
<li>
221221
<Link to="/resources">Resource routes</Link>
222222
</li>
223+
<li>
224+
<Link to="/parent/child">Errored child route</Link>
225+
</li>
223226
</ul>
224227
</nav>
225228
</div>
@@ -471,6 +474,42 @@ test.describe("route module link export", () => {
471474
}
472475
473476
`,
477+
478+
"app/routes/parent.jsx": js`
479+
import { Outlet } from "@remix-run/react";
480+
481+
export function links() {
482+
return [
483+
{ "data-test-id": "red" },
484+
];
485+
}
486+
487+
export default function Component() {
488+
return <div data-test-id="/parent"><Outlet /></div>;
489+
}
490+
491+
export function ErrorBoundary() {
492+
return <h1 data-test-id="/parent:error-boundary">Error Boundary</h1>;
493+
}
494+
`,
495+
496+
"app/routes/parent.child.jsx": js`
497+
import { Outlet } from "@remix-run/react";
498+
499+
export function loader() {
500+
throw new Response(null, { status: 404 });
501+
}
502+
503+
export function links() {
504+
return [
505+
{ "data-test-id": "blue" },
506+
];
507+
}
508+
509+
export default function Component() {
510+
return <div data-test-id="/parent"><Outlet /></div>;
511+
}
512+
`,
474513
},
475514
});
476515
appFixture = await createAppFixture(fixture);
@@ -511,6 +550,17 @@ test.describe("route module link export", () => {
511550
expect(stylesheetResponses.length).toEqual(1);
512551
});
513552

553+
test("does not render errored child route links", async ({ page }) => {
554+
let app = new PlaywrightFixture(appFixture, page);
555+
await app.goto("/", true);
556+
await page.click('a[href="/parent/child"]');
557+
await page.waitForSelector('[data-test-id="/parent:error-boundary"]');
558+
await page.waitForSelector('[data-test-id="red"]', { state: "attached" });
559+
await page.waitForSelector('[data-test-id="blue"]', {
560+
state: "detached",
561+
});
562+
});
563+
514564
test.describe("no js", () => {
515565
test.use({ javaScriptEnabled: false });
516566

@@ -534,6 +584,16 @@ test.describe("route module link export", () => {
534584
let locator = page.locator("link[rel=preload][as=image]");
535585
expect(await locator.getAttribute("imagesizes")).toBe("100vw");
536586
});
587+
588+
test("does not render errored child route links", async ({ page }) => {
589+
let app = new PlaywrightFixture(appFixture, page);
590+
await app.goto("/parent/child");
591+
await page.waitForSelector('[data-test-id="/parent:error-boundary"]');
592+
await page.waitForSelector('[data-test-id="red"]', { state: "attached" });
593+
await page.waitForSelector('[data-test-id="blue"]', {
594+
state: "detached",
595+
});
596+
});
537597
});
538598

539599
test.describe("script imports", () => {

0 commit comments

Comments
 (0)