feat(ui): add an isolated UI SDK lab under devtools
The lab is a dev-only route and a standalone entry so beta SDK patterns stay out of shipped pages while they are evaluated.
This commit is contained in:
12 files changed
+737
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { cronForRule } from "../src/devtools/ui-sdk/schedule-rule.ts";
|
||||
|
||||
test("cronForRule emits canonical cron for guided recurrence patterns", () => {
|
||||
const cases = [
|
||||
[{ cadence: "daily", time: "09:05" }, "5 9 * * *"],
|
||||
[{ cadence: "weekly", time: "08:00", weekdays: [1, 2, 3, 4, 5] }, "0 8 * * 1-5"],
|
||||
[{ cadence: "weekly", time: "23:15", weekdays: [0, 6] }, "15 23 * * 0,6"],
|
||||
[{ cadence: "weekly", time: "08:00", weekdays: [6, 0, 2, 2] }, "0 8 * * 0,2,6"],
|
||||
[{ cadence: "weekly", time: "07:30", weekdays: [0, 1, 2, 3, 4, 5, 6] }, "30 7 * * *"],
|
||||
[{ cadence: "monthly", time: "09:30", day: 31 }, "30 9 31 * *"],
|
||||
] as const;
|
||||
|
||||
for (const [rule, expected] of cases) {
|
||||
assert.equal(cronForRule(rule), expected, JSON.stringify(rule));
|
||||
}
|
||||
});
|
||||
|
||||
test("cronForRule rejects invalid times and incomplete patterns", () => {
|
||||
const cases = [
|
||||
{ cadence: "daily", time: "9:05" },
|
||||
{ cadence: "daily", time: "24:00" },
|
||||
{ cadence: "daily", time: "09:60" },
|
||||
{ cadence: "weekly", time: "09:00", weekdays: [] },
|
||||
{ cadence: "weekly", time: "09:00", weekdays: [7] },
|
||||
{ cadence: "monthly", time: "09:00", day: 0 },
|
||||
{ cadence: "monthly", time: "09:00", day: 32 },
|
||||
] as const;
|
||||
|
||||
for (const rule of cases) {
|
||||
assert.equal(cronForRule(rule), null, JSON.stringify(rule));
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user