test: cover explicit mention gating across channels
This commit is contained in:
45
src/auto-reply/reply/mentions.test.ts
Normal file
45
src/auto-reply/reply/mentions.test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { matchesMentionWithExplicit } from "./mentions.js";
|
||||
|
||||
describe("matchesMentionWithExplicit", () => {
|
||||
const mentionRegexes = [/\bclawd\b/i];
|
||||
|
||||
it("prefers explicit mentions when other mentions are present", () => {
|
||||
const result = matchesMentionWithExplicit({
|
||||
text: "@clawd hello",
|
||||
mentionRegexes,
|
||||
explicit: {
|
||||
hasAnyMention: true,
|
||||
isExplicitlyMentioned: false,
|
||||
canResolveExplicit: true,
|
||||
},
|
||||
});
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true when explicitly mentioned even if regexes do not match", () => {
|
||||
const result = matchesMentionWithExplicit({
|
||||
text: "<@123456>",
|
||||
mentionRegexes: [],
|
||||
explicit: {
|
||||
hasAnyMention: true,
|
||||
isExplicitlyMentioned: true,
|
||||
canResolveExplicit: true,
|
||||
},
|
||||
});
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("falls back to regex matching when explicit mention cannot be resolved", () => {
|
||||
const result = matchesMentionWithExplicit({
|
||||
text: "clawd please",
|
||||
mentionRegexes,
|
||||
explicit: {
|
||||
hasAnyMention: true,
|
||||
isExplicitlyMentioned: false,
|
||||
canResolveExplicit: false,
|
||||
},
|
||||
});
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user