Skip to content

chore: fix storybook flakes #19366

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

Merged
merged 5 commits into from
Aug 15, 2025
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
47 changes: 33 additions & 14 deletions site/src/components/ActiveUserChart/ActiveUserChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const meta: Meta<typeof ActiveUserChart> = {
component: ActiveUserChart,
args: {
data: [
{ date: "2024-01-01", amount: 5 },
{ date: "2024-01-02", amount: 6 },
{ date: "2024-01-03", amount: 7 },
{ date: "2024-01-04", amount: 8 },
{ date: "2024-01-05", amount: 9 },
{ date: "2024-01-06", amount: 10 },
{ date: "2024-01-07", amount: 11 },
{ date: "2024-01-01", amount: 12 },
{ date: "2024-01-02", amount: 8 },
{ date: "2024-01-03", amount: 15 },
{ date: "2024-01-04", amount: 3 },
{ date: "2024-01-05", amount: 22 },
{ date: "2024-01-06", amount: 7 },
{ date: "2024-01-07", amount: 18 },
],
},
decorators: [
Expand All @@ -31,12 +31,31 @@ export const Example: Story = {};

export const ManyDataPoints: Story = {
args: {
data: Array.from({ length: 30 }).map((_, i) => {
const date = new Date(2024, 0, i + 1);
return {
date: date.toISOString().split("T")[0],
amount: 5 + Math.floor(Math.random() * 15),
};
}),
Comment on lines -34 to -40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for just unrolling this loop. 😄 this implementation was clever but is far less understandable at a glance, despite being like 1/3rd the lines of code.

data: [
{ date: "2024-01-01", amount: 12 },
{ date: "2024-01-02", amount: 8 },
{ date: "2024-01-03", amount: 15 },
{ date: "2024-01-04", amount: 3 },
{ date: "2024-01-05", amount: 22 },
{ date: "2024-01-06", amount: 7 },
{ date: "2024-01-07", amount: 18 },
{ date: "2024-01-08", amount: 31 },
{ date: "2024-01-09", amount: 5 },
{ date: "2024-01-10", amount: 27 },
{ date: "2024-01-11", amount: 14 },
{ date: "2024-01-12", amount: 9 },
{ date: "2024-01-13", amount: 35 },
{ date: "2024-01-14", amount: 21 },
{ date: "2024-01-15", amount: 6 },
{ date: "2024-01-16", amount: 29 },
{ date: "2024-01-17", amount: 11 },
{ date: "2024-01-18", amount: 17 },
{ date: "2024-01-19", amount: 4 },
{ date: "2024-01-20", amount: 25 },
{ date: "2024-01-21", amount: 13 },
{ date: "2024-01-22", amount: 33 },
{ date: "2024-01-23", amount: 19 },
{ date: "2024-01-24", amount: 26 },
],
},
};
4 changes: 4 additions & 0 deletions site/src/modules/workspaces/generateWorkspaceName.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isChromatic from "chromatic/isChromatic";
import {
animals,
colors,
Expand All @@ -6,6 +7,9 @@ import {
} from "unique-names-generator";

export const generateWorkspaceName = () => {
if (isChromatic()) {
return "yellow-bird-23";
}
const numberDictionary = NumberDictionary.generate({ min: 0, max: 99 });
return uniqueNamesGenerator({
dictionaries: [colors, animals, numberDictionary],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import { templateByNameKey } from "api/queries/templates";
import { workspaceByOwnerAndNameKey } from "api/queries/workspaces";
import type { Workspace } from "api/typesGenerated";
import {
reactRouterNestedAncestors,
reactRouterOutlet,
reactRouterParameters,
} from "storybook-addon-remix-react-router";
import { WorkspaceSettingsLayout } from "../WorkspaceSettingsLayout";
import WorkspaceSchedulePage from "./WorkspaceSchedulePage";

const meta = {
title: "pages/WorkspaceSchedulePage",
component: WorkspaceSchedulePage,
component: WorkspaceSettingsLayout,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer that this component stay "correct", but the way the react-router storybook addon works really confuses me, so I don't really have a better idea.

Copy link
Collaborator Author

@BrunoQuaresma BrunoQuaresma Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too. The issue was, when using the nested layout function, the react-router decorator was load before any other local decorators, because of how we set it in the preview config, injecting the workspace settings layout before the dashboard provider that is required to make the it work.

IMO, we should simplify the global decorators and let the stories define what they want to use. Improving performance and make easier to identify the story dependencies.

decorators: [withAuthProvider, withDashboardProvider],
parameters: {
layout: "fullscreen",
Expand Down Expand Up @@ -52,11 +52,11 @@ function workspaceRouterParameters(workspace: Workspace) {
workspace: workspace.name,
},
},
routing: reactRouterNestedAncestors(
routing: reactRouterOutlet(
{
path: "/:username/:workspace/settings/schedule",
},
<WorkspaceSettingsLayout />,
<WorkspaceSchedulePage />,
),
});
}
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy