mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Fix production tests.
This commit is contained in:
parent
03209d88fd
commit
a1f11a4660
3
test/integration/production/pages/about.js
Normal file
3
test/integration/production/pages/about.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default () => (
|
||||||
|
<div className='about-page'>About Page</div>
|
||||||
|
)
|
|
@ -1,3 +1,8 @@
|
||||||
|
import Link from 'next/link'
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>Hello World</div>
|
<div>
|
||||||
|
<Link href='/about'><a>About Page</a></Link>
|
||||||
|
<p>Hello World</p>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/* global jasmine, describe, it, expect, beforeAll, afterAll */
|
/* global jasmine, describe, it, expect, beforeAll, afterAll */
|
||||||
|
|
||||||
import fetch from 'node-fetch'
|
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import {
|
import {
|
||||||
nextServer,
|
nextServer,
|
||||||
|
@ -9,6 +8,7 @@ import {
|
||||||
stopApp,
|
stopApp,
|
||||||
renderViaHTTP
|
renderViaHTTP
|
||||||
} from 'next-test-utils'
|
} from 'next-test-utils'
|
||||||
|
import webdriver from 'next-webdriver'
|
||||||
|
|
||||||
const appDir = join(__dirname, '../')
|
const appDir = join(__dirname, '../')
|
||||||
let appPort
|
let appPort
|
||||||
|
@ -37,32 +37,16 @@ describe('Production Usage', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('JSON pages', () => {
|
describe('With navigation', () => {
|
||||||
describe('when asked for a normal page', () => {
|
it('should navigate via client side', async () => {
|
||||||
it('should serve the normal page', async () => {
|
const browser = await webdriver(appPort, '/')
|
||||||
const url = `http://localhost:${appPort}/_next/${app.renderOpts.buildId}/pages`
|
const text = await browser
|
||||||
const res = await fetch(url, { compress: false })
|
.elementByCss('a').click()
|
||||||
expect(res.headers.get('Content-Encoding')).toBeNull()
|
.waitForElementByCss('.about-page')
|
||||||
|
.elementByCss('div').text()
|
||||||
|
|
||||||
const page = await res.json()
|
expect(text).toBe('About Page')
|
||||||
expect(page.component).toBeDefined()
|
browser.close()
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('when asked for a page with an unknown encoding', () => {
|
|
||||||
it('should serve the normal page', async () => {
|
|
||||||
const url = `http://localhost:${appPort}/_next/${app.renderOpts.buildId}/pages`
|
|
||||||
const res = await fetch(url, {
|
|
||||||
compress: false,
|
|
||||||
headers: {
|
|
||||||
'Accept-Encoding': 'br'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
expect(res.headers.get('Content-Encoding')).toBeNull()
|
|
||||||
|
|
||||||
const page = await res.json()
|
|
||||||
expect(page.component).toBeDefined()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue