Add timezone-aware cron schedules (#1232)
* feat: add timezone-aware cron schedules * chore: normalize schedule timezone property * fix: reject blank schedule timezone in mcp * Stabilize terminal resize browser repro * Fix terminal resize repro row assertions --------- Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
co-authored by
Mohamed Boudra
parent
922a93af2f
commit
632c48fde3
@@ -88,6 +88,19 @@ describe("parseScheduleCreateInput first-run timing", () => {
|
||||
expect(input.runOnCreate).toBe(true);
|
||||
});
|
||||
|
||||
test("--cron with --timezone stores a timezone-aware cadence", () => {
|
||||
const input = parseScheduleCreateInput({
|
||||
...baseCron,
|
||||
timezone: " America/New_York ",
|
||||
});
|
||||
|
||||
expect(input.cadence).toEqual({
|
||||
type: "cron",
|
||||
expression: "0 9 * * *",
|
||||
timezone: "America/New_York",
|
||||
});
|
||||
});
|
||||
|
||||
test("--every with --run-now is rejected as redundant", () => {
|
||||
expect(() => parseScheduleCreateInput({ ...baseOptions, runNow: true })).toThrow(
|
||||
expect.objectContaining({
|
||||
@@ -105,6 +118,15 @@ describe("parseScheduleCreateInput first-run timing", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test("--timezone without --cron is rejected", () => {
|
||||
expect(() => parseScheduleCreateInput({ ...baseOptions, timezone: "Europe/Zurich" })).toThrow(
|
||||
expect.objectContaining({
|
||||
code: "INVALID_TIME_ZONE",
|
||||
message: "--timezone can only be used with --cron",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseScheduleUpdateInput", () => {
|
||||
@@ -151,12 +173,31 @@ describe("parseScheduleUpdateInput", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("parses --cron cadence with --timezone", () => {
|
||||
expect(
|
||||
parseScheduleUpdateInput({
|
||||
id: "abc",
|
||||
cron: "30 9 * * *",
|
||||
timezone: "Europe/Zurich",
|
||||
}),
|
||||
).toEqual({
|
||||
id: "abc",
|
||||
cadence: { type: "cron", expression: "30 9 * * *", timezone: "Europe/Zurich" },
|
||||
});
|
||||
});
|
||||
|
||||
test("rejects passing both --every and --cron", () => {
|
||||
expect(() => parseScheduleUpdateInput({ id: "abc", every: "5m", cron: "0 9 * * *" })).toThrow(
|
||||
expect.objectContaining({ code: "INVALID_CADENCE" }),
|
||||
);
|
||||
});
|
||||
|
||||
test("rejects --timezone without --cron", () => {
|
||||
expect(() => parseScheduleUpdateInput({ id: "abc", timezone: "Europe/Zurich" })).toThrow(
|
||||
expect.objectContaining({ code: "INVALID_TIME_ZONE" }),
|
||||
);
|
||||
});
|
||||
|
||||
test("parses provider/model shorthand and explicit mode", () => {
|
||||
expect(
|
||||
parseScheduleUpdateInput({
|
||||
|
||||
Reference in New Issue
Block a user