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