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

[DevOverlay] Add Basic Stories for Error Containers #74697

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BuildError } from './BuildError'
import { withShadowPortal } from '../storybook/with-shadow-portal'

const meta: Meta<typeof BuildError> = {
title: 'BuildError',
component: BuildError,
parameters: {
layout: 'fullscreen',
},
decorators: [withShadowPortal],
}

export default meta
type Story = StoryObj<typeof BuildError>

export const Default: Story = {
args: {
message: `./src/app/page.tsx:3:3
Parsing ecmascript source code failed
1 | export default function Home() {
2 | const
> 3 | return <div>Hello World</div>
| ^^^^^^
4 | }
5 |

Expected identError: Failed to resolve import "./missing-module"`,
versionInfo: {
installed: '15.0.0',
staleness: 'fresh',
},
},
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react'
import { Errors } from './Errors'
import { withShadowPortal } from '../storybook/with-shadow-portal'
import { ACTION_UNHANDLED_ERROR } from '../../../shared'

const meta: Meta<typeof Errors> = {
title: 'Errors',
Expand All @@ -21,32 +22,109 @@ export const Default: Story = {
{
id: 1,
event: {
type: 'unhandled-error',
reason: new Error('Failed to compile'),
type: ACTION_UNHANDLED_ERROR,
reason: new Error('First error message'),
componentStackFrames: [
{
file: 'app/page.tsx',
component: 'Home',
lineNumber: 10,
column: 5,
canOpenInEditor: true,
},
],
frames: [
{
file: 'app/page.tsx',
methodName: 'Home',
arguments: [],
lineNumber: 10,
column: 5,
},
],
},
},
{
id: 2,
event: {
type: ACTION_UNHANDLED_ERROR,
reason: new Error('Second error message'),
frames: [],
},
},
{
id: 3,
event: {
type: ACTION_UNHANDLED_ERROR,
reason: new Error('Third error message'),
frames: [],
},
},
{
id: 4,
event: {
type: ACTION_UNHANDLED_ERROR,
reason: new Error('Fourth error message'),
frames: [],
},
},
],
initialDisplayState: 'fullscreen',
versionInfo: {
installed: '15.0.0',
staleness: 'fresh',
},
initialDisplayState: 'fullscreen',
hasStaticIndicator: true,
isTurbopackEnabled: true,
},
}

export const NoErrors: Story = {
export const Minimized: Story = {
args: {
isAppDir: true,
errors: [],
...Default.args,
initialDisplayState: 'minimized',
versionInfo: {
installed: '15.0.0',
staleness: 'fresh',
},
hasStaticIndicator: true,
isTurbopackEnabled: true,
},
}

export const WithHydrationWarning: Story = {
args: {
isAppDir: true,
errors: [
{
id: 1,
event: {
type: ACTION_UNHANDLED_ERROR,
reason: Object.assign(new Error('Hydration error'), {
details: {
warning: [
'Text content does not match server-rendered HTML: "%s" !== "%s"',
'Server Content',
'Client Content',
],
reactOutputComponentDiff: `<MyComponent>
<ParentComponent>
<div>
- <p> hello world </p>
+ <div> hello world </div>`,
},
componentStackFrames: [
{
component: 'MyComponent',
file: 'app/page.tsx',
lineNumber: 10,
columnNumber: 5,
},
{
component: 'ParentComponent',
file: 'app/layout.tsx',
lineNumber: 20,
columnNumber: 3,
},
],
}),
frames: [],
},
},
],
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Meta, StoryObj } from '@storybook/react'
import { RootLayoutMissingTagsError } from './RootLayoutMissingTagsError'
import { withShadowPortal } from '../storybook/with-shadow-portal'

const meta: Meta<typeof RootLayoutMissingTagsError> = {
title: 'RootLayoutMissingTagsError',
component: RootLayoutMissingTagsError,
parameters: {
layout: 'fullscreen',
},
decorators: [withShadowPortal],
}

export default meta
type Story = StoryObj<typeof RootLayoutMissingTagsError>

export const Default: Story = {
args: {
missingTags: ['html', 'body'],
versionInfo: {
installed: '15.0.0',
staleness: 'fresh',
},
},
}

export const SingleTag: Story = {
args: {
missingTags: ['html'],
versionInfo: {
installed: '15.0.0',
staleness: 'fresh',
},
},
}
Loading