Skip to content

Commit

Permalink
test: Remove support for unstable shallow routing
Browse files Browse the repository at this point in the history
Next.js versions between 14.0.2 and 14.1.0 contain bugs on
shallow routing (or other routing code) that makes `nuqs`
hard to maintain for these versions.
  • Loading branch information
franky47 committed Jun 26, 2024
1 parent d748e60 commit b52b197
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 48 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
# Watch out! When changing the job name,
# update the required checks in GitHub
# branch protection settings for `next`.
name: CI (${{ matrix.next-version }}${{ matrix.base-path && ' basePath' || ''}}${{ matrix.window-history-support && ' WHS' || ''}})
name: CI (${{ matrix.next-version }}${{ matrix.base-path && ' basePath' || ''}})
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -22,7 +22,6 @@ jobs:
# update the required checks in GitHub
# branch protection settings for `next`.
base-path: [false, '/base']
window-history-support: [false]
next-version:
- '13.4' # App router in GA
- '13.5'
Expand All @@ -32,10 +31,6 @@ jobs:
# which creates other problems under other versions of Next.js
- '14.0.4'
- latest # Current latest is 14.1.0
include:
# 14.0.4 doesn't require the WHS flag, but supports it
- next-version: '14.0.4'
window-history-support: true

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
Expand All @@ -52,7 +47,6 @@ jobs:
run: pnpm run test
env:
BASE_PATH: ${{ matrix.base-path && matrix.base-path || '/' }}
WINDOW_HISTORY_SUPPORT: ${{ matrix.window-history-support }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
E2E_NO_CACHE_ON_RERUN: ${{ github.run_attempt }}
Expand All @@ -61,13 +55,13 @@ jobs:
if: failure()
with:
path: packages/e2e/cypress/screenshots
name: ci-${{ matrix.next-version }}${{ matrix.base-path && '-basePath' || ''}}${{ matrix.window-history-support && '-whs' || ''}}
name: ci-${{ matrix.next-version }}${{ matrix.base-path && '-basePath' || ''}}
- uses: 47ng/actions-slack-notify@main
name: Notify on Slack
if: always()
with:
status: ${{ job.status }}
jobName: next@${{ matrix.next-version }}${{ matrix.base-path && ' basePath' || ''}}${{ matrix.window-history-support && ' WHS' || ''}}
jobName: next@${{ matrix.next-version }}${{ matrix.base-path && ' basePath' || ''}}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

Expand Down
14 changes: 0 additions & 14 deletions packages/e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ const basePath =

const nextJsVersion = readNextJsVersion()

const windowHistorySupport = supportsWHS(nextJsVersion)
? process.env.WINDOW_HISTORY_SUPPORT === 'true'
? 'true'
: 'false'
: 'undefined'

export default defineConfig({
e2e: {
baseUrl: `http://localhost:3001${basePath}`,
Expand All @@ -23,7 +17,6 @@ export default defineConfig({
retries: 2,
env: {
basePath,
windowHistorySupport,
supportsShallowRouting: supportsShallowRouting(nextJsVersion),
nextJsVersion
}
Expand All @@ -36,13 +29,6 @@ function readNextJsVersion() {
return pkg.dependencies.next.replace('^', '')
}

function supportsWHS(nextVersion: string) {
return (
semver.gte(nextVersion, '14.0.3-canary.6') &&
semver.lt(nextVersion, '14.0.5-canary.54')
)
}

function supportsShallowRouting(nextVersion: string) {
return semver.gte(nextVersion, '14.1.0')
}
5 changes: 1 addition & 4 deletions packages/e2e/cypress/e2e/internals.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ describe('internals', () => {
it('works in app router', () => {
cy.visit('/app/internals')
cy.contains('#hydration-marker', 'hydrated').should('be.hidden')
cy.get('#windowHistorySupport').should(
'have.text',
Cypress.env('windowHistorySupport')
)
cy.get('#nextJsVersion').should('have.text', Cypress.env('nextJsVersion'))
})
})
1 change: 0 additions & 1 deletion packages/e2e/cypress/e2e/repro-498.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference types="cypress" />

if (
Cypress.env('windowHistorySupport') !== 'true' &&
['14.1.0', '14.1.1'].includes(Cypress.env('nextJsVersion')) === false // See issue #498
) {
it('Reproduction for issue #498', () => {
Expand Down
19 changes: 3 additions & 16 deletions packages/e2e/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
const experimental =
process.env.WINDOW_HISTORY_SUPPORT === 'true'
? {
windowHistorySupport: true,
clientRouterFilter: false
}
: {
clientRouterFilter: false
}

const basePath =
process.env.BASE_PATH === '/' ? undefined : process.env.BASE_PATH

/** @type {import('next').NextConfig } */
const config = {
basePath,
experimental,
experimental: {
clientRouterFilter: false
},
rewrites: async () => [
{
source: '/app/rewrites/source',
Expand All @@ -28,9 +20,4 @@ const config = {
]
}

console.info(`Next.js config:
basePath: ${basePath}
windowHistorySupport: ${experimental?.windowHistorySupport ?? false}
`)

export default config
19 changes: 16 additions & 3 deletions packages/e2e/src/app/app/internals/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
'use client'

import React, { Suspense } from 'react'

export default function Page() {
return (
<p id="windowHistorySupport">
{String(process.env.__NEXT_WINDOW_HISTORY_SUPPORT)}
</p>
<Suspense>
<Client />
</Suspense>
)
}

function Client() {
const [nextJsVersion, setNextJsVersion] = React.useState<string | null>(null)
React.useEffect(() => {
// @ts-expect-error
setNextJsVersion(window.next?.version)
}, [])
return <p id="nextJsVersion">{nextJsVersion}</p>
}
2 changes: 1 addition & 1 deletion packages/nuqs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"prepack": "./scripts/prepack.sh"
},
"peerDependencies": {
"next": ">=13.4 <14.0.2 || ^14.0.4",
"next": ">=13.4 <14.0.2 || >=14.1.1",
"react": "^18.2.0"
},
"dependencies": {
Expand Down

0 comments on commit b52b197

Please sign in to comment.