test: fix readonly typing regressions in check baseline

This commit is contained in:
Brian Mendonca
2026-02-21 15:11:56 -07:00
committed by Peter Steinberger
parent 0e1aa77928
commit c7c047287e
5 changed files with 39 additions and 16 deletions

View File

@@ -415,6 +415,7 @@ describe("parseLineDirectives", () => {
expectedAltText: "🎵 Bohemian Rhapsody - Queen", expectedAltText: "🎵 Bohemian Rhapsody - Queen",
expectedText: "Now playing:", expectedText: "Now playing:",
expectFooter: true, expectFooter: true,
expectBodyContents: false,
}, },
{ {
name: "minimal", name: "minimal",
@@ -422,6 +423,7 @@ describe("parseLineDirectives", () => {
expectedAltText: "🎵 Unknown Track", expectedAltText: "🎵 Unknown Track",
expectedText: undefined, expectedText: undefined,
expectFooter: false, expectFooter: false,
expectBodyContents: false,
}, },
{ {
name: "paused status", name: "paused status",

View File

@@ -411,14 +411,16 @@ describe("redactConfigSnapshot", () => {
const cfg = redacted as Record<string, Record<string, unknown>>; const cfg = redacted as Record<string, Record<string, unknown>>;
const cfgCustom2 = cfg.custom2 as unknown as unknown[]; const cfgCustom2 = cfg.custom2 as unknown as unknown[];
expect(cfgCustom2.length).toBeGreaterThan(0); expect(cfgCustom2.length).toBeGreaterThan(0);
expect((cfg.custom1.anykey as Record<string, unknown>).mySecret).toBe(REDACTED_SENTINEL); expect(
((cfg.custom1 as Record<string, unknown>).anykey as Record<string, unknown>).mySecret,
).toBe(REDACTED_SENTINEL);
expect((cfgCustom2[0] as Record<string, unknown>).mySecret).toBe(REDACTED_SENTINEL); expect((cfgCustom2[0] as Record<string, unknown>).mySecret).toBe(REDACTED_SENTINEL);
const out = restored as Record<string, Record<string, unknown>>; const out = restored as Record<string, Record<string, unknown>>;
const outCustom2 = out.custom2 as unknown as unknown[]; const outCustom2 = out.custom2 as unknown as unknown[];
expect(outCustom2.length).toBeGreaterThan(0); expect(outCustom2.length).toBeGreaterThan(0);
expect((out.custom1.anykey as Record<string, unknown>).mySecret).toBe( expect(
"this-is-a-custom-secret-value", ((out.custom1 as Record<string, unknown>).anykey as Record<string, unknown>).mySecret,
); ).toBe("this-is-a-custom-secret-value");
expect((outCustom2[0] as Record<string, unknown>).mySecret).toBe( expect((outCustom2[0] as Record<string, unknown>).mySecret).toBe(
"this-is-a-custom-secret-value", "this-is-a-custom-secret-value",
); );
@@ -438,14 +440,16 @@ describe("redactConfigSnapshot", () => {
const cfg = redacted as Record<string, Record<string, unknown>>; const cfg = redacted as Record<string, Record<string, unknown>>;
const cfgCustom2 = cfg.custom2 as unknown as unknown[]; const cfgCustom2 = cfg.custom2 as unknown as unknown[];
expect(cfgCustom2.length).toBeGreaterThan(0); expect(cfgCustom2.length).toBeGreaterThan(0);
expect((cfg.custom1.anykey as Record<string, unknown>).mySecret).toBe(REDACTED_SENTINEL); expect(
((cfg.custom1 as Record<string, unknown>).anykey as Record<string, unknown>).mySecret,
).toBe(REDACTED_SENTINEL);
expect((cfgCustom2[0] as Record<string, unknown>).mySecret).toBe(REDACTED_SENTINEL); expect((cfgCustom2[0] as Record<string, unknown>).mySecret).toBe(REDACTED_SENTINEL);
const out = restored as Record<string, Record<string, unknown>>; const out = restored as Record<string, Record<string, unknown>>;
const outCustom2 = out.custom2 as unknown as unknown[]; const outCustom2 = out.custom2 as unknown as unknown[];
expect(outCustom2.length).toBeGreaterThan(0); expect(outCustom2.length).toBeGreaterThan(0);
expect((out.custom1.anykey as Record<string, unknown>).mySecret).toBe( expect(
"this-is-a-custom-secret-value", ((out.custom1 as Record<string, unknown>).anykey as Record<string, unknown>).mySecret,
); ).toBe("this-is-a-custom-secret-value");
expect((outCustom2[0] as Record<string, unknown>).mySecret).toBe( expect((outCustom2[0] as Record<string, unknown>).mySecret).toBe(
"this-is-a-custom-secret-value", "this-is-a-custom-secret-value",
); );

View File

@@ -724,9 +724,13 @@ describe("discord reaction notification gating", () => {
] as const; ] as const;
for (const testCase of cases) { for (const testCase of cases) {
expect(shouldEmitDiscordReactionNotification(testCase.input), testCase.name).toBe( expect(
testCase.expected, shouldEmitDiscordReactionNotification({
); ...testCase.input,
allowlist: testCase.input.allowlist ? [...testCase.input.allowlist] : undefined,
}),
testCase.name,
).toBe(testCase.expected);
} }
}); });
}); });
@@ -1040,7 +1044,7 @@ describe("discord reaction notification modes", () => {
const guildEntries = makeEntries({ const guildEntries = makeEntries({
[guildId]: { [guildId]: {
reactionNotifications: testCase.reactionNotifications, reactionNotifications: testCase.reactionNotifications,
users: testCase.users, users: testCase.users ? [...testCase.users] : undefined,
}, },
}); });
const listener = new DiscordReactionListener(makeReactionListenerParams({ guildEntries })); const listener = new DiscordReactionListener(makeReactionListenerParams({ guildEntries }));

View File

@@ -847,7 +847,9 @@ describe("normalizeOutboundPayloadsForJson", () => {
]; ];
for (const testCase of cases) { for (const testCase of cases) {
expect(normalizeOutboundPayloadsForJson(testCase.input)).toEqual(testCase.expected); expect(
normalizeOutboundPayloadsForJson(testCase.input.map((payload) => ({ ...payload }))),
).toEqual(testCase.expected);
} }
}); });
}); });
@@ -882,7 +884,13 @@ describe("formatOutboundPayloadLog", () => {
]; ];
for (const testCase of cases) { for (const testCase of cases) {
expect(formatOutboundPayloadLog(testCase.input), testCase.name).toBe(testCase.expected); expect(
formatOutboundPayloadLog({
...testCase.input,
mediaUrls: [...testCase.input.mediaUrls],
}),
testCase.name,
).toBe(testCase.expected);
} }
}); });
}); });

View File

@@ -595,13 +595,18 @@ describe("sendMessageTelegram", () => {
fileName: "video.mp4", fileName: "video.mp4",
}); });
await sendMessageTelegram(chatId, testCase.text, { const opts = {
token: "tok", token: "tok",
api, api,
mediaUrl: "https://example.com/video.mp4", mediaUrl: "https://example.com/video.mp4",
asVideoNote: true, asVideoNote: true,
...testCase.options, ...testCase.options,
}); };
if (opts.buttons) {
opts.buttons = opts.buttons.map((row) => [...row]);
}
await sendMessageTelegram(chatId, testCase.text, opts);
expect(sendVideoNote).toHaveBeenCalledWith( expect(sendVideoNote).toHaveBeenCalledWith(
chatId, chatId,