Skip to content

Commit bed4e12

Browse files
chore: fix storybook flakes (#19366)
Close #19365
1 parent 4ca69af commit bed4e12

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

site/src/components/ActiveUserChart/ActiveUserChart.stories.tsx

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const meta: Meta<typeof ActiveUserChart> = {
66
component: ActiveUserChart,
77
args: {
88
data: [
9-
{ date: "2024-01-01", amount: 5 },
10-
{ date: "2024-01-02", amount: 6 },
11-
{ date: "2024-01-03", amount: 7 },
12-
{ date: "2024-01-04", amount: 8 },
13-
{ date: "2024-01-05", amount: 9 },
14-
{ date: "2024-01-06", amount: 10 },
15-
{ date: "2024-01-07", amount: 11 },
9+
{ date: "2024-01-01", amount: 12 },
10+
{ date: "2024-01-02", amount: 8 },
11+
{ date: "2024-01-03", amount: 15 },
12+
{ date: "2024-01-04", amount: 3 },
13+
{ date: "2024-01-05", amount: 22 },
14+
{ date: "2024-01-06", amount: 7 },
15+
{ date: "2024-01-07", amount: 18 },
1616
],
1717
},
1818
decorators: [
@@ -31,12 +31,31 @@ export const Example: Story = {};
3131

3232
export const ManyDataPoints: Story = {
3333
args: {
34-
data: Array.from({ length: 30 }).map((_, i) => {
35-
const date = new Date(2024, 0, i + 1);
36-
return {
37-
date: date.toISOString().split("T")[0],
38-
amount: 5 + Math.floor(Math.random() * 15),
39-
};
40-
}),
34+
data: [
35+
{ date: "2024-01-01", amount: 12 },
36+
{ date: "2024-01-02", amount: 8 },
37+
{ date: "2024-01-03", amount: 15 },
38+
{ date: "2024-01-04", amount: 3 },
39+
{ date: "2024-01-05", amount: 22 },
40+
{ date: "2024-01-06", amount: 7 },
41+
{ date: "2024-01-07", amount: 18 },
42+
{ date: "2024-01-08", amount: 31 },
43+
{ date: "2024-01-09", amount: 5 },
44+
{ date: "2024-01-10", amount: 27 },
45+
{ date: "2024-01-11", amount: 14 },
46+
{ date: "2024-01-12", amount: 9 },
47+
{ date: "2024-01-13", amount: 35 },
48+
{ date: "2024-01-14", amount: 21 },
49+
{ date: "2024-01-15", amount: 6 },
50+
{ date: "2024-01-16", amount: 29 },
51+
{ date: "2024-01-17", amount: 11 },
52+
{ date: "2024-01-18", amount: 17 },
53+
{ date: "2024-01-19", amount: 4 },
54+
{ date: "2024-01-20", amount: 25 },
55+
{ date: "2024-01-21", amount: 13 },
56+
{ date: "2024-01-22", amount: 33 },
57+
{ date: "2024-01-23", amount: 19 },
58+
{ date: "2024-01-24", amount: 26 },
59+
],
4160
},
4261
};

site/src/modules/workspaces/generateWorkspaceName.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import isChromatic from "chromatic/isChromatic";
12
import {
23
animals,
34
colors,
@@ -6,6 +7,9 @@ import {
67
} from "unique-names-generator";
78

89
export const generateWorkspaceName = () => {
10+
if (isChromatic()) {
11+
return "yellow-bird-23";
12+
}
913
const numberDictionary = NumberDictionary.generate({ min: 0, max: 99 });
1014
return uniqueNamesGenerator({
1115
dictionaries: [colors, animals, numberDictionary],

site/src/pages/WorkspaceSettingsPage/WorkspaceSchedulePage/WorkspaceSchedulePage.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import { templateByNameKey } from "api/queries/templates";
1111
import { workspaceByOwnerAndNameKey } from "api/queries/workspaces";
1212
import type { Workspace } from "api/typesGenerated";
1313
import {
14-
reactRouterNestedAncestors,
14+
reactRouterOutlet,
1515
reactRouterParameters,
1616
} from "storybook-addon-remix-react-router";
1717
import { WorkspaceSettingsLayout } from "../WorkspaceSettingsLayout";
1818
import WorkspaceSchedulePage from "./WorkspaceSchedulePage";
1919

2020
const meta = {
2121
title: "pages/WorkspaceSchedulePage",
22-
component: WorkspaceSchedulePage,
22+
component: WorkspaceSettingsLayout,
2323
decorators: [withAuthProvider, withDashboardProvider],
2424
parameters: {
2525
layout: "fullscreen",
@@ -52,11 +52,11 @@ function workspaceRouterParameters(workspace: Workspace) {
5252
workspace: workspace.name,
5353
},
5454
},
55-
routing: reactRouterNestedAncestors(
55+
routing: reactRouterOutlet(
5656
{
5757
path: "/:username/:workspace/settings/schedule",
5858
},
59-
<WorkspaceSettingsLayout />,
59+
<WorkspaceSchedulePage />,
6060
),
6161
});
6262
}

0 commit comments

Comments
 (0)