import { test, expect } from "bun:test"; import { reviewItemsAwaitingMyToken } from "../src/lib/bitsTokenNudge"; import type { BoardItem } from "../src/types"; const ME = "zhang.san@bytedance.com"; const mk = (over: Record): BoardItem => ({ kind: "bug", id: "x", title: "t", status: "manual_review", mrUrl: null, watchers: [ME], ...over } as unknown as BoardItem); test("名下待复核、没 MR 的 Bug / Feature 才算", () => { const items = [ mk({ id: "bug" }), mk({ id: "feature", kind: "feature" }), mk({ id: "has-mr", mrUrl: "https://bits.bytedance.net/code/x/merge_requests/1" }), mk({ id: "running", status: "fixing" }), mk({ id: "security", kind: "security" }), mk({ id: "others", watchers: ["li.si@bytedance.com", "oc_group"] }), ]; expect(reviewItemsAwaitingMyToken(items, ME).map((it) => it.id)).toEqual(["bug", "feature"]); }); test("邮箱大小写不敏感;没有身份就不提醒", () => { const items = [mk({ watchers: ["Zhang.San@ByteDance.com"] })]; expect(reviewItemsAwaitingMyToken(items, ME)).toHaveLength(1); expect(reviewItemsAwaitingMyToken(items, "")).toHaveLength(0); });