Skip to content

Commit c27ad35

Browse files
robinmolensvenvandescheur
authored andcommitted
#292 - chore: Stable test results for date range picker
Currently, the date range picker storybook tests finish on an empty selected. With this, the current date is selected as default value. When running chromatic the date range picker components are always flagged as "modified" because the selected date is different then before. By making the date range picker tests finish on a stable predetermined selected date, we ensure that future chromatic tests will result to the same UI and don't trigger false-positive "modified" results.
1 parent 6d0b2a9 commit c27ad35

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/components/form/datepicker/datepicker.stories.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@ export const DateRangePicker: Story = {
136136
await waitFor(testFormDataSerialization.bind(this, ""));
137137
await waitFor(testEventListener.bind(this, ""));
138138

139+
// Test type date.
140+
await userEvent.type(input, "2023/09/14 - 2023/09/15", { delay: 10 });
141+
// Close and re-open the datepicker to update the UI
142+
await userEvent.tab();
143+
await userEvent.click(input, { delay: 10 });
144+
145+
await waitFor(
146+
testFormDataSerialization.bind(this, "2023-09-14/2023-09-15"),
147+
);
148+
await waitFor(testEventListener.bind(this, "09/14/2023 - 09/15/2023"));
149+
139150
async function testFormDataSerialization(expectedDate: string) {
140151
const pre = await canvas.findByRole("log");
141152
const data = JSON.parse(pre?.textContent || "{}");

0 commit comments

Comments
 (0)