Skip to content

[BOOKINGSG-9283][ZZ] refactor: migrate date input to linaria#1169

Open
ziggyzet wants to merge 10 commits into
pre-release/v4from
ZZ/B9283
Open

[BOOKINGSG-9283][ZZ] refactor: migrate date input to linaria#1169
ziggyzet wants to merge 10 commits into
pre-release/v4from
ZZ/B9283

Conversation

@ziggyzet
Copy link
Copy Markdown

Checklist

  • Migrated the component styles
    • className is chained correctly with clsx
    • User style prop is set as CSS variable
  • Changes follow the project guidelines in CONVENTIONS_V4.md
    - [ ] Updated Storybook documentation
    - [ ] Added/updated unit tests
  • Added visual tests
    - [ ] Listed breaking changes

});
});

test("Mount (dark mode)", async ({ story }) => {
Copy link
Copy Markdown

@ryan-nguyen-t ryan-nguyen-t May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be more concise to remove "(dark mode)", as it is alr specified in the outer describe block
(same for other sibling blocks)

Suggested change
test("Mount (dark mode)", async ({ story }) => {
test("Mount", async ({ story }) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update the snapshot

Copy link
Copy Markdown

@ryan-nguyen-t ryan-nguyen-t May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that for read-only dark mode, the color of the date and dividers do not change. I track it down to the fact that the hoverValue in standalone-date-input.tsx is always undefined, which cause the dividerHover & baseInputHover classes to not be applied.
Is it fine to setHoverDate for read-only mode in date-input.tsx (in the useEffect) like

       if (readOnly) {
            setHoveredDate(newValue);
        }

?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then in read-only.e2e.tsx can add the story-background class from global.css to make the background dark

Image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idt this is only for readOnly though. Will check what's happening here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to the changes, but lets add await for the toBeFocused lines on the file

Comment on lines +331 to +345
await expect(story.page.getByTestId("form-date-input-short"))
.toMatchAriaSnapshot(`
- group "Short date input":
- group:
- textbox "Date":
- /placeholder: DD
- text: /
- textbox "Month":
- /placeholder: MM
- text: /
- textbox "Year":
- /placeholder: YYYY
`);

await expect(story.page.getByTestId("form-date-input-long"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria snapshots not needed, they were covered in the earlier form variants!

});
});

test("Disabled", async ({ story }) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is now redundant

});
});

test("Read-only", async ({ story }) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this

});
});

test.describe("Error", () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this as well

Comment on lines +672 to +673
await expect(story.getUnavailableDayCell(1)).toBeVisible();
await expect(story.getUnavailableDayCell(25)).toBeVisible();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary checks, since we have the screenshot

Comment on lines +697 to +698
await expect(story.getUnavailableDayCell(10)).toBeVisible();
await expect(story.getUnavailableDayCell(15)).toBeVisible();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

locator: story.locators.dateInput,
});
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant

const [selectedDate, setSelectedDate] = useState<string>("");

return (
<div className={`${styles.story} story-background`}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can exclude this styles.story from the e2e stories, we'll take the default width of the input; grid and mobile will cover the width behaviour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants