fix: migrate cron payload channel alias

This commit is contained in:
Peter Steinberger
2026-01-09 22:40:51 +01:00
parent bdee50da6b
commit 22b3bd4415
4 changed files with 110 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { describe, expect, it } from "vitest";
import { normalizeCronJobCreate } from "./normalize.js";
describe("normalizeCronJobCreate", () => {
it("maps legacy payload.channel to payload.provider and strips channel", () => {
const normalized = normalizeCronJobCreate({
name: "legacy",
enabled: true,
schedule: { kind: "cron", expr: "* * * * *" },
sessionTarget: "isolated",
wakeMode: "now",
payload: {
kind: "agentTurn",
message: "hi",
deliver: true,
channel: "telegram",
to: "7200373102",
},
}) as unknown as Record<string, unknown>;
const payload = normalized.payload as Record<string, unknown>;
expect(payload.provider).toBe("telegram");
expect("channel" in payload).toBe(false);
});
});