Open History to see the last commit
1import { expect } from '@playwright/test'
2import { apiTest as test } from '@tanstack/router-e2e-utils'
3β
4test.describe('/search-params/default', () => {
5 test('Directly visiting the route without search param set', async ({
6 page,
7 }) => {
8 await page.goto('/search-params/default')
9 await page.waitForURL('/search-params/default?default=d1')
10β
11 await expect(page.getByTestId('search-default')).toContainText('d1')
12 await expect(page.getByTestId('context-hello')).toContainText('world')
13 expect(
14 page.url().endsWith('/search-params/default?default=d1'),
15 ).toBeTruthy()
16 })
17β
18 test('Directly visiting the route with search param set', async ({
19 page,
20 }) => {
21 await page.goto('/search-params/default/?default=d2')
22 await page.waitForURL('/search-params/default?default=d2')
23β
24 await expect(page.getByTestId('search-default')).toContainText('d2')
25 await expect(page.getByTestId('context-hello')).toContainText('world')
26 expect(
27 page.url().endsWith('/search-params/default?default=d2'),
28 ).toBeTruthy()
29 })
30β
31 test('Directly visiting the route with special character search param set', async ({
32 page,
33 }) => {
34 await page.goto('/search-params/default/?default=πλνλ―Όκ΅')
35 await page.waitForURL(
36 '/search-params/default?default=%F0%9F%9A%80%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD',
37 )
38β
39 await expect(page.getByTestId('search-default')).toContainText('πλνλ―Όκ΅')
40 await expect(page.getByTestId('context-hello')).toContainText('world')
41β
42 expect(
43 page
44 .url()
45 .endsWith(
46 '/search-params/default?default=%F0%9F%9A%80%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD',
47 ),
48 ).toBeTruthy()
49 })
50β
51 test('Directly visiting the route with encoded character search param set', async ({
52 page,
53 }) => {
54 await page.goto(
55 '/search-params/default/?default=%25EB%258C%2580%25ED%2595%259C%25EB%25AF%25BC%25EA%25B5%25AD',
56 )
57 await page.waitForURL(
58 '/search-params/default?default=%25EB%258C%2580%25ED%2595%259C%25EB%25AF%25BC%25EA%25B5%25AD',
59 )
60β
61 await expect(page.getByTestId('search-default')).toContainText(
62 '%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD',
63 )
64 await expect(page.getByTestId('context-hello')).toContainText('world')
65β
66 expect(
67 page
68 .url()
69 .endsWith(
70 '/search-params/default?default=%25EB%258C%2580%25ED%2595%259C%25EB%25AF%25BC%25EA%25B5%25AD',
71 ),
72 ).toBeTruthy()
73 })
74β
75 test('navigating to the route without search param set', async ({ page }) => {
76 await page.goto('/search-params/')
77 await page.getByTestId('link-to-default-without-search').click()
78 await page.waitForURL('/search-params/default?default=d1')
79β
80 await expect(page.getByTestId('search-default')).toContainText('d1')
81 await expect(page.getByTestId('context-hello')).toContainText('world')
82 expect(
83 page.url().endsWith('/search-params/default?default=d1'),
84 ).toBeTruthy()
85 })
86β
87 test('navigating to the route with search param set', async ({ page }) => {
88 await page.goto('/search-params/')
89 await page.getByTestId('link-to-default-with-search').click()
90 await page.waitForURL('/search-params/default?default=d2')
91β
92 await expect(page.getByTestId('search-default')).toContainText('d2')
93 await expect(page.getByTestId('context-hello')).toContainText('world')
94 expect(
95 page.url().endsWith('/search-params/default?default=d2'),
96 ).toBeTruthy()
97 })
98β
99 test('navigating to the route with special character search param set', async ({
100 page,
101 }) => {
102 await page.goto('/search-params/')
103 await page
104 .getByTestId('link-to-default-with-search-special-characters')
105 .click()
106 await page.waitForURL(
107 '/search-params/default?default=%F0%9F%9A%80%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD',
108 )
109β
110 await expect(page.getByTestId('search-default')).toContainText('πλνλ―Όκ΅')
111 await expect(page.getByTestId('context-hello')).toContainText('world')
112 expect(
113 page
114 .url()
115 .endsWith(
116 '/search-params/default?default=%F0%9F%9A%80%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD',
117 ),
118 ).toBeTruthy()
119 })
120β
121 test('navigating to the route with encoded character search param set', async ({
122 page,
123 }) => {
124 await page.goto('/search-params/')
125 await page
126 .getByTestId('link-to-default-with-search-encoded-characters')
127 .click()
128 await page.waitForURL(
129 '/search-params/default?default=%25EB%258C%2580%25ED%2595%259C%25EB%25AF%25BC%25EA%25B5%25AD',
130 )
131β
132 await expect(page.getByTestId('search-default')).toContainText(
133 '%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD',
134 )
135 await expect(page.getByTestId('context-hello')).toContainText('world')
136 expect(
137 page
138 .url()
139 .endsWith(
140 '/search-params/default?default=%25EB%258C%2580%25ED%2595%259C%25EB%25AF%25BC%25EA%25B5%25AD',
141 ),
142 ).toBeTruthy()
143 })
144})