Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(error-overlay): style tweaks #63522

Merged
merged 11 commits into from
Mar 25, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ export function Errors({
<span>{activeIdx + 1}</span> of{' '}
<span data-nextjs-dialog-header-total-count>
{readyErrors.length}
</span>{' '}
unhandled error
</span>
{' error'}
{readyErrors.length < 2 ? '' : 's'}
</small>
{versionInfo ? <VersionStalenessInfo {...versionInfo} /> : null}
Expand Down Expand Up @@ -316,10 +316,10 @@ export const styles = css`
margin-left: var(--size-gap-double);
}
.nextjs-container-errors-header small > span {
font-family: var(--font-stack-monospace);
font-family: sans-serif;
}
.nextjs-container-errors-header p {
font-family: var(--font-stack-monospace);
font-family: sans-serif;
font-size: var(--size-font-small);
line-height: var(--size-font-big);
font-weight: bold;
Expand All @@ -328,14 +328,13 @@ export const styles = css`
white-space: pre-wrap;
}
.nextjs__container_errors_desc--error {
color: var(--color-ansi-red);
padding-left: var(--size-gap);
border-left: 4px solid var(--color-accents-1);
color: var(--color-font);
}
.nextjs__container_errors__extra {
margin: 20px 0;
}
nextjs__container_errors__extra__code {
margin: 10px 0;
}
.nextjs-container-errors-header > div > small {
margin: 0;
margin-top: var(--size-gap-half);
Expand Down
11 changes: 3 additions & 8 deletions test/development/acceptance-app/hydration-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { sandbox } from 'development-sandbox'
import { FileRef, nextTestSetup } from 'e2e-utils'
import path from 'path'
import { outdent } from 'outdent'
import { getRedboxTotalErrorCount } from 'next-test-utils'

// https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference

Expand Down Expand Up @@ -373,10 +374,7 @@ describe('Error overlay for hydration errors', () => {
await session.waitForAndOpenRuntimeError()
expect(await session.hasRedbox()).toBe(true)

const totalErrorCount = await browser
.elementByCss('[data-nextjs-dialog-header-total-count]')
.text()
expect(totalErrorCount).toBe('1')
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

const description = await session.getRedboxDescription()
expect(description).toContain(
Expand Down Expand Up @@ -436,10 +434,7 @@ describe('Error overlay for hydration errors', () => {
await session.waitForAndOpenRuntimeError()
expect(await session.hasRedbox()).toBe(true)

const totalErrorCount = await browser
.elementByCss('[data-nextjs-dialog-header-total-count]')
.text()
expect(totalErrorCount).toBe('1')
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

const description = await session.getRedboxDescription()
expect(description).toContain(
Expand Down
7 changes: 7 additions & 0 deletions test/lib/next-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,13 @@ export async function getRedboxHeader(browser: BrowserInterface) {
)
}

export async function getRedboxTotalErrorCount(browser: BrowserInterface) {
return parseInt(
(await getRedboxHeader(browser)).match(/\d+ of (\d+) error/)?.[1],
10
)
}

export async function getRedboxSource(browser: BrowserInterface) {
return retry(
() =>
Expand Down