Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

search-params.spec.ts

49 lines1.7 KB

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​
9 await expect(page.getByTestId('search-default')).toContainText('d1')
10 await expect(page.getByTestId('context-hello')).toContainText('world')
11 expect(
12 page.url().endsWith('/search-params/default?default=d1'),
13 ).toBeTruthy()
14 })
15​
16 test('Directly visiting the route with search param set', async ({
17 page,
18 }) => {
19 await page.goto('/search-params/default/?default=d2')
20​
21 await expect(page.getByTestId('search-default')).toContainText('d2')
22 await expect(page.getByTestId('context-hello')).toContainText('world')
23 expect(
24 page.url().endsWith('/search-params/default?default=d2'),
25 ).toBeTruthy()
26 })
27​
28 test('navigating to the route without search param set', async ({ page }) => {
29 await page.goto('/search-params/')
30 await page.getByTestId('link-to-default-without-search').click()
31​
32 await expect(page.getByTestId('search-default')).toContainText('d1')
33 await expect(page.getByTestId('context-hello')).toContainText('world')
34 expect(
35 page.url().endsWith('/search-params/default?default=d1'),
36 ).toBeTruthy()
37 })
38​
39 test('navigating to the route with search param set', async ({ page }) => {
40 await page.goto('/search-params/')
41 await page.getByTestId('link-to-default-with-search').click()
42​
43 await expect(page.getByTestId('search-default')).toContainText('d2')
44 await expect(page.getByTestId('context-hello')).toContainText('world')
45 expect(
46 page.url().endsWith('/search-params/default?default=d2'),
47 ).toBeTruthy()
48 })
49})