Skip to content

Commit c444727

Browse files
author
Jacek
committed
test(nextjs): Add E2E tests for dynamic route with cacheComponents
1 parent f82abb2 commit c444727

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎integration/templates/next-cache-components/src/app/page.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ export default function Home() {
4242
<li>
4343
<Link href='/sign-in'>Sign In</Link>
4444
</li>
45+
<li>
46+
<Link href='/dynamic-route/test-123'>Dynamic Route</Link>
47+
</li>
4548
</ul>
4649
</nav>
4750
</main>

‎integration/tests/cache-components.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,24 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes], withPattern:
284284
await expect(page).toHaveURL(/sign-in/);
285285
});
286286

287+
test('dynamic route renders correctly via direct navigation', async ({ page, context }) => {
288+
const u = createTestUtils({ app, page, context });
289+
await u.page.goToRelative('/dynamic-route/test-123');
290+
await expect(u.page.getByText('Dynamic Route')).toBeVisible();
291+
await expect(u.page.getByTestId('route-id')).toContainText('test-123');
292+
});
293+
294+
test('client-side navigation to dynamic route works', async ({ page, context }) => {
295+
const u = createTestUtils({ app, page, context });
296+
await u.page.goToRelative('/');
297+
await expect(u.page.getByText('Next.js Cache Components Test App')).toBeVisible();
298+
299+
// Click the dynamic route link (exercises ClerkProvider's navigation hooks)
300+
await u.page.getByRole('link', { name: 'Dynamic Route' }).click();
301+
await expect(u.page.getByText('Dynamic Route')).toBeVisible();
302+
await expect(u.page.getByTestId('route-id')).toContainText('test-123');
303+
});
304+
287305
test('protected route accessible when authenticated', async ({ page, context }) => {
288306
const u = createTestUtils({ app, page, context });
289307

0 commit comments

Comments
 (0)