Skip to content

Commit

Permalink
test: update test setup for stable after() (#2722)
Browse files Browse the repository at this point in the history
* test: update test setup for stable after()

* fix: don't skip canaries buld
  • Loading branch information
pieh authored Dec 11, 2024
1 parent 0a6cc37 commit 6b56128
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
9 changes: 7 additions & 2 deletions tests/e2e/after.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
import { test } from '../utils/playwright-helpers.js'

test('next/after callback is executed and finishes', async ({ page, after }) => {
test.skip(!nextVersionSatisfies('>=15.0.0'), 'This test is only for Next.js 15+')
test.skip(
!nextVersionSatisfies('>=15.1.0'),
'This test is only for Next.js >=15.1.0 that has stable after() support',
)

// trigger initial request to check page which might be stale and allow regenerating in background
await page.goto(`${after.url}/after/check`)
Expand All @@ -25,7 +28,9 @@ test('next/after callback is executed and finishes', async ({ page, after }) =>

expect(pageInfo2.timestamp, 'Check page should be cached').toBe(pageInfo1.timestamp)

await page.goto(`${after.url}/after/trigger`)
const response = await page.goto(`${after.url}/after/trigger`)

expect(response?.status(), 'Trigger should return 200').toBe(200)

// wait for next/after to trigger revalidation of check page
await new Promise((resolve) => setTimeout(resolve, 5000))
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/after/app/after/trigger/page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { revalidatePath } from 'next/cache'
import { unstable_after as after, connection } from 'next/server'
import { after, connection } from 'next/server'

export default async function Page() {
await connection()
Expand Down
3 changes: 0 additions & 3 deletions tests/fixtures/after/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ const nextConfig = {
eslint: {
ignoreDuringBuilds: true,
},
experimental: {
after: true,
},
}

module.exports = nextConfig
2 changes: 1 addition & 1 deletion tests/fixtures/after/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"test": {
"dependencies": {
"next": ">=15.0.0"
"next": ">=15.1.0"
}
}
}
2 changes: 1 addition & 1 deletion tests/utils/next-version-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export async function setNextVersionInFixture(
if (
operation === 'update' &&
versionConstraint &&
!satisfies(checkVersion, versionConstraint) &&
!satisfies(checkVersion, versionConstraint, { includePrerelease: true }) &&
version !== versionConstraint
) {
if (!silent) {
Expand Down

0 comments on commit 6b56128

Please sign in to comment.