mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 20:13:43 +00:00
test(cron): add Asia/Shanghai year-regression coverage [AI-assisted] (openclaw#30565) thanks @liuxiaopai-ai
Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -13,6 +13,20 @@ describe("cron schedule", () => {
|
||||
expect(next).toBe(Date.parse("2025-12-17T17:00:00.000Z"));
|
||||
});
|
||||
|
||||
it("does not roll back year for Asia/Shanghai daily cron schedules (#30351)", () => {
|
||||
// 2026-03-01 08:00:00 in Asia/Shanghai
|
||||
const nowMs = Date.parse("2026-03-01T00:00:00.000Z");
|
||||
const next = computeNextRunAtMs(
|
||||
{ kind: "cron", expr: "0 8 * * *", tz: "Asia/Shanghai" },
|
||||
nowMs,
|
||||
);
|
||||
|
||||
// Next 08:00 local should be the following day, not a past year.
|
||||
expect(next).toBe(Date.parse("2026-03-02T00:00:00.000Z"));
|
||||
expect(next).toBeGreaterThan(nowMs);
|
||||
expect(new Date(next ?? 0).getUTCFullYear()).toBe(2026);
|
||||
});
|
||||
|
||||
it("throws a clear error when cron expr is missing at runtime", () => {
|
||||
const nowMs = Date.parse("2025-12-13T00:00:00.000Z");
|
||||
expect(() =>
|
||||
|
||||
Reference in New Issue
Block a user