refactor(test): stabilize case tables and readonly helper inputs

This commit is contained in:
Peter Steinberger
2026-02-22 00:00:53 +01:00
parent 03586e3d00
commit 8752203f59
11 changed files with 106 additions and 52 deletions

View File

@@ -1,5 +1,6 @@
import { ChannelType, type Guild } from "@buape/carbon";
import { describe, expect, it, vi } from "vitest";
import { typedCases } from "../test-utils/typed-cases.js";
import {
allowListMatches,
buildDiscordMediaPayload,
@@ -637,7 +638,11 @@ describe("discord autoThread name sanitization", () => {
describe("discord reaction notification gating", () => {
it("applies mode-specific reaction notification rules", () => {
const cases = [
const cases = typedCases<{
name: string;
input: Parameters<typeof shouldEmitDiscordReactionNotification>[0];
expected: boolean;
}>([
{
name: "unset defaults to own (author is bot)",
input: {
@@ -721,7 +726,7 @@ describe("discord reaction notification gating", () => {
},
expected: true,
},
] as const;
]);
for (const testCase of cases) {
expect(
@@ -963,7 +968,18 @@ describe("discord reaction notification modes", () => {
const guild = fakeGuild(guildId, "Mode Guild");
it("applies message-fetch behavior across notification modes and channel types", async () => {
const cases = [
const cases = typedCases<{
name: string;
reactionNotifications: "off" | "all" | "allowlist" | "own";
users: string[] | undefined;
userId: string | undefined;
channelType: ChannelType;
channelId: string | undefined;
parentId: string | undefined;
messageAuthorId: string;
expectedMessageFetchCalls: number;
expectedEnqueueCalls: number;
}>([
{
name: "off mode",
reactionNotifications: "off" as const,
@@ -1024,7 +1040,7 @@ describe("discord reaction notification modes", () => {
expectedMessageFetchCalls: 0,
expectedEnqueueCalls: 1,
},
] as const;
]);
for (const testCase of cases) {
enqueueSystemEventSpy.mockClear();