chore(site): use static date and ignore dynamic values for storybook (#12830)

This commit is contained in:
Bruno Quaresma
2024-04-01 11:02:54 -03:00
committed by GitHub
parent 1d2d008b45
commit 75bf41ba02
3 changed files with 9 additions and 6 deletions

View File

@ -12,6 +12,12 @@ const meta: Meta<typeof CreateTokenPage> = {
}, },
], ],
}, },
decorators: [
(Story) => {
Date.now = () => new Date("01/01/2014").getTime();
return <Story />;
},
],
}; };
export default meta; export default meta;

View File

@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react"; import type { Meta, StoryObj } from "@storybook/react";
import { expect, userEvent, waitFor, within, screen } from "@storybook/test"; import { expect, userEvent, waitFor, within, screen } from "@storybook/test";
import { addDays, addHours, addMinutes } from "date-fns"; import { addHours, addMinutes } from "date-fns";
import { getWorkspaceQuotaQueryKey } from "api/queries/workspaceQuota"; import { getWorkspaceQuotaQueryKey } from "api/queries/workspaceQuota";
import { import {
MockTemplate, MockTemplate,
@ -159,7 +159,7 @@ export const Dormant: Story = {
args: { args: {
workspace: { workspace: {
...baseWorkspace, ...baseWorkspace,
deleting_at: addDays(new Date(), 7).toISOString(), deleting_at: new Date("2024/01/01").toISOString(),
latest_build: { latest_build: {
...baseWorkspace.latest_build, ...baseWorkspace.latest_build,
status: "failed", status: "failed",

View File

@ -219,10 +219,7 @@ export const WorkspaceTopbar: FC<WorkspaceProps> = ({
title="Schedule settings" title="Schedule settings"
css={{ color: "inherit" }} css={{ color: "inherit" }}
> >
Deletion on{" "} Deletion on {new Date(workspace.deleting_at!).toLocaleString()}
<span data-chromatic="ignore">
{new Date(workspace.deleting_at!).toLocaleString()}
</span>
</Link> </Link>
</TopbarData> </TopbarData>
)} )}