fix(frontend): prevent RangeError in TimeAdjuster and add validation to SleepButton
Build Frontend / build (push) Failing after 3m15s

This commit is contained in:
2026-06-02 21:20:38 +02:00
parent 13bc53ea59
commit c371a3d8e8
5 changed files with 53 additions and 0 deletions
+16
View File
@@ -12,6 +12,7 @@ import {
adjustForTimezone,
getLocalOffsetFromReference,
formatDateTime,
toUTCFromLocalInput,
} from '../../src/utils/time';
describe('formatMinutesAfter', () => {
@@ -152,3 +153,18 @@ describe('getLocalOffsetFromReference', () => {
expect(offset).toBe(localMins - refMins);
});
});
describe('toUTCFromLocalInput', () => {
it('converts valid datetime-local string to ISO UTC string', () => {
const input = '2024-01-15T10:00';
// This is tricky because it depends on local timezone.
// But we just want to see if it works for a valid input.
const result = toUTCFromLocalInput(input);
expect(result).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/);
});
it('returns empty string on invalid datetime-local string', () => {
expect(toUTCFromLocalInput('2026-06-0')).toBe('');
});
});