mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:18:26 +00:00
refactor(test): stabilize case tables and readonly helper inputs
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user