Unverified Commit 2277eb92 authored by Javi Velasco's avatar Javi Velasco Committed by GitHub

Enable appDir e2e deploy tests #1 (#41759)

Enables `appDir` test for `deploy` in the `test/e2e/app-dir/index.test.ts` test suite.
parent f5a89eb0
...@@ -15,12 +15,6 @@ import webdriver from 'next-webdriver' ...@@ -15,12 +15,6 @@ import webdriver from 'next-webdriver'
describe('app dir', () => { describe('app dir', () => {
const isDev = (global as any).isNextDev const isDev = (global as any).isNextDev
if ((global as any).isNextDeploy) {
it('should skip next deploy for now', () => {})
return
}
let next: NextInstance let next: NextInstance
function runTests() { function runTests() {
...@@ -139,22 +133,24 @@ describe('app dir', () => { ...@@ -139,22 +133,24 @@ describe('app dir', () => {
expect(html).toContain('hello from app/dashboard') expect(html).toContain('hello from app/dashboard')
}) })
it('should serve /index as separate page', async () => { if (!(global as any).isNextDeploy) {
const html = await renderViaHTTP(next.url, '/dashboard/index') it('should serve /index as separate page', async () => {
expect(html).toContain('hello from app/dashboard/index') const html = await renderViaHTTP(next.url, '/dashboard/index')
// should load chunks generated via async import correctly with React.lazy expect(html).toContain('hello from app/dashboard/index')
expect(html).toContain('hello from lazy') // should load chunks generated via async import correctly with React.lazy
// should support `dynamic` in both server and client components expect(html).toContain('hello from lazy')
expect(html).toContain('hello from dynamic on server') // should support `dynamic` in both server and client components
expect(html).toContain('hello from dynamic on client') expect(html).toContain('hello from dynamic on server')
}) expect(html).toContain('hello from dynamic on client')
})
it('should serve polyfills for browsers that do not support modules', async () => { it('should serve polyfills for browsers that do not support modules', async () => {
const html = await renderViaHTTP(next.url, '/dashboard/index') const html = await renderViaHTTP(next.url, '/dashboard/index')
expect(html).toMatch( expect(html).toMatch(
/<script src="\/_next\/static\/chunks\/polyfills(-\w+)?\.js" nomodule="">/ /<script src="\/_next\/static\/chunks\/polyfills(-\w+)?\.js" nomodule="">/
) )
}) })
}
// TODO-APP: handle css modules fouc in dev // TODO-APP: handle css modules fouc in dev
it.skip('should handle css imports in next/dynamic correctly', async () => { it.skip('should handle css imports in next/dynamic correctly', async () => {
...@@ -402,17 +398,19 @@ describe('app dir', () => { ...@@ -402,17 +398,19 @@ describe('app dir', () => {
}) })
describe('parallel routes', () => { describe('parallel routes', () => {
it('should match parallel routes', async () => { if (!(global as any).isNextDeploy) {
const html = await renderViaHTTP(next.url, '/parallel/nested') it('should match parallel routes', async () => {
expect(html).toContain('parallel/layout') const html = await renderViaHTTP(next.url, '/parallel/nested')
expect(html).toContain('parallel/@foo/nested/layout') expect(html).toContain('parallel/layout')
expect(html).toContain('parallel/@foo/nested/@a/page') expect(html).toContain('parallel/@foo/nested/layout')
expect(html).toContain('parallel/@foo/nested/@b/page') expect(html).toContain('parallel/@foo/nested/@a/page')
expect(html).toContain('parallel/@bar/nested/layout') expect(html).toContain('parallel/@foo/nested/@b/page')
expect(html).toContain('parallel/@bar/nested/@a/page') expect(html).toContain('parallel/@bar/nested/layout')
expect(html).toContain('parallel/@bar/nested/@b/page') expect(html).toContain('parallel/@bar/nested/@a/page')
expect(html).toContain('parallel/nested/page') expect(html).toContain('parallel/@bar/nested/@b/page')
}) expect(html).toContain('parallel/nested/page')
})
}
it('should match parallel routes in route groups', async () => { it('should match parallel routes in route groups', async () => {
const html = await renderViaHTTP(next.url, '/parallel/nested-2') const html = await renderViaHTTP(next.url, '/parallel/nested-2')
...@@ -1172,16 +1170,18 @@ describe('app dir', () => { ...@@ -1172,16 +1170,18 @@ describe('app dir', () => {
} }
}) })
it('should have consistent query and params handling', async () => { if (!(global as any).isNextDeploy) {
const html = await renderViaHTTP( it('should have consistent query and params handling', async () => {
next.url, const html = await renderViaHTTP(
'/param-and-query/params?slug=query' next.url,
) '/param-and-query/params?slug=query'
const $ = cheerio.load(html) )
const el = $('#params-and-query') const $ = cheerio.load(html)
expect(el.attr('data-params')).toBe('params') const el = $('#params-and-query')
expect(el.attr('data-query')).toBe('query') expect(el.attr('data-params')).toBe('params')
}) expect(el.attr('data-query')).toBe('query')
})
}
}) })
describe('useSelectedLayoutSegment', () => { describe('useSelectedLayoutSegment', () => {
...@@ -1905,21 +1905,23 @@ describe('app dir', () => { ...@@ -1905,21 +1905,23 @@ describe('app dir', () => {
}) })
describe('bots', () => { describe('bots', () => {
it('should block rendering for bots and return 404 status', async () => { if (!(global as any).isNextDeploy) {
const res = await fetchViaHTTP( it('should block rendering for bots and return 404 status', async () => {
next.url, const res = await fetchViaHTTP(
'/not-found/servercomponent', next.url,
'', '/not-found/servercomponent',
{ '',
headers: { {
'User-Agent': 'Googlebot', headers: {
}, 'User-Agent': 'Googlebot',
} },
) }
)
expect(res.status).toBe(404) expect(res.status).toBe(404)
expect(await res.text()).toInclude('"noindex"') expect(await res.text()).toInclude('"noindex"')
}) })
}
}) })
describe('redirect', () => { describe('redirect', () => {
...@@ -2038,22 +2040,24 @@ describe('app dir', () => { ...@@ -2038,22 +2040,24 @@ describe('app dir', () => {
}) })
describe('next/script', () => { describe('next/script', () => {
it('should support next/script and render in correct order', async () => { if (!(global as any).isNextDeploy) {
const browser = await webdriver(next.url, '/script') it('should support next/script and render in correct order', async () => {
const browser = await webdriver(next.url, '/script')
// Wait for lazyOnload scripts to be ready.
await new Promise((resolve) => setTimeout(resolve, 1000)) // Wait for lazyOnload scripts to be ready.
await new Promise((resolve) => setTimeout(resolve, 1000))
expect(await browser.eval(`window._script_order`)).toStrictEqual([
1, expect(await browser.eval(`window._script_order`)).toStrictEqual([
1.5, 1,
2, 1.5,
2.5, 2,
'render', 2.5,
3, 'render',
4, 3,
]) 4,
}) ])
})
}
it('should insert preload tags for beforeInteractive and afterInteractive scripts', async () => { it('should insert preload tags for beforeInteractive and afterInteractive scripts', async () => {
const html = await renderViaHTTP(next.url, '/script') const html = await renderViaHTTP(next.url, '/script')
......
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