Skip to content

Commit 5bb1606

Browse files
committed
test: Add pretty URL encoding e2e test
1 parent 01d40ab commit 5bb1606

File tree

16 files changed

+82
-0
lines changed

16 files changed

+82
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { testPrettyUrls } from 'e2e-shared/specs/pretty-urls.cy'
2+
3+
testPrettyUrls({
4+
path: '/app/pretty-urls',
5+
nextJsRouter: 'app'
6+
})
7+
8+
testPrettyUrls({
9+
path: '/pages/pretty-urls',
10+
nextJsRouter: 'pages'
11+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { PrettyUrls } from 'e2e-shared/specs/pretty-urls'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<PrettyUrls />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { PrettyUrls } from 'e2e-shared/specs/pretty-urls'
2+
3+
export default PrettyUrls
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { testPrettyUrls } from 'e2e-shared/specs/pretty-urls.cy'
2+
3+
testPrettyUrls({
4+
path: '/pretty-urls'
5+
})

packages/e2e/react-router/v6/src/react-router.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const router = createBrowserRouter(
4646
<Route path="conditional-rendering/useQueryState" lazy={load(import('./routes/conditional-rendering.useQueryState'))} />
4747
<Route path="conditional-rendering/useQueryStates" lazy={load(import('./routes/conditional-rendering.useQueryStates'))} />
4848
<Route path="scroll" lazy={load(import('./routes/scroll'))} />
49+
<Route path="pretty-urls" lazy={load(import('./routes/pretty-urls'))} />
4950

5051
<Route path="render-count/:hook/:shallow/:history/:startTransition/no-loader" lazy={load(import('./routes/render-count.$hook.$shallow.$history.$startTransition.no-loader'))} />
5152
<Route path="render-count/:hook/:shallow/:history/:startTransition/sync-loader" lazy={load(import('./routes/render-count.$hook.$shallow.$history.$startTransition.sync-loader'))} />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { PrettyUrls } from 'e2e-shared/specs/pretty-urls'
2+
3+
export default PrettyUrls

packages/e2e/react-router/v7/app/routes.ts

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default [
2929
route('/conditional-rendering/useQueryState', './routes/conditional-rendering.useQueryState.tsx'),
3030
route('/conditional-rendering/useQueryStates', './routes/conditional-rendering.useQueryStates.tsx'),
3131
route('/scroll', './routes/scroll.tsx'),
32+
route('/pretty-urls', './routes/pretty-urls.tsx'),
3233

3334
route('/render-count/:hook/:shallow/:history/:startTransition/no-loader', './routes/render-count.$hook.$shallow.$history.$startTransition.no-loader.tsx'),
3435
route('/render-count/:hook/:shallow/:history/:startTransition/sync-loader', './routes/render-count.$hook.$shallow.$history.$startTransition.sync-loader.tsx'),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { PrettyUrls } from 'e2e-shared/specs/pretty-urls'
2+
3+
export default PrettyUrls
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { testPrettyUrls } from 'e2e-shared/specs/pretty-urls.cy'
2+
3+
testPrettyUrls({
4+
path: '/pretty-urls'
5+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { testPrettyUrls } from 'e2e-shared/specs/pretty-urls.cy'
2+
3+
testPrettyUrls({
4+
path: '/pretty-urls'
5+
})

packages/e2e/react/src/routes.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const routes: Record<string, React.LazyExoticComponent<() => JSX.Element>> = {
2424
'/conditional-rendering/useQueryState': lazy(() => import('./routes/conditional-rendering.useQueryState')),
2525
'/conditional-rendering/useQueryStates': lazy(() => import('./routes/conditional-rendering.useQueryStates')),
2626
'/scroll': lazy(() => import('./routes/scroll')),
27+
'/pretty-urls': lazy(() => import('./routes/pretty-urls')),
2728

2829
'/render-count/useQueryState/true/replace/false': lazy(() => import('./routes/render-count')),
2930
'/render-count/useQueryState/true/replace/true': lazy(() => import('./routes/render-count')),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { PrettyUrls } from 'e2e-shared/specs/pretty-urls'
2+
3+
export default PrettyUrls
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { PrettyUrls } from 'e2e-shared/specs/pretty-urls'
2+
3+
export default PrettyUrls
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { testPrettyUrls } from 'e2e-shared/specs/pretty-urls.cy'
2+
3+
testPrettyUrls({
4+
path: '/pretty-urls'
5+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { createTest } from '../create-test'
2+
3+
export const testPrettyUrls = createTest('Pretty URLs', ({ path }) => {
4+
it('should render unencoded characters', () => {
5+
cy.visit(path)
6+
cy.contains('#hydration-marker', 'hydrated').should('be.hidden')
7+
cy.get('button').click()
8+
cy.get('#state').should('have.text', '-._~!$()*,;=:@/?[]{}\\|^')
9+
})
10+
})
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use client'
2+
3+
import { useQueryState } from 'nuqs'
4+
5+
export function PrettyUrls() {
6+
const [state, setState] = useQueryState('test')
7+
return (
8+
<>
9+
<button onClick={() => setState('-._~!$()*,;=:@/?[]{}\\|^')}>Test</button>
10+
<pre id="state">{state}</pre>
11+
</>
12+
)
13+
}

0 commit comments

Comments
 (0)