Skip to content

Commit 75bf41b

Browse files
chore(site): use static date and ignore dynamic values for storybook (#12830)
1 parent 1d2d008 commit 75bf41b

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

site/src/pages/CreateTokenPage/CreateTokenPage.stories.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ const meta: Meta<typeof CreateTokenPage> = {
1212
},
1313
],
1414
},
15+
decorators: [
16+
(Story) => {
17+
Date.now = () => new Date("01/01/2014").getTime();
18+
return <Story />;
19+
},
20+
],
1521
};
1622

1723
export default meta;

site/src/pages/WorkspacePage/WorkspaceTopbar.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22
import { expect, userEvent, waitFor, within, screen } from "@storybook/test";
3-
import { addDays, addHours, addMinutes } from "date-fns";
3+
import { addHours, addMinutes } from "date-fns";
44
import { getWorkspaceQuotaQueryKey } from "api/queries/workspaceQuota";
55
import {
66
MockTemplate,
@@ -159,7 +159,7 @@ export const Dormant: Story = {
159159
args: {
160160
workspace: {
161161
...baseWorkspace,
162-
deleting_at: addDays(new Date(), 7).toISOString(),
162+
deleting_at: new Date("2024/01/01").toISOString(),
163163
latest_build: {
164164
...baseWorkspace.latest_build,
165165
status: "failed",

site/src/pages/WorkspacePage/WorkspaceTopbar.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,7 @@ export const WorkspaceTopbar: FC<WorkspaceProps> = ({
219219
title="Schedule settings"
220220
css={{ color: "inherit" }}
221221
>
222-
Deletion on{" "}
223-
<span data-chromatic="ignore">
224-
{new Date(workspace.deleting_at!).toLocaleString()}
225-
</span>
222+
Deletion on {new Date(workspace.deleting_at!).toLocaleString()}
226223
</Link>
227224
</TopbarData>
228225
)}

0 commit comments

Comments
 (0)