From 9665541068a450cc986899d04642cc0a00de576f Mon Sep 17 00:00:00 2001 From: Zack Tanner Date: Mon, 14 Aug 2023 08:56:46 -0700 Subject: [PATCH 1/2] add standalone testcase for ipv6 hostnames --- .../standalone-mode/ipv6/app/app-page/page.js | 3 + .../standalone-mode/ipv6/app/layout.js | 8 ++ .../standalone-mode/ipv6/index.test.ts | 87 +++++++++++++++++++ .../standalone-mode/ipv6/next.config.js | 3 + .../standalone-mode/ipv6/pages/pages-page.js | 3 + 5 files changed, 104 insertions(+) create mode 100644 test/production/standalone-mode/ipv6/app/app-page/page.js create mode 100644 test/production/standalone-mode/ipv6/app/layout.js create mode 100644 test/production/standalone-mode/ipv6/index.test.ts create mode 100644 test/production/standalone-mode/ipv6/next.config.js create mode 100644 test/production/standalone-mode/ipv6/pages/pages-page.js diff --git a/test/production/standalone-mode/ipv6/app/app-page/page.js b/test/production/standalone-mode/ipv6/app/app-page/page.js new file mode 100644 index 0000000000000..5c93bee9b05e7 --- /dev/null +++ b/test/production/standalone-mode/ipv6/app/app-page/page.js @@ -0,0 +1,3 @@ +export default function AppPage() { + return
Hello from App
+} diff --git a/test/production/standalone-mode/ipv6/app/layout.js b/test/production/standalone-mode/ipv6/app/layout.js new file mode 100644 index 0000000000000..f3791f288f9d7 --- /dev/null +++ b/test/production/standalone-mode/ipv6/app/layout.js @@ -0,0 +1,8 @@ +export default function Layout({ children }) { + return ( + + + {children} + + ) +} diff --git a/test/production/standalone-mode/ipv6/index.test.ts b/test/production/standalone-mode/ipv6/index.test.ts new file mode 100644 index 0000000000000..124a8d9f7c801 --- /dev/null +++ b/test/production/standalone-mode/ipv6/index.test.ts @@ -0,0 +1,87 @@ +import { + FileRef, + NextInstance, + createNext, + createNextDescribe, +} from 'e2e-utils' +import fs from 'fs-extra' +import glob from 'glob' +import { + findPort, + initNextServerScript, + killApp, + renderViaHTTP, +} from 'next-test-utils' +import { join } from 'path' + +describe('standalone mode: ipv6 hostname', () => { + let next: NextInstance + let server + let appPort + let output = '' + + beforeAll(async () => { + next = await createNext({ + files: __dirname, + }) + await next.stop() + + await fs.move( + join(next.testDir, '.next/standalone'), + join(next.testDir, 'standalone') + ) + + for (const file of await fs.readdir(next.testDir)) { + if (file !== 'standalone') { + await fs.remove(join(next.testDir, file)) + console.log('removed', file) + } + } + const files = glob.sync('**/*', { + cwd: join(next.testDir, 'standalone/.next/server/pages'), + dot: true, + }) + + for (const file of files) { + if (file.endsWith('.json') || file.endsWith('.html')) { + await fs.remove(join(next.testDir, '.next/server', file)) + } + } + + const testServer = join(next.testDir, 'standalone/server.js') + appPort = await findPort() + server = await initNextServerScript( + testServer, + /ready started server on/, + { + ...process.env, + HOSTNAME: '::', + PORT: appPort, + }, + undefined, + { + cwd: next.testDir, + onStdout(msg) { + output += msg + }, + onStderr(msg) { + output += msg + }, + } + ) + }) + afterAll(async () => { + await next.destroy() + if (server) await killApp(server) + }) + + it('should load the page without any errors', async () => { + expect(output).toContain(`started server on`) + + let html = await renderViaHTTP(appPort, '/app-page') + expect(html).toContain('Hello from App') + + html = await renderViaHTTP(appPort, '/pages-page') + expect(html).toContain('Hello from Pages') + }) +}) diff --git a/test/production/standalone-mode/ipv6/next.config.js b/test/production/standalone-mode/ipv6/next.config.js new file mode 100644 index 0000000000000..e97173b4b3799 --- /dev/null +++ b/test/production/standalone-mode/ipv6/next.config.js @@ -0,0 +1,3 @@ +module.exports = { + output: 'standalone', +} diff --git a/test/production/standalone-mode/ipv6/pages/pages-page.js b/test/production/standalone-mode/ipv6/pages/pages-page.js new file mode 100644 index 0000000000000..6d50c075faae6 --- /dev/null +++ b/test/production/standalone-mode/ipv6/pages/pages-page.js @@ -0,0 +1,3 @@ +export default function AppPage() { + return
Hello from Pages
+} From f3402198dcfa98d465e3cd55010309c468054bb9 Mon Sep 17 00:00:00 2001 From: Zack Tanner Date: Mon, 14 Aug 2023 09:17:41 -0700 Subject: [PATCH 2/2] lint --- test/production/standalone-mode/ipv6/index.test.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/production/standalone-mode/ipv6/index.test.ts b/test/production/standalone-mode/ipv6/index.test.ts index 124a8d9f7c801..273f992018324 100644 --- a/test/production/standalone-mode/ipv6/index.test.ts +++ b/test/production/standalone-mode/ipv6/index.test.ts @@ -1,9 +1,4 @@ -import { - FileRef, - NextInstance, - createNext, - createNextDescribe, -} from 'e2e-utils' +import { NextInstance, createNext } from 'e2e-utils' import fs from 'fs-extra' import glob from 'glob' import {