Skip to content

Commit

Permalink
test: handle client side redirects by redirecting RSC files
Browse files Browse the repository at this point in the history
  • Loading branch information
pmelab committed Oct 3, 2024
1 parent 28dbcb9 commit 5892e4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions e2e/broken-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,13 @@ test.describe('client side navigation', () => {
// Click on a link to a broken redirect
await page.getByRole('link', { name: 'Broken redirect' }).click();

// Navigate to a page that redirects to a non-existing page
await page.goto(`http://localhost:${port}/broken-redirect`);
// The page renders the custom 404.tsx
await expect(page.getByRole('heading')).toHaveText('Custom not found');
// The browsers URL remains the one that was redirected to
expect(page.url()).toBe(`http://localhost:${port}/broken`);
// The browsers URL remains the link href
// NOTE: This is inconsistent with server side navigation, but
// there is no way to tell where the RSC request was redirected
// to before failing with 404.
expect(page.url()).toBe(`http://localhost:${port}/broken-redirect`);

// Go back to the index page
await page.getByRole('link', { name: 'Back' }).click();
Expand Down
1 change: 1 addition & 0 deletions e2e/fixtures/broken-links/public/serve.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"redirects": [
{ "source": "/redirect", "destination": "/exists" },
{ "source": "/RSC/redirect.txt", "destination": "/RSC/exists.txt" },
{ "source": "/broken-redirect", "destination": "/broken" }
]
}

0 comments on commit 5892e4a

Please sign in to comment.