fix(interception): use locale-prefixed href so middleware interception fires correctly

This commit is contained in:
Divanshu Chauhan
2026-06-06 17:52:05 -07:00
parent 967f1aaa70
commit 02e80c2670
2 changed files with 3 additions and 12 deletions
@@ -11,8 +11,6 @@ const LOCALE_HOME = `${BASE}/interception-mw/en`;
test.describe("interception-dynamic-segment-middleware", () => {
test("intercepts dynamic route when middleware rewrites add locale prefix", async ({ page }) => {
// TODO(#1364 Part C): interception doesn't fire when middleware rewrites add a locale prefix.
test.fail();
await page.goto(LOCALE_HOME);
await waitForAppRouterHydration(page);
@@ -24,8 +22,6 @@ test.describe("interception-dynamic-segment-middleware", () => {
});
test("refresh after interception shows non-intercepted page", async ({ page }) => {
// TODO(#1364 Part C): depends on interception firing (see test above).
test.fail();
await page.goto(LOCALE_HOME);
await waitForAppRouterHydration(page);
@@ -42,8 +38,6 @@ test.describe("interception-dynamic-segment-middleware", () => {
test("back/forward navigation preserves intercepted state with middleware active", async ({
page,
}) => {
// TODO(#1364 Part C): depends on interception firing (see test above).
test.fail();
await page.goto(LOCALE_HOME);
await waitForAppRouterHydration(page);
@@ -58,8 +52,6 @@ test.describe("interception-dynamic-segment-middleware", () => {
});
test("repeated interceptions with middleware work consistently", async ({ page }) => {
// TODO(#1364 Part C): depends on interception firing (see test above).
test.fail();
for (let i = 0; i < 2; i++) {
await page.goto(LOCALE_HOME);
await waitForAppRouterHydration(page);
@@ -1,11 +1,10 @@
import Link from "next/link";
export default function Page() {
export default async function Page({ params }: { params: Promise<{ locale: string }> }) {
const { locale } = await params;
return (
<div>
{/* Link without locale — middleware rewrites /interception-mw/foo/p/1
to /interception-mw/en/foo/p/1 so interception fires */}
<Link href="/interception-mw/foo/p/1" id="link-foo-p-1">
<Link href={`/interception-mw/${locale}/foo/p/1`} id="link-foo-p-1">
Foo
</Link>
</div>