Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

rsc-basic.spec.ts

43 lines1.5 KB

1import { expect } from '@playwright/test'
2import { test } from '@tanstack/router-e2e-utils'
3import { waitForHydration } from './hydration'
4​
5test.describe('RSC Basic Tests', () => {
6 test('RSC renders with server timestamp', async ({ page }) => {
7 await page.goto('/rsc-basic')
8 await page.waitForURL('/rsc-basic')
9​
10 // Verify RSC content is rendered
11 await expect(page.getByTestId('rsc-basic-content')).toBeVisible()
12 await expect(page.getByTestId('rsc-server-timestamp')).toBeVisible()
13 await expect(page.getByTestId('rsc-label')).toContainText('Sarah Chen')
14​
15 // Verify timestamps are present
16 const serverTimestamp = await page
17 .getByTestId('rsc-server-timestamp')
18 .textContent()
19 const loaderTimestamp = await page
20 .getByTestId('loader-timestamp')
21 .textContent()
22​
23 expect(serverTimestamp).toContain('Fetched:')
24 expect(Number(loaderTimestamp)).toBeGreaterThan(0)
25 })
26​
27 test('RSC renders correctly after client-side navigation', async ({
28 page,
29 }) => {
30 // Start from home
31 await page.goto('/')
32 await page.waitForURL('/')
33 await waitForHydration(page)
34​
35 // Navigate to RSC page via nav bar (need to be specific to avoid matching example cards)
36 await page.getByTestId('nav-basic').click()
37 await page.waitForURL('/rsc-basic')
38​
39 // Verify RSC content is rendered
40 await expect(page.getByTestId('rsc-basic-content')).toBeVisible()
41 await expect(page.getByTestId('rsc-label')).toContainText('Sarah Chen')
42 })
43})