feat(scheduled-tasks): add cron syntax support to task editor dialog (#1593)

Adds a 'Cron' schedule type option to the scheduled task editor, allowing
users to create and edit cron-based schedules through the UI.

- Add cron expression input with inline validation (cron-parser)
- Show next 4 upcoming run times as a preview
- Provide clickable example chips (every 5min, hourly, Monday 9am, etc.)
- Preserve cron expressions when editing existing cron tasks
- Add cron.ts utility module for validation and next-run computation
- Add i18n keys across all 8 locale files

Closes #1586

Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
Tom Rochette
2026-06-16 11:03:42 +03:00
committed by GitHub
co-authored by Bohdan Triapitsyn
parent e904abda04
commit e402cd75f5
14 changed files with 341 additions and 18 deletions
+29
View File
@@ -0,0 +1,29 @@
import { describe, expect, test } from 'bun:test';
import { getNextRuns, isValidCronExpression } from './cron';
describe('cron helpers', () => {
test('accepts valid cron expressions', () => {
expect(isValidCronExpression('*/5 * * * *').valid).toBe(true);
expect(isValidCronExpression('0 9 * * 1').valid).toBe(true);
expect(isValidCronExpression('0 0 9 * * 1').valid).toBe(true);
});
test('rejects empty and invalid cron expressions', () => {
expect(isValidCronExpression('').valid).toBe(false);
expect(isValidCronExpression(' ').valid).toBe(false);
expect(isValidCronExpression('abc').valid).toBe(false);
expect(isValidCronExpression('61 * * * *').valid).toBe(false);
});
test('returns the requested number of next runs', () => {
const runs = getNextRuns('*/5 * * * *', 'UTC', 3);
expect(runs).toHaveLength(3);
expect(runs.every((run) => run instanceof Date && Number.isFinite(run.getTime()))).toBe(true);
});
test('returns an empty list for invalid expressions', () => {
expect(getNextRuns('not cron', 'UTC')).toEqual([]);
});
});