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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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;

View File

@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";
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 {
MockTemplate,
@ -159,7 +159,7 @@ export const Dormant: Story = {
args: {
workspace: {
...baseWorkspace,
deleting_at: addDays(new Date(), 7).toISOString(),
deleting_at: new Date("2024/01/01").toISOString(),
latest_build: {
...baseWorkspace.latest_build,
status: "failed",

View File

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