Skip to content

Commit

Permalink
[DevOverlay] Add Basic Stories for Error Containers
Browse files Browse the repository at this point in the history
  • Loading branch information
devjiwonchoi committed Jan 9, 2025
1 parent 413b357 commit e4f4d0e
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 12 deletions.
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,110 @@ 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',
},
},
}

0 comments on commit e4f4d0e

Please sign in to comment.