Open History to see the last commit
1import { expect, test } from '@playwright/test'
2β
3test('transitions/count/create-resource should keep old values visible during navigation', async ({
4 page,
5}) => {
6 await page.goto('/transition/count/create-resource')
7β
8 await expect(page.getByTestId('n-value')).toContainText('n: 1')
9 await expect(page.getByTestId('double-value')).toContainText('double: 2')
10β
11 const bodyTexts: Array<string> = []
12β
13 const pollInterval = setInterval(async () => {
14 const text = await page
15 .locator('body')
16 .textContent()
17 .catch(() => '')
18 if (text) bodyTexts.push(text)
19 }, 50)
20β
21 // 1 click
22β
23 page.getByTestId('increase-button').click()
24β
25 await expect(page.getByTestId('n-value')).toContainText('n: 1', {
26 timeout: 2_000,
27 })
28 await expect(page.getByTestId('double-value')).toContainText('double: 2', {
29 timeout: 2_000,
30 })
31β
32 await page.waitForTimeout(200)
33β
34 await expect(page.getByTestId('n-value')).toContainText('n: 2', {
35 timeout: 2000,
36 })
37 await expect(page.getByTestId('double-value')).toContainText('double: 4', {
38 timeout: 2000,
39 })
40β
41 // 2 clicks
42β
43 page.getByTestId('increase-button').click()
44 page.getByTestId('increase-button').click()
45β
46 await expect(page.getByTestId('n-value')).toContainText('n: 2', {
47 timeout: 2000,
48 })
49 await expect(page.getByTestId('double-value')).toContainText('double: 4', {
50 timeout: 2000,
51 })
52β
53 await page.waitForTimeout(200)
54β
55 await expect(page.getByTestId('n-value')).toContainText('n: 4', {
56 timeout: 2000,
57 })
58 await expect(page.getByTestId('double-value')).toContainText('double: 8', {
59 timeout: 2000,
60 })
61β
62 // 3 clicks
63β
64 page.getByTestId('increase-button').click()
65 page.getByTestId('increase-button').click()
66 page.getByTestId('increase-button').click()
67β
68 await expect(page.getByTestId('n-value')).toContainText('n: 4', {
69 timeout: 2000,
70 })
71 await expect(page.getByTestId('double-value')).toContainText('double: 8', {
72 timeout: 2000,
73 })
74β
75 await page.waitForTimeout(200)
76β
77 await expect(page.getByTestId('n-value')).toContainText('n: 7', {
78 timeout: 2000,
79 })
80 await expect(page.getByTestId('double-value')).toContainText('double: 14', {
81 timeout: 2000,
82 })
83β
84 clearInterval(pollInterval)
85β
86 // With proper transitions, old values should remain visible until new ones arrive
87 const hasLoadingText = bodyTexts.some((text) => text.includes('Loading...'))
88β
89 if (hasLoadingText) {
90 throw new Error(
91 'FAILED: "Loading..." appeared during navigation. ' +
92 'Solid Router should use transitions to keep old values visible.',
93 )
94 }
95})