Files
ghbot/test/chat-mention-rules.test.ts
wdawdwa 70f964070d feat: isolate comment command handlers and skip bot authors (4.2, 8.1)
- /recheck, /conflict, and @bot now run independently via allSettled
- bot-authored comments are skipped before dispatch to prevent loops
2026-08-22 17:51:45 +08:00

22 lines
1002 B
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { containsBotMention } from "../src/chat/processor.js";
test("bot mention detection accepts configured aliases", () => {
assert.equal(containsBotMention("@bot help me", "ghbot"), true);
assert.equal(containsBotMention("@ghbot please review", "ghbot"), true);
assert.equal(containsBotMention("@ghbot[bot] ping", "ghbot[bot]"), true);
});
test("partial usernames and ordinary text never trigger the bot", () => {
assert.equal(containsBotMention("email me at user@botmail.com", "ghbot"), false);
assert.equal(containsBotMention("the @botanist knows", "ghbot"), false);
assert.equal(containsBotMention("no mention here", "ghbot"), false);
assert.equal(containsBotMention("@anotherbot hi", "ghbot"), false);
});
test("mention detection is case-insensitive", () => {
assert.equal(containsBotMention("@BOT hello", "ghbot"), true);
assert.equal(containsBotMention("@GHBOT[BOT] hello", "ghbot[bot]"), true);
});