@@ -9,14 +9,15 @@ import { createWhatsAppStatusReactionController } from "./status-reaction.js";
99
1010const hoisted = vi . hoisted ( ( ) => ( {
1111 sendReactionWhatsApp : vi . fn ( async ( ) => undefined ) ,
12+ resolveGroupActivationFor : vi . fn ( async ( ) : Promise < "always" | "mention" > => "always" ) ,
1213} ) ) ;
1314
1415vi . mock ( "../../send.js" , ( ) => ( {
1516 sendReactionWhatsApp : hoisted . sendReactionWhatsApp ,
1617} ) ) ;
1718
1819vi . mock ( "./group-activation.js" , ( ) => ( {
19- resolveGroupActivationFor : vi . fn ( async ( ) => "always" ) ,
20+ resolveGroupActivationFor : hoisted . resolveGroupActivationFor ,
2021} ) ) ;
2122
2223type TestMsgOverrides = NonNullable < Parameters < typeof createTestWebInboundMessage > [ 0 ] > ;
@@ -233,6 +234,65 @@ describe("maybeSendAckReaction", () => {
233234 expectAckReactionSent ( "work" , cfg ) ;
234235 } ) ;
235236
237+ it . each ( [
238+ {
239+ name : "acks a mentioned group message" ,
240+ scope : "group-mentions" ,
241+ activation : "mention" ,
242+ wasMentioned : true ,
243+ expected : true ,
244+ } ,
245+ {
246+ name : "skips an unmentioned inactive group message" ,
247+ scope : "group-mentions" ,
248+ activation : "mention" ,
249+ wasMentioned : false ,
250+ expected : false ,
251+ } ,
252+ {
253+ name : "acks an activated group without a literal mention" ,
254+ scope : "group-mentions" ,
255+ activation : "always" ,
256+ wasMentioned : false ,
257+ expected : true ,
258+ } ,
259+ {
260+ name : "acks every group message under group-all" ,
261+ scope : "group-all" ,
262+ activation : "mention" ,
263+ wasMentioned : false ,
264+ expected : true ,
265+ } ,
266+ {
267+ name : "keeps direct-only scope out of groups" ,
268+ scope : "direct" ,
269+ activation : "always" ,
270+ wasMentioned : true ,
271+ expected : false ,
272+ } ,
273+ ] as const ) ( "$name" , async ( { scope, activation, wasMentioned, expected } ) => {
274+ const cfg = createConfig ( "ack" ) ;
275+ cfg . messages ! . ackReactionScope = scope ;
276+ hoisted . resolveGroupActivationFor . mockResolvedValue ( activation ) ;
277+
278+ const ackReaction = await runAckReaction ( {
279+ cfg,
280+ msg : createMessage ( {
281+ platform :
{ chatJid :
"[email protected] " } , 282+ admission : {
283+ conversation :
{ kind :
"group" , id :
"[email protected] " } , 284+ } ,
285+ groupMention : { wasMentioned, requireMention : true } ,
286+ } ) ,
287+ sessionKey :
"whatsapp:default:[email protected] " , 288+ } ) ;
289+
290+ expect ( Boolean ( ackReaction ) ) . toBe ( expected ) ;
291+ if ( ackReaction ) {
292+ await expect ( ackReaction . ackReactionPromise ) . resolves . toBe ( true ) ;
293+ }
294+ } ) ;
295+
236296 it ( "uses the canonical emoji preserved from agent identity" , async ( ) => {
237297 const cfg = {
238298 agents : {
0 commit comments