@@ -7,7 +7,7 @@ const SECOND = TEST_IDENTITIES.bob.pubkey;
77const AMBIGUOUS =
88 "The mention @Scout is ambiguous. Choose a recipient from the mention picker." ;
99
10- async function install ( page : Page , channel = "general" ) {
10+ async function install ( page : Page , channel = "general" , agents = false ) {
1111 await installMockBridge ( page , {
1212 managedAgents :
1313 channel === "watercooler"
@@ -17,10 +17,18 @@ async function install(page: Page, channel = "general") {
1717 status : "running" ,
1818 channelNames : [ "watercooler" ] ,
1919 } ) )
20- : [ ] ,
20+ : agents
21+ ? [ FIRST , SECOND ] . map ( ( pubkey ) => ( {
22+ pubkey,
23+ name : "Scout" ,
24+ status : "running" ,
25+ channelNames : [ channel ] ,
26+ } ) )
27+ : [ ] ,
2128 searchProfiles : [ FIRST , SECOND ] . map ( ( pubkey ) => ( {
2229 pubkey,
2330 displayName : "Scout" ,
31+ isAgent : agents ,
2432 } ) ) ,
2533 } ) ;
2634 await page . goto ( "/" ) ;
@@ -419,12 +427,19 @@ test("editing to a longer typed member drops the original shorter reference", as
419427 await expect ( row ) . toContainText ( "Scout Jones hello" ) ;
420428} ) ;
421429
422- for ( const scale of [ 1 , 1.5 ] ) {
423- test ( `exact-key chips wrap in narrow composer, sent message and reopen at ${ scale } x text` , async ( {
430+ // The default relay directory knows FIRST as an agent; SECOND is a human.
431+ // The agent variant makes SECOND managed too, covering a qualified bot label.
432+ for ( const { kind, scale } of [
433+ { kind : "mixed" , scale : 1 } ,
434+ { kind : "mixed" , scale : 1.5 } ,
435+ { kind : "agent" , scale : 1 } ,
436+ { kind : "agent" , scale : 1.5 } ,
437+ ] ) {
438+ test ( `exact-key ${ kind } chips wrap in narrow composer, sent message and reopen at ${ scale } x text` , async ( {
424439 page,
425440 } , testInfo ) => {
426441 await page . setViewportSize ( { width : 800 , height : 900 } ) ;
427- await install ( page ) ;
442+ await install ( page , "general" , kind === "agent" ) ;
428443 await page . evaluate ( ( scale ) => {
429444 document . documentElement . style . fontSize = `${ 16 * scale } px` ;
430445 } , scale ) ;
@@ -460,6 +475,13 @@ for (const scale of [1, 1.5]) {
460475 host : import ( "@playwright/test" ) . Locator ,
461476 stage : string ,
462477 ) => {
478+ if ( stage === "sent" ) {
479+ await expect ( host . locator ( "[data-mention]" ) ) . toHaveCount ( 2 ) ;
480+ await expect ( host . locator ( "[data-mention]" ) . last ( ) ) . toHaveAttribute (
481+ "data-mention-kind" ,
482+ kind === "agent" ? "agent" : "human" ,
483+ ) ;
484+ }
463485 const result = await geometry ( host ) ;
464486 expect ( result . chips . length ) . toBeGreaterThanOrEqual ( 2 ) ;
465487 expect ( result . scrollWidth ) . toBeLessThanOrEqual ( result . clientWidth + 1 ) ;
@@ -475,7 +497,34 @@ for (const scale of [1, 1.5]) {
475497 expect ( rect . right ) . toBeLessThanOrEqual ( result . width + 1 ) ;
476498 }
477499 }
478- if ( stage !== "sent" ) {
500+ if ( stage === "sent" ) {
501+ for ( const chip of await host . locator ( "[data-mention]" ) . all ( ) ) {
502+ const expectedKind =
503+ kind === "agent" ||
504+ ( await chip . getAttribute ( "data-mention-pubkey" ) ) === FIRST
505+ ? "agent"
506+ : "human" ;
507+ await expect ( chip ) . toHaveAttribute ( "data-mention-kind" , expectedKind ) ;
508+ const leading = chip . locator ( ".inline-chip-leading-fragment" ) ;
509+ await expect ( leading ) . toHaveText ( "Scout" ) ;
510+ const icon = await leading . evaluate ( ( element ) => {
511+ const style = getComputedStyle ( element , "::before" ) ;
512+ return {
513+ display : style . display ,
514+ mask : style . maskImage ,
515+ width : parseFloat ( style . width ) ,
516+ height : parseFloat ( style . height ) ,
517+ } ;
518+ } ) ;
519+ expect ( icon . display ) . toBe ( "block" ) ;
520+ expect ( icon . mask ) . toContain ( "data:image/svg+xml" ) ;
521+ expect ( icon . width ) . toBeGreaterThan ( 0 ) ;
522+ expect ( icon . height ) . toBeGreaterThan ( 0 ) ;
523+ await expect ( leading ) . toHaveClass (
524+ new RegExp ( `inline-chip-icon-${ expectedKind } ` ) ,
525+ ) ;
526+ }
527+ } else {
479528 for ( const prefix of await host
480529 . locator ( ".mention-prefix-hidden" )
481530 . all ( ) ) {
@@ -495,7 +544,7 @@ for (const scale of [1, 1.5]) {
495544 } ) ;
496545 await waitForAnimations ( page ) ;
497546 await page . screenshot ( {
498- path : `test-results/mention-recipients/layout-${ scale } -${ stage } .png` ,
547+ path : `test-results/mention-recipients/layout-${ kind } - ${ scale } -${ stage } .png` ,
499548 } ) ;
500549 } ;
501550 await expect ( input ) . toHaveText ( content ) ;
0 commit comments