rsnext/test/production/app-dir-prefetch-non-iso-url/index.test.ts
JJ Kasper 19013a5e3f
Ensure next.url is used instead of next.appPort (#44163)
`appPort` shouldn't be used unless absolutely necessary as `next.url` is
more specific and allows more control.

x-ref:
https://github.com/vercel/next.js/actions/runs/3734223762/jobs/6336069606
2022-12-19 13:29:50 -08:00

48 lines
1.3 KiB
TypeScript

import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { join } from 'path'
import { BrowserInterface } from '../../lib/browsers/base'
import webdriver from 'next-webdriver'
import { check } from 'next-test-utils'
describe('app-dir-prefetch-non-iso-url', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
'next.config.js': new FileRef(join(__dirname, 'next.config.js')),
app: new FileRef(join(__dirname, 'app')),
},
})
})
afterAll(() => next.destroy())
it('should go to iso url', async () => {
let browser: BrowserInterface
try {
browser = await webdriver(next.url, '/')
await browser.elementByCss('#to-iso').click()
await check(() => browser.elementByCss('#page').text(), '/[slug]')
} finally {
if (browser) {
await browser.close()
}
}
})
it('should go to non-iso url', async () => {
let browser: BrowserInterface
try {
browser = await webdriver(next.url, '/')
await browser.elementByCss('#to-non-iso').click()
await check(() => browser.elementByCss('#page').text(), '/[slug]')
} finally {
if (browser) {
await browser.close()
}
}
})
})