feat(DateTimeFields): implement free typing time input with dropdown
- Replace default TimePicker field with custom EditableTimeField - Allow free typing with multiple formats (HH:mm, HHmm, H, etc.) - Show dropdown on click while maintaining typing capability - Center-align time input text
This commit is contained in:
committed by
Benoit TELLIER
parent
12776d36a4
commit
627e9bf44b
@@ -66,6 +66,7 @@ describe("DateTimeFields", () => {
|
||||
const startTimeInput = screen.getByTestId("start-time-input");
|
||||
|
||||
fireEvent.change(startTimeInput, { target: { value: "12:00" } });
|
||||
fireEvent.blur(startTimeInput);
|
||||
|
||||
await waitFor(() =>
|
||||
expect(mockHandlers.onStartTimeChange).toHaveBeenCalledWith("12:00")
|
||||
@@ -109,6 +110,7 @@ describe("DateTimeFields", () => {
|
||||
const endTimeInput = screen.getByTestId("end-time-input");
|
||||
|
||||
fireEvent.change(endTimeInput, { target: { value: "08:00" } });
|
||||
fireEvent.blur(endTimeInput);
|
||||
|
||||
await waitFor(() =>
|
||||
expect(mockHandlers.onEndTimeChange).toHaveBeenCalledWith("08:00")
|
||||
@@ -208,11 +210,14 @@ describe("DateTimeFields", () => {
|
||||
const startTimeInput = screen.getByTestId("start-time-input");
|
||||
|
||||
fireEvent.change(startTimeInput, { target: { value: "09:30" } });
|
||||
fireEvent.blur(startTimeInput);
|
||||
|
||||
await waitFor(() =>
|
||||
expect(mockHandlers.onStartTimeChange).toHaveBeenCalledWith("09:30")
|
||||
);
|
||||
expect(mockHandlers.onEndTimeChange).toHaveBeenCalledWith("10:30");
|
||||
await waitFor(() =>
|
||||
expect(mockHandlers.onEndTimeChange).toHaveBeenCalledWith("10:30")
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves 1-hour duration across midnight when changing start time from 22:30 to 23:45", async () => {
|
||||
@@ -228,6 +233,7 @@ describe("DateTimeFields", () => {
|
||||
|
||||
// Change start time from 22:30 to 23:45
|
||||
fireEvent.change(startTimeInput, { target: { value: "23:45" } });
|
||||
fireEvent.blur(startTimeInput);
|
||||
|
||||
await waitFor(() =>
|
||||
expect(mockHandlers.onStartTimeChange).toHaveBeenCalledWith("23:45")
|
||||
|
||||
@@ -406,9 +406,10 @@ describe("CalendarApp integration", () => {
|
||||
fireEvent.change(startDateInput, {
|
||||
target: { value: "08:00" },
|
||||
});
|
||||
fireEvent.blur(startDateInput);
|
||||
});
|
||||
|
||||
// Wait for the 0.1s delay in handleStartTimeChangeWithClose to complete
|
||||
// Wait for blur handler to complete
|
||||
await act(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 150));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user