Validate daily schedule start times
Disable schedule activation until the local time input matches a strict HH:MM value. Keep a defensive activation guard that surfaces a localized validation error and skips persistence when invoked with invalid state. Add red-green coverage for empty, malformed, out-of-range hour, and out-of-range minute values.
This commit is contained in:
@@ -791,6 +791,7 @@ function withRuntime(input: DownloadsModelInput, overrides: Partial<DownloadsVie
|
||||
scheduleActive: false,
|
||||
scheduleOpen: false,
|
||||
scheduleTime: "23:30",
|
||||
scheduleTimeValid: true,
|
||||
scheduleStartDay: "today",
|
||||
scheduleLabel: "",
|
||||
packageSpeedBps: { "package-a": 12_000_000 },
|
||||
@@ -1235,6 +1236,15 @@ describe("downloads view", () => {
|
||||
expect(calls).toEqual(["time:09:45", "day:today"]);
|
||||
});
|
||||
|
||||
it.each(["", "8:15", "24:00", "12:60"])("disables schedule activation for the invalid time %j", (scheduleTime) => {
|
||||
const toolbar = DownloadsToolbar({
|
||||
actions: createActions(),
|
||||
model: withRuntime(createInput(), { scheduleOpen: true, scheduleTime, scheduleTimeValid: false })
|
||||
});
|
||||
|
||||
expect(findButton(toolbar, "Planen").props.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it("animates the persistent schedule slot horizontally and disables it through the global motion setting", () => {
|
||||
const closed = renderToStaticMarkup(<DownloadsToolbar actions={createActions()} model={withRuntime(createInput())} />);
|
||||
const open = renderToStaticMarkup(<DownloadsToolbar actions={createActions()} model={withRuntime(createInput(), { scheduleOpen: true })} />);
|
||||
|
||||
Reference in New Issue
Block a user