fix(frontend): prevent RangeError in TimeAdjuster and add validation to SleepButton
Build Frontend / build (push) Failing after 3m15s
Build Frontend / build (push) Failing after 3m15s
This commit is contained in:
@@ -29,4 +29,18 @@ describe('TimeAdjuster', () => {
|
||||
fireEvent.click(resetButton);
|
||||
expect(handleChange).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('handles invalid date input gracefully (returns empty string)', async () => {
|
||||
// Since we changed the implementation, it should no longer throw.
|
||||
// We can't easily test the useEffect error anymore because it doesn't throw,
|
||||
// but we can check if onTimeChange is called with "" for invalid input.
|
||||
const handleChange = vi.fn();
|
||||
const { container } = render(<TimeAdjuster onTimeChange={handleChange} />);
|
||||
const input = container.querySelector('input');
|
||||
|
||||
fireEvent.change(input!, { target: { value: '2026-06-0' } });
|
||||
// We might need to wait for the effect
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
expect(handleChange).toHaveBeenCalledWith("");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user