Skip to content

Commit

Permalink
test: Move e2e tests into shared library (#807)
Browse files Browse the repository at this point in the history
  • Loading branch information
franky47 authored Dec 15, 2024
1 parent e4154a1 commit 54067b3
Show file tree
Hide file tree
Showing 198 changed files with 2,072 additions and 2,249 deletions.
22 changes: 6 additions & 16 deletions packages/e2e/next/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { defineConfig } from 'cypress'
import cypressTerminalReport from 'cypress-terminal-report/src/installLogsPrinter'
import { defineConfig } from 'e2e-shared/cypress.config'
import fs from 'node:fs'
import semver from 'semver'

Expand All @@ -9,20 +8,11 @@ const basePath =
const nextJsVersion = readNextJsVersion()

export default defineConfig({
e2e: {
baseUrl: `http://localhost:3001${basePath}`,
video: false,
fixturesFolder: false,
testIsolation: true,
setupNodeEvents(on) {
cypressTerminalReport(on)
},
retries: 2,
env: {
basePath,
supportsShallowRouting: supportsShallowRouting(nextJsVersion),
nextJsVersion
}
baseUrl: `http://localhost:3001${basePath}`,
env: {
basePath,
supportsShallowRouting: supportsShallowRouting(nextJsVersion),
nextJsVersion
}
})

Expand Down
35 changes: 0 additions & 35 deletions packages/e2e/next/cypress/e2e/hash-preservation.cy.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
it('Persists search params across navigation using a generated Link href', () => {
cy.visit('/app/persist-across-navigation/a')
cy.contains('#hydration-marker', 'hydrated').should('be.hidden')
cy.get('input[type=text]').type('foo')
cy.get('input[type=text]').type('foo', { delay: 0 })
cy.get('input[type=checkbox]').check()
cy.get('a').click()
cy.location('pathname').should(
Expand Down
25 changes: 25 additions & 0 deletions packages/e2e/next/cypress/e2e/shared/basic-io.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { testBasicIO } from 'e2e-shared/specs/basic-io.cy'

testBasicIO({
hook: 'useQueryState',
path: '/app/basic-io/useQueryState',
nextJsRouter: 'app'
})

testBasicIO({
hook: 'useQueryStates',
path: '/app/basic-io/useQueryStates',
nextJsRouter: 'app'
})

testBasicIO({
hook: 'useQueryState',
path: '/pages/basic-io/useQueryState',
nextJsRouter: 'pages'
})

testBasicIO({
hook: 'useQueryStates',
path: '/pages/basic-io/useQueryStates',
nextJsRouter: 'pages'
})
25 changes: 25 additions & 0 deletions packages/e2e/next/cypress/e2e/shared/hash-preservation.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { testHashPreservation } from 'e2e-shared/specs/hash-preservation.cy'

testHashPreservation({
path: '/app/hash-preservation',
nextJsRouter: 'app',
description: 'standard route'
})

testHashPreservation({
path: '/app/hash-preservation/dynamic/route',
nextJsRouter: 'app',
description: 'dynamic route'
})

testHashPreservation({
path: '/pages/hash-preservation',
nextJsRouter: 'pages',
description: 'standard route'
})

testHashPreservation({
path: '/pages/hash-preservation/dynamic/route',
nextJsRouter: 'pages',
description: 'dynamic route'
})
25 changes: 25 additions & 0 deletions packages/e2e/next/cypress/e2e/shared/linking.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { testLinking } from 'e2e-shared/specs/linking.cy'

testLinking({
hook: 'useQueryState',
path: '/app/linking/useQueryState',
nextJsRouter: 'app'
})

testLinking({
hook: 'useQueryStates',
path: '/app/linking/useQueryStates',
nextJsRouter: 'app'
})

testLinking({
hook: 'useQueryState',
path: '/pages/linking/useQueryState',
nextJsRouter: 'pages'
})

testLinking({
hook: 'useQueryStates',
path: '/pages/linking/useQueryStates',
nextJsRouter: 'pages'
})
59 changes: 59 additions & 0 deletions packages/e2e/next/cypress/e2e/shared/push.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { testPush } from 'e2e-shared/specs/push.cy'

testPush({
path: '/app/push/useQueryState',
hook: 'useQueryState',
nextJsRouter: 'app',
description: 'standard route'
})

testPush({
path: '/app/push/useQueryStates',
hook: 'useQueryStates',
nextJsRouter: 'app',
description: 'standard route'
})

testPush({
path: '/pages/push/useQueryState',
hook: 'useQueryState',
nextJsRouter: 'pages',
description: 'standard route'
})

testPush({
path: '/pages/push/useQueryStates',
hook: 'useQueryStates',
nextJsRouter: 'pages',
description: 'standard route'
})

// --

testPush({
path: '/app/push/useQueryState/dynamic/route',
hook: 'useQueryState',
nextJsRouter: 'app',
description: 'dynamic route'
})

testPush({
path: '/app/push/useQueryStates/dynamic/route',
hook: 'useQueryStates',
nextJsRouter: 'app',
description: 'dynamic route'
})

testPush({
path: '/pages/push/useQueryState/dynamic/route',
hook: 'useQueryState',
nextJsRouter: 'pages',
description: 'dynamic route'
})

testPush({
path: '/pages/push/useQueryStates/dynamic/route',
hook: 'useQueryStates',
nextJsRouter: 'pages',
description: 'dynamic route'
})
25 changes: 25 additions & 0 deletions packages/e2e/next/cypress/e2e/shared/routing.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { testRouting } from 'e2e-shared/specs/routing.cy'

testRouting({
path: '/app/routing/useQueryState',
hook: 'useQueryState',
nextJsRouter: 'app'
})

testRouting({
path: '/app/routing/useQueryStates',
hook: 'useQueryStates',
nextJsRouter: 'app'
})

testRouting({
path: '/pages/routing/useQueryState',
hook: 'useQueryState',
nextJsRouter: 'pages'
})

testRouting({
path: '/pages/routing/useQueryStates',
hook: 'useQueryStates',
nextJsRouter: 'pages'
})
4 changes: 1 addition & 3 deletions packages/e2e/next/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import setup from 'cypress-terminal-report/src/installLogsCollector'

setup()
import 'e2e-shared/cypress/support/e2e'
1 change: 1 addition & 0 deletions packages/e2e/next/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const config = {
...(process.env.REACT_COMPILER === 'true' ? { reactCompiler: true } : {}),
serverSourceMaps: true
},
transpilePackages: ['e2e-shared'],
rewrites: async () => [
{
source: '/app/rewrites/source',
Expand Down
3 changes: 2 additions & 1 deletion packages/e2e/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
"babel-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
"cypress": "^13.15.2",
"cypress-terminal-report": "^7.0.4",
"semver": "^7.6.3",
"e2e-shared": "workspace:*",
"start-server-and-test": "^2.0.8",
"semver": "^7.6.3",
"typescript": "^5.6.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { UseQueryStateBasicIO } from 'e2e-shared/specs/basic-io'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<UseQueryStateBasicIO />
</Suspense>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { UseQueryStatesBasicIO } from 'e2e-shared/specs/basic-io'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<UseQueryStatesBasicIO />
</Suspense>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { HashPreservation } from 'e2e-shared/specs/hash-preservation'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<HashPreservation />
</Suspense>
)
}
10 changes: 10 additions & 0 deletions packages/e2e/next/src/app/app/(shared)/hash-preservation/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { HashPreservation } from 'e2e-shared/specs/hash-preservation'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<HashPreservation />
</Suspense>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { LinkingUseQueryState } from 'e2e-shared/specs/linking'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<LinkingUseQueryState path="/app/linking/useQueryState" />
</Suspense>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { LinkingUseQueryState } from 'e2e-shared/specs/linking'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<LinkingUseQueryState path="/app/linking/useQueryState" />
</Suspense>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { LinkingUseQueryStates } from 'e2e-shared/specs/linking'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<LinkingUseQueryStates path="/app/linking/useQueryStates" />
</Suspense>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { LinkingUseQueryStates } from 'e2e-shared/specs/linking'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<LinkingUseQueryStates path="/app/linking/useQueryStates" />
</Suspense>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { PushUseQueryState } from 'e2e-shared/specs/push'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<PushUseQueryState />
</Suspense>
)
}
10 changes: 10 additions & 0 deletions packages/e2e/next/src/app/app/(shared)/push/useQueryState/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { PushUseQueryState } from 'e2e-shared/specs/push'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<PushUseQueryState />
</Suspense>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { PushUseQueryStates } from 'e2e-shared/specs/push'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<PushUseQueryStates />
</Suspense>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { PushUseQueryStates } from 'e2e-shared/specs/push'
import { Suspense } from 'react'

export default function Page() {
return (
<Suspense>
<PushUseQueryStates />
</Suspense>
)
}
Loading

0 comments on commit 54067b3

Please sign in to comment.