Skip to content

Commit

Permalink
Kill chart flakiness (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
josepjaume authored Sep 25, 2024
1 parent 9b03360 commit 9e64cd8
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Meta } from "@storybook/react"
import { AreaChartProps } from "@/components/Charts/AreaChart"
import AreaChartStory from "@/components/Charts/AreaChart/index.stories"
import { AreaChartWidget } from "."
import { containerStoryArgs } from "../storybook-utils"
import { containerStoryArgs, WidgetDecorator } from "../storybook-utils"

const meta: Meta<typeof AreaChartWidget> = {
component: AreaChartWidget,
Expand All @@ -29,13 +29,7 @@ const meta: Meta<typeof AreaChartWidget> = {
},
chart: AreaChartStory.args as AreaChartProps,
},
decorators: [
(Story) => (
<div className="w-full min-w-80">
<Story />
</div>
),
],
decorators: [WidgetDecorator],
}

export default meta
Expand Down
10 changes: 2 additions & 8 deletions lib/experimental/Widgets/Charts/BarChartWidget/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Meta } from "@storybook/react"
import { BarChartProps } from "@/components/Charts/BarChart"
import BarChartStory from "@/components/Charts/BarChart/index.stories"
import { BarChartWidget } from "."
import { containerStoryArgs } from "../storybook-utils"
import { containerStoryArgs, WidgetDecorator } from "../storybook-utils"

const meta = {
component: BarChartWidget,
Expand All @@ -19,13 +19,7 @@ const meta = {
},
chart: BarChartStory.args as BarChartProps,
},
decorators: [
(Story) => (
<div className="w-full min-w-80">
<Story />
</div>
),
],
decorators: [WidgetDecorator],
} satisfies Meta<typeof BarChartWidget>

export default meta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Meta } from "@storybook/react"
import AreaChartStory from "@/components/Charts/AreaChart/index.stories"
import { LineChartProps } from "@/components/Charts/LineChart"
import { LineChartWidget } from "."
import { containerStoryArgs } from "../storybook-utils"
import { containerStoryArgs, WidgetDecorator } from "../storybook-utils"

const meta = {
component: LineChartWidget,
Expand All @@ -19,13 +19,7 @@ const meta = {
},
chart: AreaChartStory.args as LineChartProps,
},
decorators: [
(Story) => (
<div className="w-full min-w-80">
<Story />
</div>
),
],
decorators: [WidgetDecorator],
} satisfies Meta<typeof LineChartWidget>

export default meta
Expand Down
10 changes: 2 additions & 8 deletions lib/experimental/Widgets/Charts/PieChartWidget/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Meta } from "@storybook/react"

import { PieChartWidget } from "."
import { containerStoryArgs } from "../storybook-utils"
import { containerStoryArgs, WidgetDecorator } from "../storybook-utils"

const meta = {
component: PieChartWidget,
Expand Down Expand Up @@ -47,13 +47,7 @@ const meta = {
],
},
},
decorators: [
(Story) => (
<div className="w-full min-w-80">
<Story />
</div>
),
],
decorators: [WidgetDecorator],
} satisfies Meta<typeof PieChartWidget>

export default meta
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Meta } from "@storybook/react"
import { RadialProgressWidget } from "."
import { WidgetDecorator } from "../storybook-utils"

const meta = {
component: RadialProgressWidget,
Expand All @@ -20,13 +21,7 @@ const meta = {
overview: { number: 75, label: "Completed" },
},
},
decorators: [
(Story) => (
<div className="w-full min-w-80">
<Story />
</div>
),
],
decorators: [WidgetDecorator],
} satisfies Meta<typeof RadialProgressWidget>

export default meta
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Meta } from "@storybook/react"

import { SummariesWidget } from "."
import { WidgetDecorator } from "../storybook-utils"

const meta = {
component: SummariesWidget,
Expand All @@ -20,13 +21,7 @@ const meta = {
},
],
},
decorators: [
(Story) => (
<div className="w-full min-w-80">
<Story />
</div>
),
],
decorators: [WidgetDecorator],
} satisfies Meta<typeof SummariesWidget>

export default meta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Meta } from "@storybook/react"
import { VerticalBarChartProps } from "@/components/Charts/VerticalBarChart"
import BarChartStory from "@/components/Charts/VerticalBarChart/index.stories"
import { VerticalBarChartWidget } from "."
import { containerStoryArgs } from "../storybook-utils"
import { containerStoryArgs, WidgetDecorator } from "../storybook-utils"

const meta = {
component: VerticalBarChartWidget,
Expand All @@ -19,13 +19,7 @@ const meta = {
},
chart: BarChartStory.args as VerticalBarChartProps,
},
decorators: [
(Story) => (
<div className="w-full min-w-80">
<Story />
</div>
),
],
decorators: [WidgetDecorator],
} satisfies Meta<typeof VerticalBarChartWidget>

export default meta
Expand Down
6 changes: 6 additions & 0 deletions lib/experimental/Widgets/Charts/storybook-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ import ContainerStory from "../Widget/index.stories"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { children, ...containerStoryArgs } = ContainerStory.args

export const WidgetDecorator = (Story: React.ComponentType) => (
<div className="w-96">
<Story />
</div>
)

export { containerStoryArgs }

0 comments on commit 9e64cd8

Please sign in to comment.