Unverified Commit bafa8d49 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Remove installCommand on streaming-ssr test (#58037)

Removes installCommand as it doesn't have to be different than the
default command. Also converted to using `createNextDescribe`.

<!-- 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 #

-->
parent 8536ad98
import { join } from 'path' import { join } from 'path'
import { createNext, FileRef } from 'e2e-utils' import { createNext, createNextDescribe } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base' import { NextInstance } from 'test/lib/next-modes/base'
import { import {
check, check,
...@@ -12,61 +12,56 @@ import { ...@@ -12,61 +12,56 @@ import {
const isNextProd = !(global as any).isNextDev && !(global as any).isNextDeploy const isNextProd = !(global as any).isNextDev && !(global as any).isNextDeploy
describe('streaming SSR with custom next configs', () => { createNextDescribe(
let next: NextInstance 'streaming SSR with custom next configs',
{
beforeAll(async () => { files: join(__dirname, 'streaming-ssr'),
next = await createNext({ },
files: join(__dirname, 'streaming-ssr'), ({ next }) => {
installCommand: 'npm install', it('should match more specific route along with dynamic routes', async () => {
const res1 = await fetchViaHTTP(next.url, '/api/user/login')
const res2 = await fetchViaHTTP(next.url, '/api/user/any')
expect(await res1.text()).toBe('login')
expect(await res2.text()).toBe('[id]')
}) })
})
afterAll(() => next.destroy())
it('should match more specific route along with dynamic routes', async () => { it('should render styled-jsx styles in streaming', async () => {
const res1 = await fetchViaHTTP(next.url, '/api/user/login') const html = await renderViaHTTP(next.url, '/')
const res2 = await fetchViaHTTP(next.url, '/api/user/any') expect(html).toContain('color:blue')
expect(await res1.text()).toBe('login') })
expect(await res2.text()).toBe('[id]')
})
it('should render styled-jsx styles in streaming', async () => { it('should redirect paths without trailing-slash and render when slash is appended', async () => {
const html = await renderViaHTTP(next.url, '/') const page = '/hello'
expect(html).toContain('color:blue') const redirectRes = await fetchViaHTTP(
}) next.url,
page,
{},
{ redirect: 'manual' }
)
const res = await fetchViaHTTP(next.url, page + '/')
const html = await res.text()
it('should redirect paths without trailing-slash and render when slash is appended', async () => { expect(redirectRes.status).toBe(308)
const page = '/hello' expect(res.status).toBe(200)
const redirectRes = await fetchViaHTTP( expect(html).toContain('hello nextjs')
next.url, expect(html).toContain('home')
page, })
{},
{ redirect: 'manual' }
)
const res = await fetchViaHTTP(next.url, page + '/')
const html = await res.text()
expect(redirectRes.status).toBe(308)
expect(res.status).toBe(200)
expect(html).toContain('hello nextjs')
expect(html).toContain('home')
})
it('should render next/router correctly in edge runtime', async () => { it('should render next/router correctly in edge runtime', async () => {
const html = await renderViaHTTP(next.url, '/router') const html = await renderViaHTTP(next.url, '/router')
expect(html).toContain('link') expect(html).toContain('link')
}) })
it('should render multi-byte characters correctly in streaming', async () => { it('should render multi-byte characters correctly in streaming', async () => {
const html = await renderViaHTTP(next.url, '/multi-byte') const html = await renderViaHTTP(next.url, '/multi-byte')
expect(html).toContain('マルチバイト'.repeat(28)) expect(html).toContain('マルチバイト'.repeat(28))
}) })
if ((global as any).isNextDev) { if ((global as any).isNextDev) {
it('should work with custom document', async () => { it('should work with custom document', async () => {
await next.patchFile( await next.patchFile(
'pages/_document.js', 'pages/_document.js',
` `
import { Html, Head, Main, NextScript } from 'next/document' import { Html, Head, Main, NextScript } from 'next/document'
export default function Document() { export default function Document() {
...@@ -81,14 +76,15 @@ describe('streaming SSR with custom next configs', () => { ...@@ -81,14 +76,15 @@ describe('streaming SSR with custom next configs', () => {
) )
} }
` `
) )
await check(async () => { await check(async () => {
return await renderViaHTTP(next.url, '/') return await renderViaHTTP(next.url, '/')
}, /index/) }, /index/)
await next.deleteFile('pages/_document.js') await next.deleteFile('pages/_document.js')
}) })
}
} }
}) )
if (isNextProd) { if (isNextProd) {
describe('streaming SSR with custom server', () => { describe('streaming SSR with custom server', () => {
...@@ -97,11 +93,7 @@ if (isNextProd) { ...@@ -97,11 +93,7 @@ if (isNextProd) {
let appPort let appPort
beforeAll(async () => { beforeAll(async () => {
next = await createNext({ next = await createNext({
files: { files: join(__dirname, 'custom-server'),
pages: new FileRef(join(__dirname, 'custom-server/pages')),
'server.js': new FileRef(join(__dirname, 'custom-server/server.js')),
},
nextConfig: require(join(__dirname, 'custom-server/next.config.js')),
}) })
await next.stop() await next.stop()
......
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