import { describe, expect, it } from "vitest" ;
import {
buildDeliveryFromLegacyPayload,
buildDeliveryPatchFromLegacyPayload,
hasLegacyDeliveryHints,
mergeLegacyDeliveryInto,
normalizeLegacyDeliveryInput,
} from "./doctor-cron-legacy-delivery.js" ;
describe("legacy delivery threadId support" , () => {
it("treats threadId as a legacy delivery hint" , () => {
expect(hasLegacyDeliveryHints({ threadId: "42" })).toBe(true );
expect(hasLegacyDeliveryHints({ threadId: 42 })).toBe(true );
});
it("hydrates threadId into new delivery payloads" , () => {
expect(
buildDeliveryFromLegacyPayload({
channel: "telegram" ,
to: "-100123:topic:42" ,
threadId: 42 ,
}),
).toEqual({
mode: "announce" ,
channel: "telegram" ,
to: "-100123:topic:42" ,
threadId: "42" ,
});
});
it("patches and merges threadId into existing deliveries" , () => {
expect(buildDeliveryPatchFromLegacyPayload({ threadId: "77" })).toEqual({
mode: "announce" ,
threadId: "77" ,
});
expect(
mergeLegacyDeliveryInto(
{ mode: "announce" , channel: "telegram" , to: "-100123" , threadId: "1" },
{ threadId: 77 },
),
).toEqual({
delivery: { mode: "announce" , channel: "telegram" , to: "-100123" , threadId: "77" },
mutated: true ,
});
});
it("strips threadId from legacy payloads after normalization" , () => {
const payload: Record<string, unknown> = {
channel: "telegram" ,
to: "-100123:topic:42" ,
threadId: 42 ,
};
expect(normalizeLegacyDeliveryInput({ payload })).toEqual({
delivery: {
mode: "announce" ,
channel: "telegram" ,
to: "-100123:topic:42" ,
threadId: "42" ,
},
mutated: true ,
});
expect(payload.threadId).toBeUndefined();
});
});
Messung V0.5 in Prozent C=100 H=100 G=100
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-10)
¤
*© Formatika GbR, Deutschland