Repository: vercel/next.js
Pull request: Upgrade @playwright/test and cleanup internal APIs

### What

Relanding #77659 

Changed files:
filename: packages/next/package.json
patch: @@ -108,7 +108,7 @@
   },
   "peerDependencies": {
     "@opentelemetry/api": "^1.1.0",
-    "@playwright/test": "^1.41.2",
+    "@playwright/test": "^1.51.1",
     "babel-plugin-react-compiler": "*",
     "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",
     "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",
@@ -168,7 +168,7 @@
     "@next/react-refresh-utils": "15.4.0-canary.79",
     "@next/swc": "15.4.0-canary.79",
     "@opentelemetry/api": "1.6.0",
-    "@playwright/test": "1.41.2",
+    "@playwright/test": "1.51.1",
     "@rspack/core": "1.3.12",
     "@storybook/addon-a11y": "8.6.0",
     "@storybook/addon-essentials": "8.6.0",

filename: packages/next/src/experimental/testmode/playwright/step.ts
patch: @@ -9,33 +9,13 @@ export interface StepProps {
   params?: Record<string, string | number | boolean | null | undefined>
 }
 
-// Access the internal Playwright API until it's exposed publicly.
-// See https://github.com/microsoft/playwright/issues/27059.
-interface TestInfoWithRunAsStep extends TestInfo {
-  _runAsStep: <T>(
-    stepInfo: StepProps,
-    handler: (result: { complete: Complete }) => Promise<T>
-  ) => Promise<T>
-}
-
 type Complete = (result: { error?: any }) => void
 
-function isWithRunAsStep(
-  testInfo: TestInfo
-): testInfo is TestInfoWithRunAsStep {
-  return '_runAsStep' in testInfo
-}
-
 export async function step<T>(
-  testInfo: TestInfo,
+  _testInfo: TestInfo,
   props: StepProps,
   handler: (complete: Complete) => Promise<Awaited<T>>
 ): Promise<Awaited<T>> {
-  if (isWithRunAsStep(testInfo)) {
-    return testInfo._runAsStep(props, ({ complete }) => handler(complete))
-  }
-
-  // Fallback to the `test.step()`.
   let result: Awaited<T>
   let reportedError: any
   try {

filename: pnpm-lock.yaml
patch: @@ -1040,8 +1040,8 @@ importers:
         specifier: 1.6.0
         version: 1.6.0
       '@playwright/test':
-        specifier: 1.41.2
-        version: 1.41.2
+        specifier: 1.51.1
+        version: 1.51.1
       '@rspack/core':
         specifier: 1.3.12
         version: 1.3.12(@swc/helpers@0.5.15)
@@ -1218,7 +1218,7 @@ importers:
         version: 3.0.0
       axe-playwright:
         specifier: 2.0.3
-        version: 2.0.3(playwright@1.48.0)
+        version: 2.0.3(playwright@1.51.1)
       babel-plugin-react-compiler:
         specifier: 19.0.0-beta-e552027-20250112
         version: 19.0.0-beta-e552027-20250112
@@ -4633,10 +4633,9 @@ packages:
     resolution: {integrity: sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==}
     engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
 
-  '@playwright/test@1.41.2':
-    resolution: {integrity: sha512-qQB9h7KbibJzrDpkXkYvsmiDJK14FULCCZgEcoe2AvFAS64oCirWTwzTlAYEbKaRxWs5TFesE1Na6izMv3HfGg==}
-    engines: {node: '>=16'}
-    deprecated: Please update to the latest version of Playwright to test up-to-date browsers.
+  '@playwright/test@1.51.1':
+    resolution: {integrity: sha512-nM+kEaTSAoVlXmMPH10017vn3FSiFqr/bh4fKg9vmAdMfd9SDqRZNvPSiAHADc/itWak+qPvMPZQOPwCBW7k7Q==}
+    engines: {node: '>=18'}
     hasBin: true
 
   '@polka/url@1.0.0-next.11':
@@ -12922,26 +12921,26 @@ packages:
     engines: {node: '>=18'}
     hasBin: true
 
-  playwright-core@1.41.2:
-    resolution: {integrity: sha512-VaTvwCA4Y8kxEe+kfm2+uUUw5Lubf38RxF7FpBxLPmGe5sdNkSg5e3ChEigaGrX7qdqT3pt2m/98LiyvU2x6CA==}
-    engines: {node: '>=16'}
-    hasBin: true
-
   playwright-core@1.48.0:
     resolution: {integrity: sha512-RBvzjM9rdpP7UUFrQzRwR8L/xR4HyC1QXMzGYTbf1vjw25/ya9NRAVnXi/0fvFopjebvyPzsmoK58xxeEOaVvA==}
     engines: {node: '>=18'}
     hasBin: true
 
-  playwright@1.41.2:
-    resolution: {integrity: sha512-v0bOa6H2GJChDL8pAeLa/LZC4feoAMbSQm1/jF/ySsWWoaNItvrMP7GEkvEEFyCTUYKMxjQKaTSg5up7nR6/8A==}
-    engines: {node: '>=16'}
+  playwright-core@1.51.1:
+    resolution: {integrity: sha512-/crRMj8+j/Nq5s8QcvegseuyeZPxpQCZb6HNk3Sos3BlZyAknRjoyJPFWkpNn8v0+P3WiwqFF8P+zQo4eqiNuw==}
+    engines: {node: '>=18'}
     hasBin: true
 
   playwright@1.48.0:
     resolution: {integrity: sha512-qPqFaMEHuY/ug8o0uteYJSRfMGFikhUysk8ZvAtfKmUK3kc/6oNl/y3EczF8OFGYIi/Ex2HspMfzYArk6+XQSA==}
     engines: {node: '>=18'}
     hasBin: true
 
+  playwright@1.51.1:
+    resolution: {integrity: sha512-kkx+MB2KQRkyxjYPc3a0wLZZoDczmppyGJIvQ43l+aZihkaVvmu/21kiyaHeHjiFxjxNNFnUncKmcGIyOojsaw==}
+    engines: {node: '>=18'}
+    hasBin: true
+
   pluralize@8.0.0:
     resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
     engines: {node: '>=4'}
@@ -13842,7 +13841,6 @@ packages:
     engines: {node: '>=0.6.0', teleport: '>=0.2.0'}
     deprecated: |-
       You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.
-
       (For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
 
   qs@6.11.0:
@@ -20329,9 +20327,9 @@ snapshots:
 
   '@pkgr/core@0.1.1': {}
 
-  '@playwright/test@1.41.2':
+  '@playwright/test@1.51.1':
     dependencies:
-      playwright: 1.41.2
+      playwright: 1.51.1
 
   '@polka/url@1.0.0-next.11': {}
 
@@ -22524,14 +22522,14 @@ snapshots:
       axe-core: 4.10.0
       mustache: 4.2.0
 
-  axe-playwright@2.0.3(playwright@1.48.0):
+  axe-playwright@2.0.3(playwright@1.51.1):
     dependencies:
       '@types/junit-report-builder': 3.0.2
       axe-core: 4.10.0
       axe-html-reporter: 2.2.11(axe-core@4.10.0)
       junit-report-builder: 5.1.1
       picocolors: 1.1.1
-      playwright: 1.48.0
+      playwright: 1.51.1
 
   axios@0.26.1:
     dependencies:
@@ -30961,19 +30959,19 @@ snapshots:
     dependencies:
       playwright-core: 1.48.0
 
-  playwright-core@1.41.2: {}
-
   playwright-core@1.48.0: {}
 
-  playwright@1.41.2:
+  playwright-core@1.51.1: {}
+
+  playwright@1.48.0:
     dependencies:
-      playwright-core: 1.41.2
+      playwright-core: 1.48.0
     optionalDependencies:
       fsevents: 2.3.2
 
-  playwright@1.48.0:
+  playwright@1.51.1:
     dependencies:
-      playwright-core: 1.48.0
+      playwright-core: 1.51.1
     optionalDependencies:
       fsevents: 2.3.2