Scheduler: edit, Run now, cron with a preview, and a schedule's runs (#19)
CI / Lint (eslint) (pull_request) Successful in 27s
CI / Test (jest) (pull_request) Successful in 26s
CI / Security (npm audit) (pull_request) Successful in 10s
CI / Scan (secrets, workflows, shell) (pull_request) Failing after 2m45s
CI / Integration (api) (pull_request) Successful in 3m37s
CI / UI (playwright) (pull_request) Successful in 2m51s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m35s
CI / Lint (eslint) (pull_request) Successful in 27s
CI / Test (jest) (pull_request) Successful in 26s
CI / Security (npm audit) (pull_request) Successful in 10s
CI / Scan (secrets, workflows, shell) (pull_request) Failing after 2m45s
CI / Integration (api) (pull_request) Successful in 3m37s
CI / UI (playwright) (pull_request) Successful in 2m51s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m35s
- Edit: PUT /api/scheduled-commands/:id changes a schedule in place (keeping its history) and works out its next run again. The create dialog doubles as the edit dialog. - Run now: POST /api/scheduled-commands/:id/run dispatches at once, records triggered_by, leaves next_run alone, and answers 409 while a previous run is still going. The dispatch body moved out of the scheduler loop into dispatchSchedule() so both share it. - Cron is offered in the dialog, and a preview shows the next three runs and the server time zone they are worked out in (GET /api/scheduled-commands/preview). Errors stay in the dialog. - Runs links to /executions?view=automated&search=scheduler:<name>; Executions now honours ?view= and ?search=. - Create and edit share scheduleInput(), which also checks daily HH:MM. - The dialog's worker list had no styles on this page (it borrows Quick Command's markup); they are now included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
777ab728c0
commit
966c2be5cc
10 files changed
+453
-97
No files matched your search
@@ -268,3 +268,33 @@ describe('definitionErrors (#11)', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('scheduleInput and nextRuns (#19)', () => {
|
||||
const { scheduleInput, nextRuns } = require('../lib/utils');
|
||||
const base = { name: 'n', command: 'true', worker_ids: ['w1'] };
|
||||
|
||||
test('accepts each schedule type and works out the next run', () => {
|
||||
for (const [t, v] of [['interval', '15'], ['hourly', '2'], ['daily', '02:30'], ['cron', '*/5 * * * *']]) {
|
||||
const r = scheduleInput({ ...base, schedule_type: t, schedule_value: v });
|
||||
expect(r.error).toBeUndefined();
|
||||
expect(r.value.next_run.getTime()).toBeGreaterThan(Date.now());
|
||||
}
|
||||
});
|
||||
|
||||
test('says what is wrong', () => {
|
||||
const err = b => scheduleInput({ ...base, ...b }).error;
|
||||
expect(err({ name: ' ' })).toBe('A name is required');
|
||||
expect(err({ worker_ids: [] })).toBe('Pick at least one worker');
|
||||
expect(err({ schedule_type: 'weekly', schedule_value: '1' })).toMatch(/^schedule_type must be one of/);
|
||||
expect(err({ schedule_type: 'interval', schedule_value: '0' })).toBe('The interval must be a whole number above 0');
|
||||
expect(err({ schedule_type: 'daily', schedule_value: '7pm' })).toBe('The time must be HH:MM (24-hour)');
|
||||
expect(err({ schedule_type: 'cron', schedule_value: '99 * * * *' })).toMatch(/^Invalid schedule:/);
|
||||
});
|
||||
|
||||
test('nextRuns steps forward from each run', () => {
|
||||
const from = new Date(2026, 10, 23, 12, 0, 0);
|
||||
expect(nextRuns('interval', '30', 3, from).map(d => d.getTime() - from.getTime())).toEqual([30, 60, 90].map(m => m * 60000));
|
||||
const daily = nextRuns('daily', '02:00', 2, from);
|
||||
expect(daily.map(d => [d.getDate(), d.getHours()])).toEqual([[24, 2], [25, 2]]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user