2019-09-01 14:58:56 +00:00
|
|
|
import Browser from '../utils/browser'
|
|
|
|
import { loadFixture, getPort, Nuxt } from '../utils'
|
|
|
|
|
|
|
|
let port
|
|
|
|
const browser = new Browser()
|
2023-10-16 21:23:38 +00:00
|
|
|
const url = route => 'http://127.0.0.1:' + port + route
|
2019-09-01 14:58:56 +00:00
|
|
|
|
|
|
|
let nuxt = null
|
|
|
|
let page = null
|
|
|
|
|
|
|
|
describe('basic browser', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
const config = await loadFixture('error')
|
|
|
|
nuxt = new Nuxt(config)
|
|
|
|
await nuxt.ready()
|
|
|
|
|
|
|
|
port = await getPort()
|
2023-10-16 21:23:38 +00:00
|
|
|
await nuxt.server.listen(port, '127.0.0.1')
|
2019-09-01 14:58:56 +00:00
|
|
|
|
|
|
|
await browser.start({
|
|
|
|
// slowMo: 50,
|
|
|
|
// headless: false
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Open /', async () => {
|
|
|
|
page = await browser.page(url('/'))
|
|
|
|
|
|
|
|
expect(await page.$text('h1')).toBe('Error Loop incoming page')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('/squared doesnt loop due to error on error page', async () => {
|
|
|
|
await page.nuxt.navigate('/squared')
|
|
|
|
|
2019-09-30 08:44:35 +00:00
|
|
|
expect(await page.$text('header')).toBe('Error layout')
|
2020-04-14 09:26:40 +00:00
|
|
|
expect(await page.$text('h2')).toBe('An error occurred while showing the error page')
|
2019-09-01 14:58:56 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('/about loads normally', async () => {
|
|
|
|
await page.nuxt.navigate('/about')
|
|
|
|
|
|
|
|
expect(await page.$text('h1')).toBe('About')
|
|
|
|
})
|
|
|
|
|
2020-09-09 10:32:10 +00:00
|
|
|
test('/about error layout after click', async () => {
|
|
|
|
const transitionPromise = page.evaluate(async ($nuxt) => {
|
|
|
|
await new Promise(resolve => $nuxt.$once('triggerScroll', resolve))
|
|
|
|
}, page.$nuxt)
|
|
|
|
|
|
|
|
await page.click('button')
|
|
|
|
await transitionPromise
|
|
|
|
expect(await page.$text('header')).toBe('Error layout')
|
|
|
|
})
|
|
|
|
|
2019-09-01 14:58:56 +00:00
|
|
|
test('/info prints empty page', async () => {
|
|
|
|
await page.nuxt.navigate('/info')
|
|
|
|
|
|
|
|
expect(await page.$text('#__layout')).toBe('')
|
|
|
|
})
|
|
|
|
|
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
|
|
afterAll(async () => {
|
|
|
|
await nuxt.close()
|
|
|
|
})
|
|
|
|
|
|
|
|
// Stop browser
|
|
|
|
afterAll(async () => {
|
|
|
|
await page.close()
|
|
|
|
await browser.close()
|
|
|
|
})
|
|
|
|
})
|