@@ -338,6 +338,112 @@ describe("zalouser channel policies", () => {
338338 } ) ;
339339 } ) ;
340340
341+ it . each ( [
342+ {
343+ name : "prefixed group target" ,
344+ params : { to : "zalouser:group:group-123" } ,
345+ threadId : "group-123" ,
346+ isGroup : true ,
347+ } ,
348+ {
349+ name : "prefixed direct target inside an ambient group" ,
350+ params : { chatId : "zlu:user:user-456" } ,
351+ threadId : "user-456" ,
352+ isGroup : false ,
353+ } ,
354+ {
355+ name : "explicit group override for a bare identifier" ,
356+ params : { threadId : "bare-group" , isGroup : true } ,
357+ threadId : "bare-group" ,
358+ isGroup : true ,
359+ } ,
360+ {
361+ name : "explicit direct override for a group target" ,
362+ params : { to : "group:override-789" , isGroup : false } ,
363+ threadId : "override-789" ,
364+ isGroup : false ,
365+ } ,
366+ {
367+ name : "ambient group without a target prefix" ,
368+ params : { } ,
369+ threadId : "ambient-group" ,
370+ isGroup : true ,
371+ } ,
372+ {
373+ name : "core-materialized ambient group target" ,
374+ params : { to : "ambient-group" } ,
375+ threadId : "ambient-group" ,
376+ isGroup : true ,
377+ } ,
378+ {
379+ name : "explicit direct target with the ambient group identifier" ,
380+ params : { to : "user:ambient-group" } ,
381+ threadId : "ambient-group" ,
382+ isGroup : false ,
383+ } ,
384+ {
385+ name : "explicit thread target before the fallback target" ,
386+ params : { threadId : "user:priority-123" , to : "group:fallback-456" } ,
387+ threadId : "priority-123" ,
388+ isGroup : false ,
389+ } ,
390+ ] ) ( "routes $name reactions through the canonical target owner" , async ( testCase ) => {
391+ const result = await zalouserMessageActions . handleAction ?.( {
392+ channel : "zalouser" ,
393+ action : "react" ,
394+ params : {
395+ messageId : "111" ,
396+ cliMsgId : "222" ,
397+ emoji : "👍" ,
398+ ...testCase . params ,
399+ } ,
400+ cfg : { channels : { zalouser : { enabled : true , profile : "default" } } } ,
401+ toolContext : {
402+ currentChannelProvider : "zalouser" ,
403+ currentChannelId : "ambient-group" ,
404+ currentChatType : "group" ,
405+ } ,
406+ } ) ;
407+
408+ expect ( mockSendReaction ) . toHaveBeenCalledWith ( {
409+ profile : "default" ,
410+ threadId : testCase . threadId ,
411+ isGroup : testCase . isGroup ,
412+ msgId : "111" ,
413+ cliMsgId : "222" ,
414+ emoji : "👍" ,
415+ remove : false ,
416+ } ) ;
417+ expect ( result ?. details ) . toEqual ( {
418+ messageId : "111" ,
419+ cliMsgId : "222" ,
420+ threadId : testCase . threadId ,
421+ } ) ;
422+ } ) ;
423+
424+ it ( "does not borrow group routing from another channel with the same conversation id" , async ( ) => {
425+ await zalouserMessageActions . handleAction ?.( {
426+ channel : "zalouser" ,
427+ action : "react" ,
428+ params : {
429+ to : "shared-conversation" ,
430+ messageId : "111" ,
431+ cliMsgId : "222" ,
432+ emoji : "👍" ,
433+ } ,
434+ cfg : { channels : { zalouser : { enabled : true , profile : "default" } } } ,
435+ toolContext : {
436+ currentChannelProvider : "slack" ,
437+ currentChannelId : "shared-conversation" ,
438+ currentChatType : "group" ,
439+ } ,
440+ } ) ;
441+
442+ expect ( mockSendReaction ) . toHaveBeenCalledWith (
443+ expect . objectContaining ( { threadId : "shared-conversation" , isGroup : false } ) ,
444+ ) ;
445+ } ) ;
446+
341447 it ( "honors the selected Zalouser account during discovery" , ( ) => {
342448 const actions = zalouserMessageActions ;
343449 const cfg = {
0 commit comments