Skip to content

Commit

Permalink
missing html tag seems to work just fine now
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Apr 20, 2024
1 parent c09bd4f commit 6c7d16e
Showing 1 changed file with 2 additions and 54 deletions.
56 changes: 2 additions & 54 deletions test/development/app-dir/missing-required-html-tags/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,12 @@
import { nextTestSetup } from 'e2e-utils'
import { getRedboxDescription, hasRedbox, retry } from 'next-test-utils'
import { hasRedbox } from 'next-test-utils'

describe('app-dir - missing required html tags', () => {
const { next } = nextTestSetup({ files: __dirname })

it('should show error overlay', async () => {
it('should not error', async () => {
const browser = await next.browser('/')

expect(await hasRedbox(browser)).toBe(true)
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(`
"The following tags are missing in the Root Layout: <html>, <body>.
Read more at https://nextjs.org/docs/messages/missing-root-layout-tags"
`)
})

it('should hmr when you fix the error', async () => {
const browser = await next.browser('/')

await next.patchFile('app/layout.js', (code) =>
code.replace('return children', 'return <body>{children}</body>')
)

expect(await hasRedbox(browser)).toBe(true)
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(`
"The following tags are missing in the Root Layout: <html>.
Read more at https://nextjs.org/docs/messages/missing-root-layout-tags"
`)

await next.patchFile('app/layout.js', (code) =>
code.replace(
'return <body>{children}</body>',
'return <html><body>{children}</body></html>'
)
)

expect(await hasRedbox(browser)).toBe(false)
expect(await browser.elementByCss('p').text()).toBe('hello world')

// Reintroduce the bug, but only missing html tag
await next.patchFile('app/layout.js', (code) =>
code.replace(
'return <html><body>{children}</body></html>',
'return children'
)
)

await retry(async () => {
expect(await hasRedbox(browser)).toBe(true)
})

// Fix the issue again
await next.patchFile('app/layout.js', (code) =>
code.replace(
'return children',
'return <html><body>{children}</body></html>'
)
)

await retry(async () => {
expect(await hasRedbox(browser)).toBe(false)
})
})
})

0 comments on commit 6c7d16e

Please sign in to comment.