Skip to content

Commit 54067b3

Browse files
authored
test: Move e2e tests into shared library (#807)
1 parent e4154a1 commit 54067b3

File tree

198 files changed

+2072
-2249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+2072
-2249
lines changed

packages/e2e/next/cypress.config.ts

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { defineConfig } from 'cypress'
2-
import cypressTerminalReport from 'cypress-terminal-report/src/installLogsPrinter'
1+
import { defineConfig } from 'e2e-shared/cypress.config'
32
import fs from 'node:fs'
43
import semver from 'semver'
54

@@ -9,20 +8,11 @@ const basePath =
98
const nextJsVersion = readNextJsVersion()
109

1110
export default defineConfig({
12-
e2e: {
13-
baseUrl: `http://localhost:3001${basePath}`,
14-
video: false,
15-
fixturesFolder: false,
16-
testIsolation: true,
17-
setupNodeEvents(on) {
18-
cypressTerminalReport(on)
19-
},
20-
retries: 2,
21-
env: {
22-
basePath,
23-
supportsShallowRouting: supportsShallowRouting(nextJsVersion),
24-
nextJsVersion
25-
}
11+
baseUrl: `http://localhost:3001${basePath}`,
12+
env: {
13+
basePath,
14+
supportsShallowRouting: supportsShallowRouting(nextJsVersion),
15+
nextJsVersion
2616
}
2717
})
2818

packages/e2e/next/cypress/e2e/hash-preservation.cy.js

-35
This file was deleted.

packages/e2e/next/cypress/e2e/persist-across-navigation.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
it('Persists search params across navigation using a generated Link href', () => {
44
cy.visit('/app/persist-across-navigation/a')
55
cy.contains('#hydration-marker', 'hydrated').should('be.hidden')
6-
cy.get('input[type=text]').type('foo')
6+
cy.get('input[type=text]').type('foo', { delay: 0 })
77
cy.get('input[type=checkbox]').check()
88
cy.get('a').click()
99
cy.location('pathname').should(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { testBasicIO } from 'e2e-shared/specs/basic-io.cy'
2+
3+
testBasicIO({
4+
hook: 'useQueryState',
5+
path: '/app/basic-io/useQueryState',
6+
nextJsRouter: 'app'
7+
})
8+
9+
testBasicIO({
10+
hook: 'useQueryStates',
11+
path: '/app/basic-io/useQueryStates',
12+
nextJsRouter: 'app'
13+
})
14+
15+
testBasicIO({
16+
hook: 'useQueryState',
17+
path: '/pages/basic-io/useQueryState',
18+
nextJsRouter: 'pages'
19+
})
20+
21+
testBasicIO({
22+
hook: 'useQueryStates',
23+
path: '/pages/basic-io/useQueryStates',
24+
nextJsRouter: 'pages'
25+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { testHashPreservation } from 'e2e-shared/specs/hash-preservation.cy'
2+
3+
testHashPreservation({
4+
path: '/app/hash-preservation',
5+
nextJsRouter: 'app',
6+
description: 'standard route'
7+
})
8+
9+
testHashPreservation({
10+
path: '/app/hash-preservation/dynamic/route',
11+
nextJsRouter: 'app',
12+
description: 'dynamic route'
13+
})
14+
15+
testHashPreservation({
16+
path: '/pages/hash-preservation',
17+
nextJsRouter: 'pages',
18+
description: 'standard route'
19+
})
20+
21+
testHashPreservation({
22+
path: '/pages/hash-preservation/dynamic/route',
23+
nextJsRouter: 'pages',
24+
description: 'dynamic route'
25+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { testLinking } from 'e2e-shared/specs/linking.cy'
2+
3+
testLinking({
4+
hook: 'useQueryState',
5+
path: '/app/linking/useQueryState',
6+
nextJsRouter: 'app'
7+
})
8+
9+
testLinking({
10+
hook: 'useQueryStates',
11+
path: '/app/linking/useQueryStates',
12+
nextJsRouter: 'app'
13+
})
14+
15+
testLinking({
16+
hook: 'useQueryState',
17+
path: '/pages/linking/useQueryState',
18+
nextJsRouter: 'pages'
19+
})
20+
21+
testLinking({
22+
hook: 'useQueryStates',
23+
path: '/pages/linking/useQueryStates',
24+
nextJsRouter: 'pages'
25+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { testPush } from 'e2e-shared/specs/push.cy'
2+
3+
testPush({
4+
path: '/app/push/useQueryState',
5+
hook: 'useQueryState',
6+
nextJsRouter: 'app',
7+
description: 'standard route'
8+
})
9+
10+
testPush({
11+
path: '/app/push/useQueryStates',
12+
hook: 'useQueryStates',
13+
nextJsRouter: 'app',
14+
description: 'standard route'
15+
})
16+
17+
testPush({
18+
path: '/pages/push/useQueryState',
19+
hook: 'useQueryState',
20+
nextJsRouter: 'pages',
21+
description: 'standard route'
22+
})
23+
24+
testPush({
25+
path: '/pages/push/useQueryStates',
26+
hook: 'useQueryStates',
27+
nextJsRouter: 'pages',
28+
description: 'standard route'
29+
})
30+
31+
// --
32+
33+
testPush({
34+
path: '/app/push/useQueryState/dynamic/route',
35+
hook: 'useQueryState',
36+
nextJsRouter: 'app',
37+
description: 'dynamic route'
38+
})
39+
40+
testPush({
41+
path: '/app/push/useQueryStates/dynamic/route',
42+
hook: 'useQueryStates',
43+
nextJsRouter: 'app',
44+
description: 'dynamic route'
45+
})
46+
47+
testPush({
48+
path: '/pages/push/useQueryState/dynamic/route',
49+
hook: 'useQueryState',
50+
nextJsRouter: 'pages',
51+
description: 'dynamic route'
52+
})
53+
54+
testPush({
55+
path: '/pages/push/useQueryStates/dynamic/route',
56+
hook: 'useQueryStates',
57+
nextJsRouter: 'pages',
58+
description: 'dynamic route'
59+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { testRouting } from 'e2e-shared/specs/routing.cy'
2+
3+
testRouting({
4+
path: '/app/routing/useQueryState',
5+
hook: 'useQueryState',
6+
nextJsRouter: 'app'
7+
})
8+
9+
testRouting({
10+
path: '/app/routing/useQueryStates',
11+
hook: 'useQueryStates',
12+
nextJsRouter: 'app'
13+
})
14+
15+
testRouting({
16+
path: '/pages/routing/useQueryState',
17+
hook: 'useQueryState',
18+
nextJsRouter: 'pages'
19+
})
20+
21+
testRouting({
22+
path: '/pages/routing/useQueryStates',
23+
hook: 'useQueryStates',
24+
nextJsRouter: 'pages'
25+
})
+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import setup from 'cypress-terminal-report/src/installLogsCollector'
2-
3-
setup()
1+
import 'e2e-shared/cypress/support/e2e'

packages/e2e/next/next.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const config = {
1010
...(process.env.REACT_COMPILER === 'true' ? { reactCompiler: true } : {}),
1111
serverSourceMaps: true
1212
},
13+
transpilePackages: ['e2e-shared'],
1314
rewrites: async () => [
1415
{
1516
source: '/app/rewrites/source',

packages/e2e/next/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434
"babel-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
3535
"cypress": "^13.15.2",
3636
"cypress-terminal-report": "^7.0.4",
37-
"semver": "^7.6.3",
37+
"e2e-shared": "workspace:*",
3838
"start-server-and-test": "^2.0.8",
39+
"semver": "^7.6.3",
3940
"typescript": "^5.6.3"
4041
}
4142
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { UseQueryStateBasicIO } from 'e2e-shared/specs/basic-io'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<UseQueryStateBasicIO />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { UseQueryStatesBasicIO } from 'e2e-shared/specs/basic-io'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<UseQueryStatesBasicIO />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { HashPreservation } from 'e2e-shared/specs/hash-preservation'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<HashPreservation />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { HashPreservation } from 'e2e-shared/specs/hash-preservation'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<HashPreservation />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { LinkingUseQueryState } from 'e2e-shared/specs/linking'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<LinkingUseQueryState path="/app/linking/useQueryState" />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { LinkingUseQueryState } from 'e2e-shared/specs/linking'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<LinkingUseQueryState path="/app/linking/useQueryState" />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { LinkingUseQueryStates } from 'e2e-shared/specs/linking'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<LinkingUseQueryStates path="/app/linking/useQueryStates" />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { LinkingUseQueryStates } from 'e2e-shared/specs/linking'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<LinkingUseQueryStates path="/app/linking/useQueryStates" />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { PushUseQueryState } from 'e2e-shared/specs/push'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<PushUseQueryState />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { PushUseQueryState } from 'e2e-shared/specs/push'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<PushUseQueryState />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { PushUseQueryStates } from 'e2e-shared/specs/push'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<PushUseQueryStates />
8+
</Suspense>
9+
)
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { PushUseQueryStates } from 'e2e-shared/specs/push'
2+
import { Suspense } from 'react'
3+
4+
export default function Page() {
5+
return (
6+
<Suspense>
7+
<PushUseQueryStates />
8+
</Suspense>
9+
)
10+
}

0 commit comments

Comments
 (0)