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