From 618490b2a097c0267da071f5a8a4d93b585ccf93 Mon Sep 17 00:00:00 2001 From: Shaneeza Date: Thu, 18 Jan 2024 14:47:43 -0500 Subject: [PATCH 1/2] remove todays date from DatePickerMenu story --- .../DatePickerMenu/DatePickerMenu.stories.tsx | 57 ++++--------------- 1 file changed, 10 insertions(+), 47 deletions(-) diff --git a/packages/date-picker/src/DatePicker/DatePickerMenu/DatePickerMenu.stories.tsx b/packages/date-picker/src/DatePicker/DatePickerMenu/DatePickerMenu.stories.tsx index 04dfec8fa6..b17a0eddec 100644 --- a/packages/date-picker/src/DatePicker/DatePickerMenu/DatePickerMenu.stories.tsx +++ b/packages/date-picker/src/DatePicker/DatePickerMenu/DatePickerMenu.stories.tsx @@ -78,41 +78,12 @@ export default meta; type DatePickerMenuStoryType = StoryObj; -export const Basic: DatePickerMenuStoryType = { - render: args => { - MockDate.reset(); - const [value, setValue] = useState(null); - - const date = new Date(Date.now()); - const props = omit(args, [...contextPropNames, 'isOpen']); - const refEl = useRef(null); - return ( - -
- - Today:{' '} - {new Intl.DateTimeFormat('en-GB', { - dateStyle: 'full', - }).format(date)} - - -
-
- ); - }, -}; - -Basic.parameters = { - chromatic: { disableSnapshot: true }, -}; - export const WithValue: DatePickerMenuStoryType = { render: args => { MockDate.reset(); const props = omit(args, [...contextPropNames, 'isOpen']); const refEl = useRef(null); - const date = new Date(Date.now()); const withValueDate = new Date(2023, Month.September, 10); return ( {}} >
- - Today:{' '} - {new Intl.DateTimeFormat('en-GB', { - dateStyle: 'full', - }).format(date)} - -

Value:{' '} {new Intl.DateTimeFormat('en-GB', { @@ -156,15 +120,14 @@ export const MockedToday: DatePickerMenuStoryType = { const props = omit(args, [...contextPropNames, 'isOpen']); const refEl = useRef(null); - const date = new Date(Date.now()); return (
- Today:{' '} + Mocked Today:{' '} {new Intl.DateTimeFormat('en-GB', { dateStyle: 'full', - }).format(date)} + }).format(mockToday)}
@@ -188,8 +151,8 @@ type DatePickerMenuInteractionTestType = Omit & * Chromatic Interaction tests */ -export const InitialFocusToday: DatePickerMenuInteractionTestType = { - ...Basic, +export const InitialFocusMockedToday: DatePickerMenuInteractionTestType = { + ...MockedToday, play: async ctx => { const { findByRole } = within(ctx.canvasElement.parentElement!); await findByRole('listbox'); @@ -208,7 +171,7 @@ export const InitialFocusValue: DatePickerMenuInteractionTestType = { export const LeftArrowKey: DatePickerMenuInteractionTestType = { ...WithValue, play: async ctx => { - await InitialFocusToday.play(ctx); + await InitialFocusMockedToday.play(ctx); userEvent.keyboard('{arrowleft}'); }, }; @@ -216,7 +179,7 @@ export const LeftArrowKey: DatePickerMenuInteractionTestType = { export const RightArrowKey: DatePickerMenuInteractionTestType = { ...WithValue, play: async ctx => { - await InitialFocusToday.play(ctx); + await InitialFocusMockedToday.play(ctx); userEvent.keyboard('{arrowright}'); }, }; @@ -224,7 +187,7 @@ export const RightArrowKey: DatePickerMenuInteractionTestType = { export const UpArrowKey: DatePickerMenuInteractionTestType = { ...WithValue, play: async ctx => { - await InitialFocusToday.play(ctx); + await InitialFocusMockedToday.play(ctx); userEvent.keyboard('{arrowup}'); }, }; @@ -232,7 +195,7 @@ export const UpArrowKey: DatePickerMenuInteractionTestType = { export const DownArrowKey: DatePickerMenuInteractionTestType = { ...WithValue, play: async ctx => { - await InitialFocusToday.play(ctx); + await InitialFocusMockedToday.play(ctx); userEvent.keyboard('{arrowdown}'); }, }; @@ -240,7 +203,7 @@ export const DownArrowKey: DatePickerMenuInteractionTestType = { export const UpToPrevMonth: DatePickerMenuInteractionTestType = { ...WithValue, play: async ctx => { - await InitialFocusToday.play(ctx); + await InitialFocusMockedToday.play(ctx); userEvent.keyboard('{arrowup}{arrowup}'); }, }; @@ -248,7 +211,7 @@ export const UpToPrevMonth: DatePickerMenuInteractionTestType = { export const DownToNextMonth: DatePickerMenuInteractionTestType = { ...WithValue, play: async ctx => { - await InitialFocusToday.play(ctx); + await InitialFocusMockedToday.play(ctx); userEvent.keyboard('{arrowdown}{arrowdown}{arrowdown}'); }, }; From a69182eb4c86ba25475e5a9bbf4edf7d6fd93720 Mon Sep 17 00:00:00 2001 From: Shaneeza Date: Thu, 18 Jan 2024 14:50:17 -0500 Subject: [PATCH 2/2] add changeset --- .changeset/fifty-turkeys-battle.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fifty-turkeys-battle.md diff --git a/.changeset/fifty-turkeys-battle.md b/.changeset/fifty-turkeys-battle.md new file mode 100644 index 0000000000..b7b55b36dd --- /dev/null +++ b/.changeset/fifty-turkeys-battle.md @@ -0,0 +1,5 @@ +--- +'@leafygreen-ui/date-picker': patch +--- + +Modify `DatePickerMenu.stories.tsx` to exclude the current date, as it caused daily chromatic changes. \ No newline at end of file