Unverified Commit bd932b38 authored by Jamiboy Mohammad's avatar Jamiboy Mohammad Committed by GitHub

test: enable basePath redirect deployment coverage (#99401)

## Summary

Re-enable `gssp-redirect-base-path` deployment coverage with Corepack so
installation uses the fixture's declared pnpm version.

A redirect with `basePath: false` lands at `/404`, outside the
application's `/docs` base path. Vercel may serve its own 404 page
there. Check the destination URL and the browser's actual HTTP 404
navigation response in every mode, while retaining the custom-page text
assertion for self-hosted modes. This follows the existing base-path
error-page tests; the other redirect assertions remain unchanged.

Follow-up to #99192.

## Verification

- All 22 tests passed locally in production Turbopack mode, both
normally and with `__NEXT_CACHE_COMPONENTS=true` and
`__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS=true`.
- Normal and cache-components deployment manifests select the suite
without excluding individual cases. Deployment execution awaits CI.
- The repository TypeScript check is blocked by the worktree's shared
`node_modules` resolving an older Next.js build in another checkout
(missing upgrade and static-config exports); it reported no errors in
the changed test.

<!-- NEXT_JS_LLM -->
parent 90305124
......@@ -4,15 +4,14 @@ import { retry } from 'next-test-utils'
const basePath = '/docs'
describe('GS(S)P Redirect with basePath', () => {
const { next, skipped } = nextTestSetup({
const { next, isNextDeploy } = nextTestSetup({
files: __dirname,
dependencies: {
react: '19.3.0-canary-da9325b5-20260417',
'react-dom': '19.3.0-canary-da9325b5-20260417',
},
skipDeployment: true,
env: { ENABLE_EXPERIMENTAL_COREPACK: '1' },
})
if (skipped) return
it('should apply temporary redirect when visited directly for GSSP page', async () => {
const res = await next.fetch(`${basePath}/gssp-blog/redirect-1`, {
......@@ -38,14 +37,26 @@ describe('GS(S)P Redirect with basePath', () => {
expect(parsedUrl.pathname).toBe(`/404`)
const browser = await next.browser(`${basePath}`)
let notFoundStatus: number | undefined
browser.on('response', (response) => {
if (
response.request().isNavigationRequest() &&
new URL(response.url()).pathname === '/404'
) {
notFoundStatus = response.status()
}
})
await browser.eval(`next.router.push('/gssp-blog/redirect-1-no-basepath-')`)
await retry(async () => {
const html = await browser.eval('document.documentElement.innerHTML')
expect(html).toMatch(/oops not found/)
expect(new URL(await browser.url()).pathname).toBe('/404')
expect(notFoundStatus).toBe(404)
// Outside basePath, deployments may render the platform's 404 page.
if (!isNextDeploy) {
const html = await browser.eval('document.documentElement.innerHTML')
expect(html).toMatch(/oops not found/)
}
})
const parsedUrl2 = new URL(await browser.eval('window.location.href'))
expect(parsedUrl2.pathname).toBe('/404')
})
it('should apply permanent redirect when visited directly for GSSP page', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment