Open History to see the last commit
1import { expect } from '@playwright/test'
2import { test } from '@tanstack/router-e2e-utils'
3β
4const testCount = 7
5β
6test.describe('selective ssr', () => {
7 test('testcount matches', async ({ page }) => {
8 await page.goto('/')
9β
10 await expect(page.getByTestId('test-count')).toHaveText(`${testCount}`)
11 })
12β
13 for (let i = 0; i < testCount; i++) {
14 test(`run test ${i}`, async ({ page }) => {
15 await page.goto('/')
16 const testId = `testcase-${i}-link`
17 await page.getByTestId(testId).click()
18β
19 // wait for page to be loaded by waiting for the leaf route to be rendered
20 await expect(page.getByTestId('postId-heading')).toContainText('postId')
21β
22 // check expectations
23 await Promise.all(
24 ['root', 'posts', 'postId'].map(async (route) => {
25 const expectedData = await page
26 .getByTestId(`${route}-data-expected`)
27 .textContent()
28 expect(expectedData).not.toBeNull()
29 await expect(page.getByTestId(`${route}-loader`)).toContainText(
30 expectedData!,
31 )
32 await expect(page.getByTestId(`${route}-context`)).toContainText(
33 expectedData!,
34 )
35 }),
36 )
37 await expect(page.getByTestId('router-isLoading')).toContainText('false')
38 await expect(page.getByTestId('router-status')).toContainText('idle')
39 })
40 }
41})