// One-off: send a sample status-change notification to verify the Lark link. // Run from repo root: `bun scripts/test-notify.ts` import { larkEnabled, sendCard } from "../control-server/src/lark"; import { notifyStatusChange } from "../control-server/src/notify"; import type { Task } from "@bbbug/shared/types"; const now = Date.now(); const sample: Task = { id: "test-" + now, meegoId: "TEST-0001", meegoUrl: "https://meego.feishu.cn/story/detail/0001", title: "[测试] 状态变更通知链路验证", description: "", reproSteps: "", bugType: "ui", platform: "android", difficulty: "medium", stepsClarity: "clear", remark: null, reviewFeedback: null, executionPlan: null, regenContext: null, workspacePath: null, pinned: 0, status: "pending_confirmation", priorityKey: now, creatorEmail: null, creatorLarkId: null, createdAt: now, startedAt: null, finishedAt: null, durationMs: null, totalDurationMs: null, branchName: null, mrUrl: null, logPath: null, beforeEvidencePath: null, afterEvidencePath: null, failureReason: null, attempts: 0, }; console.log("larkEnabled:", larkEnabled()); console.log("LARK_NOTIFY_CHAT_ID:", process.env.LARK_NOTIFY_CHAT_ID || "(unset)"); // Direct send for a clear pass/fail signal (notifyStatusChange swallows errors). const ok = await sendCard("chat_id", process.env.LARK_NOTIFY_CHAT_ID || "", { config: { wide_screen_mode: true }, header: { template: "turquoise", title: { tag: "plain_text", content: "✅ 通知链路自检" } }, elements: [{ tag: "div", text: { tag: "lark_md", content: "这是一条来自 Streamline 的测试消息,用于验证状态变更通知是否能送达本群。" } }], }); console.log("direct sendCard ok:", ok); // Also exercise the real notification path (pending_confirmation card). await notifyStatusChange(sample, "pending_confirmation"); console.log("notifyStatusChange(pending_confirmation) dispatched");