From 6b56128b90ce9d7d8bc7a6a125fb755f6fe160ac Mon Sep 17 00:00:00 2001
From: Michal Piechowiak <misiek.piechowiak@gmail.com>
Date: Wed, 11 Dec 2024 14:57:15 +0100
Subject: [PATCH] test: update test setup for stable after() (#2722)

* test: update test setup for stable after()

* fix: don't skip canaries buld
---
 tests/e2e/after.test.ts                        | 9 +++++++--
 tests/fixtures/after/app/after/trigger/page.js | 2 +-
 tests/fixtures/after/next.config.js            | 3 ---
 tests/fixtures/after/package.json              | 2 +-
 tests/utils/next-version-helpers.mjs           | 2 +-
 5 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/tests/e2e/after.test.ts b/tests/e2e/after.test.ts
index 0ab9fae3a6..8921f7b2ba 100644
--- a/tests/e2e/after.test.ts
+++ b/tests/e2e/after.test.ts
@@ -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`)
@@ -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))
diff --git a/tests/fixtures/after/app/after/trigger/page.js b/tests/fixtures/after/app/after/trigger/page.js
index 62f02d8148..6edd89bd53 100644
--- a/tests/fixtures/after/app/after/trigger/page.js
+++ b/tests/fixtures/after/app/after/trigger/page.js
@@ -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()
diff --git a/tests/fixtures/after/next.config.js b/tests/fixtures/after/next.config.js
index d3a1abc892..9d94510be1 100644
--- a/tests/fixtures/after/next.config.js
+++ b/tests/fixtures/after/next.config.js
@@ -4,9 +4,6 @@ const nextConfig = {
   eslint: {
     ignoreDuringBuilds: true,
   },
-  experimental: {
-    after: true,
-  },
 }
 
 module.exports = nextConfig
diff --git a/tests/fixtures/after/package.json b/tests/fixtures/after/package.json
index ebd15f679b..62e31aa11f 100644
--- a/tests/fixtures/after/package.json
+++ b/tests/fixtures/after/package.json
@@ -14,7 +14,7 @@
   },
   "test": {
     "dependencies": {
-      "next": ">=15.0.0"
+      "next": ">=15.1.0"
     }
   }
 }
diff --git a/tests/utils/next-version-helpers.mjs b/tests/utils/next-version-helpers.mjs
index 52150e4904..69f243cfc3 100644
--- a/tests/utils/next-version-helpers.mjs
+++ b/tests/utils/next-version-helpers.mjs
@@ -85,7 +85,7 @@ export async function setNextVersionInFixture(
         if (
           operation === 'update' &&
           versionConstraint &&
-          !satisfies(checkVersion, versionConstraint) &&
+          !satisfies(checkVersion, versionConstraint, { includePrerelease: true }) &&
           version !== versionConstraint
         ) {
           if (!silent) {