Skip to content

Commit

Permalink
Rename waitForAndOpenRuntimeError to openRedbox
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Nov 21, 2024
1 parent 2113aac commit 7da9f3c
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 114 deletions.
12 changes: 6 additions & 6 deletions test/development/acceptance-app/ReactRefreshLogBox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
)
await session.evaluate(() => document.querySelector('a').click())

await session.waitForAndOpenRuntimeError()
await session.openRedbox()
expect(await session.getRedboxSource()).toMatchSnapshot()
})

Expand Down Expand Up @@ -149,7 +149,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`export default function FunctionDefault() { throw new Error('no'); }`
)

await session.waitForAndOpenRuntimeError()
await session.openRedbox()
expect(await session.getRedboxSource()).toMatchSnapshot()
expect(
await session.evaluate(() => document.querySelector('h2').textContent)
Expand Down Expand Up @@ -390,7 +390,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
)

await session.evaluate(() => document.querySelector('button').click())
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

const header = await session.getRedboxDescription()
expect(header).toMatchSnapshot()
Expand Down Expand Up @@ -435,7 +435,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
)

await session.evaluate(() => document.querySelector('button').click())
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

const header2 = await session.getRedboxDescription()
expect(header2).toMatchSnapshot()
Expand Down Expand Up @@ -480,7 +480,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
)

await session.evaluate(() => document.querySelector('button').click())
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

const header3 = await session.getRedboxDescription()
expect(header3).toMatchSnapshot()
Expand Down Expand Up @@ -525,7 +525,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
)

await session.evaluate(() => document.querySelector('button').click())
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

const header4 = await session.getRedboxDescription()
expect(header4).toEqual(
Expand Down
2 changes: 1 addition & 1 deletion test/development/acceptance-app/error-message-url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Error overlay - error message urls', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

const link = await browser.elementByCss('#nextjs__container_errors__link a')
const text = await link.text()
Expand Down
4 changes: 2 additions & 2 deletions test/development/acceptance-app/error-recovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe.each(['default', 'turbo'])('Error recovery app %s', () => {
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('1')

await session.waitForAndOpenRuntimeError()
await session.openRedbox()

expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"index.js (7:11) @ Index.useCallback[increment]
Expand Down Expand Up @@ -282,7 +282,7 @@ describe.each(['default', 'turbo'])('Error recovery app %s', () => {
)

await new Promise((resolve) => setTimeout(resolve, 1000))
await session.waitForAndOpenRuntimeError()
await session.openRedbox()
expect(await session.getRedboxSource()).not.toInclude(
"Expected '}', got '<eof>'"
)
Expand Down
45 changes: 15 additions & 30 deletions test/development/acceptance-app/hydration-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
Expand Down Expand Up @@ -153,9 +152,8 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

const pseudoHtml = await session.getRedboxComponentStack()
Expand Down Expand Up @@ -203,9 +201,8 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

const pseudoHtml = await session.getRedboxComponentStack()
Expand Down Expand Up @@ -239,9 +236,8 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

const pseudoHtml = await session.getRedboxComponentStack()
Expand Down Expand Up @@ -288,9 +284,8 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

const pseudoHtml = await session.getRedboxComponentStack()
Expand Down Expand Up @@ -330,9 +325,8 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
Expand Down Expand Up @@ -378,9 +372,8 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(2)

// FIXME: Should also have "text nodes cannot be a child of tr"
Expand Down Expand Up @@ -427,9 +420,8 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

expect(await session.getRedboxDescription()).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -487,7 +479,7 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

const pseudoHtml = await session.getRedboxComponentStack()
if (isTurbopack) {
Expand Down Expand Up @@ -572,9 +564,8 @@ describe('Error overlay for hydration errors in App router', () => {
)

const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(2)

const description = await session.getRedboxDescription()
Expand Down Expand Up @@ -631,9 +622,8 @@ describe('Error overlay for hydration errors in App router', () => {
)

const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(2)

const description = await session.getRedboxDescription()
Expand Down Expand Up @@ -670,9 +660,8 @@ describe('Error overlay for hydration errors in App router', () => {
)

const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(2)

const description = await session.getRedboxDescription()
Expand Down Expand Up @@ -724,9 +713,8 @@ describe('Error overlay for hydration errors in App router', () => {
)

const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(2)

const description = await session.getRedboxDescription()
Expand Down Expand Up @@ -796,9 +784,7 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()

await session.assertHasRedbox()
await session.openRedbox()

retry(async () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(4)
Expand Down Expand Up @@ -868,9 +854,8 @@ describe('Error overlay for hydration errors in App router', () => {
])
)
const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError()
await session.openRedbox()

await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

const pseudoHtml = await session.getRedboxComponentStack()
Expand Down
2 changes: 1 addition & 1 deletion test/development/acceptance-app/version-staleness.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Error Overlay version staleness', () => {
`
)

await session.waitForAndOpenRuntimeError()
await session.openRedbox()

if (process.env.TURBOPACK) {
expect(await getStaleness(browser)).toMatchInlineSnapshot(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
getRedboxCallStack,
getRedboxDescription,
getRedboxTitle,
getRedboxSource,
getRedboxTotalErrorCount,
waitForAndOpenRuntimeError,
openRedbox,
} from 'next-test-utils'

async function getRedboxResult(browser: any) {
Expand All @@ -33,8 +32,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
const browser = await next.browser('/browser/event')
await browser.elementByCss('button').click()

await waitForAndOpenRuntimeError(browser)
await assertHasRedbox(browser)
await openRedbox(browser)

const result = await getRedboxResult(browser)

Expand Down Expand Up @@ -82,8 +80,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
it('should capture browser console error in render and dedupe if necessary', async () => {
const browser = await next.browser('/browser/render')

await waitForAndOpenRuntimeError(browser)
await assertHasRedbox(browser)
await openRedbox(browser)

const result = await getRedboxResult(browser)

Expand Down Expand Up @@ -129,8 +126,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
it('should capture browser console error in render and dedupe when multi same errors logged', async () => {
const browser = await next.browser('/browser/render')

await waitForAndOpenRuntimeError(browser)
await assertHasRedbox(browser)
await openRedbox(browser)

const result = await getRedboxResult(browser)

Expand Down Expand Up @@ -176,8 +172,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
it('should capture server replay string error from console error', async () => {
const browser = await next.browser('/ssr')

await waitForAndOpenRuntimeError(browser)
await assertHasRedbox(browser)
await openRedbox(browser)

const result = await getRedboxResult(browser)

Expand Down Expand Up @@ -223,8 +218,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
it('should capture server replay error instance from console error', async () => {
const browser = await next.browser('/ssr-error-instance')

await waitForAndOpenRuntimeError(browser)
await assertHasRedbox(browser)
await openRedbox(browser)

const result = await getRedboxResult(browser)

Expand Down Expand Up @@ -270,8 +264,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
it('should be able to capture rsc logged error', async () => {
const browser = await next.browser('/rsc')

await waitForAndOpenRuntimeError(browser)
await assertHasRedbox(browser)
await openRedbox(browser)

const result = await getRedboxResult(browser)

Expand Down
Loading

0 comments on commit 7da9f3c

Please sign in to comment.