Commit Graph

6 Commits

Author SHA1 Message Date
Jamiboy Mohammad 3dbf921905 test: enable verified runtime deploy tests (#98457)
## Summary

Enable the same 9 previously selected deployment-test scopes across 9
runtime test files, now in a stack rooted on canary. Remove 8
`skipDeployment` options and their obsolete skip guards. Enable only the
selected middleware cookie assertion; the neighboring query assertion
remains excluded. Other mode, bundler, middleware, and Cache Components
exclusions remain in place.

This preserves the selection with passing evidence from the previous
deployment runs. No additional candidate scopes are enabled; excluded
variants are not counted as deployment coverage.

The worker-react-refresh scope (ID 411) remains deployment-excluded
pending fixture dependency changes: React 19.3.0 conflicts with
@react-three/fiber 9.7.0’s React <19.3 peer range. Both deploy variants
fail during npm installation, before the assertion executes. It is
tracked as a fixable candidate, not a permanent local-only test.

## Verification

- All selected test registration names and assertion bodies match the
previous enabled revision, checked by AST comparison.
- Verified that the canary diff contains only the inventoried exclusions
and their obsolete skip plumbing; other exclusions are preserved.
- Formatting and lint passed; 77 gate infrastructure unit tests passed.
- Full local bootstrap was blocked by missing package-level dependencies
in the temporary worktree. Fresh deployment execution on these rewritten
commits remains to be verified in CI.

<details>
<summary>Preserved scope inventory (9)</summary>

- ID 350: `test/e2e/app-dir/app-edge-root-layout/index.test.ts` —
`describe('app-dir edge runtime root layout', () => {
  const { next, isNextStart } = nextTestSetup({
    files: __dirname,
  })

  it('should not emit metadata files into bad paths', async () => {
    await next.fetch('/favicon.ico')
// issue: If metadata files are not filter out properly with
image-loader,
    // an incorrect static/media folder will be generated

    // Check that the static folder is not generated
    const incorrectGeneratedStaticFolder = await next.hasFile('static')
    expect(incorrectGeneratedStaticFolder).toBe(false)
  })

  if (isNextStart) {
it('should mark static contain metadata routes as edge functions', async
() => {
      const middlewareManifest = await next.readFile(
        '.next/server/middleware-manifest.json'
      )
      expect(middlewareManifest).not.toContain('/favicon')
    })
  }
})`
- ID 353: `test/e2e/app-dir/binary/rsc-binary.test.ts` — `describe('RSC
binary serialization', () => {
  const { next } = nextTestSetup({
    files: __dirname,
    dependencies: {
      'server-only': 'latest',
    },
  })

  afterEach(async () => {
    await next.stop()
  })

it('should correctly encode/decode binaries and hydrate', async function
() {
    const browser = await next.browser('/')
    await check(async () => {
      const content = await browser.elementByCss('body').text()

      return content.includes('utf8 binary: hello') &&
        content.includes('arbitrary binary: 255,0,1,2,3') &&
        content.includes('hydrated: true')
        ? 'success'
        : 'fail'
    }, 'success')
  })
})`
- ID 355:
`test/e2e/app-dir/interception-middleware-rewrite/interception-middleware-rewrite.test.ts`
— `describe('interception-middleware-rewrite', () => {
  const { next } = nextTestSetup({
    files: __dirname,
  })

it('should support intercepting routes with a middleware rewrite', async
() => {
    const browser = await next.browser('/')

    await check(() => browser.elementByCss('#children').text(), 'root')

    await check(
      () =>
        browser
          .elementByCss('[href="/feed"]')
          .click()
          .elementByCss('#modal')
          .text(),
      'intercepted'
    )

    await check(
      () => browser.refresh().elementByCss('#children').text(),
      'not intercepted'
    )

    await check(() => browser.elementByCss('#modal').text(), 'default')
  })

it('should continue to work after using browser back button and
following another intercepting route', async () => {
    const browser = await next.browser('/')
    await check(() => browser.elementById('children').text(), 'root')

    await browser.elementByCss('[href="/photos/1"]').click()
    await check(
      () => browser.elementById('modal').text(),
      'Intercepted Photo ID: 1'
    )
    await browser.back()
    await browser.elementByCss('[href="/photos/2"]').click()
    await check(
      () => browser.elementById('modal').text(),
      'Intercepted Photo ID: 2'
    )
  })

it('should continue to show the intercepted page when revisiting it',
async () => {
    const browser = await next.browser('/')
    await check(() => browser.elementById('children').text(), 'root')

    await browser.elementByCss('[href="/photos/1"]').click()

    // we should be showing the modal and not the page
    await check(
      () => browser.elementById('modal').text(),
      'Intercepted Photo ID: 1'
    )

    await browser.refresh()

    // page should show after reloading the browser
    await check(
      () => browser.elementById('children').text(),
      'Page Photo ID: 1'
    )

    // modal should no longer be showing
    await check(() => browser.elementById('modal').text(), 'default')

    await browser.back()

    // revisit the same page that was intercepted
    await browser.elementByCss('[href="/photos/1"]').click()

    // ensure that we're still showing the modal and not the page
    await check(
      () => browser.elementById('modal').text(),
      'Intercepted Photo ID: 1'
    )

    // page content should not have changed
    await check(() => browser.elementById('children').text(), 'root')
  })
})`
- ID 360: `test/e2e/app-dir/middleware-matching/index.test.ts` —
`describe('app dir - middleware with custom matcher', () => {
  const { next } = nextTestSetup({
    files: __dirname,
  })

  it('should match /:id (without asterisk)', async () => {
    const browser = await next.browser('/chat/123')
    expect(await browser.elementByCss('p').text()).toBe('Home')
  })
})`
- ID 361:
`test/e2e/app-dir/node-extensions/node-extensions.random.test.ts` —
`describe('Cache Components', () => {
      const { next } = nextTestSetup({
        files: __dirname + '/fixtures/random/cache-components',
      })

it('should not error when accessing middlware that use Math.random()',
async () => {
        let res: Awaited<ReturnType<typeof next.fetch>>,
          $: Awaited<ReturnType<typeof next.render$>>

        res = await next.fetch('/rewrite')
        expect(res.status).toBe(200)
        $ = await next.render$('/rewrite')
        expect($('[data-testid="content"]').text()).toBe('rewritten')
      })

it('should not error when accessing pages that use Math.random() in App
Router', async () => {
        let res, $

        res = await next.fetch('/app/prerendered/unstable-cache')
        expect(res.status).toBe(200)
        $ = await next.render$('/app/prerendered/unstable-cache')
        expect($('li').length).toBe(2)

        res = await next.fetch('/app/prerendered/use-cache')
        expect(res.status).toBe(200)
        $ = await next.render$('/app/prerendered/use-cache')
        expect($('li').length).toBe(2)

        res = await next.fetch('/app/rendered/uncached')
        expect(res.status).toBe(200)
        $ = await next.render$('/app/rendered/uncached')
        expect($('li').length).toBe(2)

        res = await next.fetch('/app/rendered/unstable-cache')
        expect(res.status).toBe(200)
        $ = await next.render$('/app/rendered/unstable-cache')
        expect($('li').length).toBe(2)

        res = await next.fetch('/app/rendered/use-cache')
        expect(res.status).toBe(200)
        $ = await next.render$('/app/rendered/use-cache')
        expect($('li').length).toBe(2)
      })

it('should not error when accessing routes that use Math.random() in App
Router', async () => {
        let res, body

        res = await next.fetch('/app/prerendered/uncached/api')
        expect(res.status).toBe(200)
        body = await res.json()
        expect(body).toEqual({
          rand1: expect.any(Number),
          rand2: expect.any(Number),
        })

        res = await next.fetch('/app/prerendered/unstable-cache/api')
        expect(res.status).toBe(200)
        body = await res.json()
        expect(body).toEqual({
          rand1: expect.any(Number),
          rand2: expect.any(Number),
        })

        res = await next.fetch('/app/prerendered/use-cache/api')
        expect(res.status).toBe(200)
        body = await res.json()
        expect(body).toEqual({
          rand1: expect.any(Number),
          rand2: expect.any(Number),
        })

        res = await next.fetch('/app/rendered/uncached/api')
        expect(res.status).toBe(200)
        body = await res.json()
        expect(body).toEqual({
          rand1: expect.any(Number),
          rand2: expect.any(Number),
        })

        res = await next.fetch('/app/rendered/unstable-cache/api')
        expect(res.status).toBe(200)
        body = await res.json()
        expect(body).toEqual({
          rand1: expect.any(Number),
          rand2: expect.any(Number),
        })

        res = await next.fetch('/app/rendered/use-cache/api')
        expect(res.status).toBe(200)
        body = await res.json()
        expect(body).toEqual({
          rand1: expect.any(Number),
          rand2: expect.any(Number),
        })
      })

it('should not error when accessing pages that use Math.random() in
Pages Router', async () => {
        let res, $

        res = await next.fetch('/pages/gip/random')
        expect(res.status).toBe(200)
        $ = await next.render$('/pages/gip/random')
        expect($('li').length).toBe(2)

        res = await next.fetch('/pages/gssp/random')
        expect(res.status).toBe(200)
        $ = await next.render$('/pages/gssp/random')
        expect($('li').length).toBe(2)

        res = await next.fetch('/pages/gsp/random')
        expect(res.status).toBe(200)
        $ = await next.render$('/pages/gsp/random')
        expect($('li').length).toBe(2)
      })

it('should not error when accessing routes that use Math.random() in
Pages Router', async () => {
        let res, body

        res = await next.fetch('/api/random')
        expect(res.status).toBe(200)
        body = await res.json()
        expect(body).toEqual({
          rand1: expect.any(Number),
          rand2: expect.any(Number),
        })

        expect(body.rand1).not.toBe(body.rand2)

        const first1 = body.rand1
        const first2 = body.rand2

        res = await next.fetch('/api/random')
        body = await res.json()
        expect(body.rand1).not.toBe(body.rand2)
        expect(body.rand1).not.toBe(first1)
        expect(body.rand2).not.toBe(first2)
      })
    })`
- ID 370:
`test/e2e/app-dir/webpack-loader-binary/webpack-loader-binary.test.ts` —
`describe('webpack-loader-ts-transform', () => {
  const { next } = nextTestSetup({
    files: __dirname,
  })

it('should allow passing binary assets to and from a Webpack loader',
async () => {
    const $ = await next.render$('/')
    expect($('#text').text()).toBe('Got a buffer of 18 bytes')
    expect($('#binary').text()).toBe('Got a buffer of 6765 bytes')
  })
})`
- ID 386:
`test/e2e/edge-runtime-uses-edge-light-import-specifier-for-packages/edge-runtime-uses-edge-light-import-specifier-for-packages.test.ts`
— `describe('edge-runtime uses edge-light import specifier for
packages', () => {
  const { next } = nextTestSetup({
    files: __dirname,
    packageJson: {
      scripts: {
        build: 'next build',
        dev: 'next dev',
        start: 'next start',
      },
    },
    installCommand: 'pnpm i',
    startCommand: (global as any).isNextDev ? 'pnpm dev' : 'pnpm start',
    buildCommand: 'pnpm build',
  })

  // In case you need to test the response object
  it('pages/api endpoints import the correct module', async () => {
    const res = await next.fetch('/api/edge')
    const html = await res.json()
    expect(html).toEqual({
// edge-light is only supported in `exports` and `imports` but webpack
also adds the top level `edge-light` key incorrectly.
edgeLightPackage: process.env.IS_TURBOPACK_TEST ? 'import' :
'edge-light',
      edgeLightPackageExports: 'edge-light',
    })
  })

  it('pages import the correct module', async () => {
    const $ = await next.render$('/')
    const text = JSON.parse($('pre#result').text())
    expect(text).toEqual({
// edge-light is only supported in `exports` and `imports` but webpack
also adds the top level `edge-light` key incorrectly.
edgeLightPackage: process.env.IS_TURBOPACK_TEST ? 'import' :
'edge-light',
      edgeLightPackageExports: 'edge-light',
    })
  })

  it('app-dir imports the correct module', async () => {
    const $ = await next.render$('/app-dir')
    const text = JSON.parse($('pre#result').text())
    expect(text).toEqual({
// edge-light is only supported in `exports` and `imports` but webpack
also adds the top level `edge-light` key incorrectly.
edgeLightPackage: process.env.IS_TURBOPACK_TEST ? 'import' :
'edge-light',
      edgeLightPackageExports: 'edge-light',
    })
  })
})`
- ID 392: `test/e2e/middleware-custom-matchers/test/index.test.ts` —
`it('should match has cookie on client routing', async () => {
      const browser = await next.browser('/routes')
      await browser.addCookie({ name: 'loggedIn', value: 'true' })
      await browser.refresh()
      await browser.eval('window.__TEST_NO_RELOAD = true')
      await browser.elementById('has-match-3').click()
const fromMiddleware = await
browser.elementById('from-middleware').text()
      expect(fromMiddleware).toBe('true')
      const noReload = await browser.eval('window.__TEST_NO_RELOAD')
      expect(noReload).toBe(true)
    })`
- ID 402:
`test/e2e/on-request-error/skip-next-internal-error/skip-next-internal-error.test.ts`
— `describe('on-request-error - skip-next-internal-error', () => {
  const { next } = nextTestSetup({
    files: __dirname,
  })

  async function assertNoNextjsInternalErrors() {
    const output = next.cliOutput
    // No navigation errors
    expect(output).not.toContain('NEXT_REDIRECT')
    expect(output).not.toContain('NEXT_NOT_FOUND')
    expect(output).not.toContain('BAILOUT_TO_CLIENT_SIDE_RENDERING')
    // No dynamic usage errors
    expect(output).not.toContain('DYNAMIC_SERVER_USAGE')
    // No react postpone errors
    // TODO: cover PPR errors later
    expect(output).not.toContain('react.postpone')
  }

  describe('app router render', () => {
    // Server navigation errors
it('should not catch server component not-found errors', async () => {
      await next.fetch('/server/not-found')
      await assertNoNextjsInternalErrors()
    })

it('should not catch server component redirect errors', async () => {
      await next.render('/server/redirect')
      await assertNoNextjsInternalErrors()
    })

    // Client navigation errors
it('should not catch client component not-found errors', async () => {
      await next.fetch('/server/not-found')
      await assertNoNextjsInternalErrors()
    })

it('should not catch client component redirect errors', async () => {
      await next.render('/client/redirect')
      await assertNoNextjsInternalErrors()
    })

    // Dynamic usage
it('should not catch server component dynamic usage errors', async () =>
{
      await next.fetch('/server/dynamic-fetch')
      await assertNoNextjsInternalErrors()
    })

it('should not catch client component dynamic usage errors', async () =>
{
      await next.fetch('/client/dynamic-fetch')
      await assertNoNextjsInternalErrors()
    })

    // No SSR
    it('should not catch next dynamic no-ssr errors', async () => {
      await next.fetch('/client/no-ssr')
      await assertNoNextjsInternalErrors()
    })

    // Server Actions navigation
    it('should not catch server action not-found errors', async () => {
      await next.fetch('/form/not-found')
      await assertNoNextjsInternalErrors()
    })

    it('should not catch server action redirect errors', async () => {
      await next.fetch('/form/redirect')
      await assertNoNextjsInternalErrors()
    })
  })

  describe('app router API', () => {
    // API routes navigation errors
it('should not catch server component not-found errors', async () => {
      await next.render('/app-route/not-found')
      await assertNoNextjsInternalErrors()
    })

it('should not catch server component redirect errors', async () => {
      await next.render('/app-route/redirect')
      await assertNoNextjsInternalErrors()
    })
  })
})`


</details>

<details>
<summary>Deployment evidence for the additional scopes</summary>

- `test/e2e/middleware-custom-matchers/test/index.test.ts` — `it('should
match has cookie on client routing', async () => {`:
[normal](https://github.com/vercel/next.js/actions/runs/34426785013/job/102715655249),
[cache](https://github.com/vercel/next.js/actions/runs/34426785013/job/102715655202).

</details>

<!-- NEXT_JS_LLM -->
2026-09-15 10:29:07 -07:00
Sebastian "Sebbie" Silbermann 3ff93d9124 Match peer dependencies in rsc-binary tests (#69515) 2024-09-03 17:50:56 +02:00
JJ Kasper e456acd854 Re-land Fix broken HTML inlining of non UTF-8 decodable binary data from Flight payload #65664 (#65988) 2024-06-04 20:25:59 -07:00
Zack Tanner 658037358c Revert "Fix broken HTML inlining of non UTF-8 decodable binary data f… (#65906)
…rom Flight payload (#65664)"

This reverts commit a34d909877.

This PR appears to be causing issues with PPR when deployed.
[x-ref](https://github.com/vercel/vercel/actions/runs/9133310975/job/25116552847?pr=11610)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2024-05-17 14:15:55 -07:00
Tim Neutkens e359b14881 Upgrade react@beta (#65845)
Ensures `useMemoCache` is available for the React Compiler.

Required for #65804 without having to manually enable experimental React
through e.g. taint: true.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-05-16 21:59:47 +02:00
Shu Ding a34d909877 Fix broken HTML inlining of non UTF-8 decodable binary data from Flight payload (#65664)
This PR ensures that any arbitrary binary data can be passed across the
RSC boundary, especially when inlined in HTML. While the Flight payloads
in RSC requests (`text/x-component`) already work, it's a different case
when we inline them directly in HTML as that's required to be a valid
string in UTF-8.

So instead of always inlining the UTF-8 decoded chunk (`new
TextDecoder('utf-8')`), we fallback non-decodable chunks to base64 and
send as a special item in `__next_f` so we can safely change it back to
a binary typed array.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-15 22:30:46 +00:00