@@ -17,7 +17,11 @@ test.beforeAll(async () => {
1717 } ) ;
1818} ) ;
1919test . afterAll ( async ( ) => { await studio ?. close ( ) ; await rm ( directory , { recursive : true , force : true } ) ; } ) ;
20- async function connect ( page ) {
20+
21+ // Agent configuration lives in the composer, so a connection decision an Agent
22+ // needs before it can answer is stated in that same input region. Run stays the
23+ // only transition that creates message lanes.
24+ async function chooseAgents ( page ) {
2125 await page . goto ( `${ studio . url } /#/compare` ) ;
2226 const open = page . getByRole ( "button" , { name : "Open Project" , exact : true } ) ;
2327 await expect ( open . or ( page . getByRole ( "textbox" , { name : "What should these Agents do?" } ) ) ) . toBeVisible ( ) ;
@@ -26,61 +30,72 @@ async function connect(page) {
2630 await page . getByRole ( "button" , { name : / ^ C h o o s e A g e n t s / } ) . click ( ) ;
2731 for ( const name of [ "Alpha ACP" , "Beta ACP" ] ) await page . getByRole ( "menuitemcheckbox" , { name : new RegExp ( name ) } ) . click ( ) ;
2832 await page . keyboard . press ( "Escape" ) ;
29- // Agent settings prepare inline in the shared composer; Run is the only
30- // transition that creates message lanes and opens the connection panel.
33+ }
34+ async function connectionPanel ( page ) {
35+ const panel = page . locator ( ".live-compare-connection .acp-connection-panel" ) ;
36+ await expect ( panel ) . toBeVisible ( ) ;
37+ return panel ;
38+ }
39+ async function signIn ( panel ) {
40+ await panel . locator ( "details.acp-connection-auth" ) . evaluate ( node => { if ( node instanceof HTMLDetailsElement ) node . open = true ; } ) ;
41+ await panel . getByRole ( "button" , { name : "Fixture login" , exact : true } ) . click ( ) ;
42+ await expect ( panel ) . toContainText ( "Authentication completed." ) ;
43+ }
44+ async function startComparison ( page ) {
3145 await page . getByRole ( "button" , { name : "Run 2 Agents" , exact : true } ) . click ( ) ;
3246 const lanes = page . locator ( ".live-compare-lane" ) ;
33- await expect ( lanes . nth ( 0 ) . getByRole ( "button" , { name : "Browse Agent history" } ) ) . toBeVisible ( ) ;
47+ await expect ( lanes ) . toHaveCount ( 2 ) ;
3448 return [ lanes . nth ( 0 ) , lanes . nth ( 1 ) ] ;
3549}
36- test ( "discover, authenticate, paginate and restore the selected Agent session" , async ( { page } , info ) => {
50+
51+ test ( "discovers, authenticates, paginates and restores the selected Agent session" , async ( { page } , info ) => {
3752 await page . emulateMedia ( { reducedMotion : "reduce" } ) ;
3853 const errors = [ ] ; page . on ( "pageerror" , error => errors . push ( error . message ) ) ; page . on ( "console" , message => { if ( message . type ( ) === "error" ) errors . push ( message . text ( ) ) ; } ) ;
39- const [ alpha , beta ] = await connect ( page ) ;
40- await expect ( beta ) . toContainText ( "This Agent does not support session discovery." ) ;
41- await expect ( beta . getByRole ( "button" , { name : "Browse Agent history" } ) ) . toHaveCount ( 0 ) ;
42- await alpha . getByText ( "Sign in" , { exact : true } ) . click ( ) ;
43- await alpha . getByRole ( "button" , { name : "Fixture login" , exact : true } ) . click ( ) ;
44- await expect ( alpha ) . toContainText ( "Authentication completed." ) ;
45- await alpha . getByRole ( "button" , { name : "Browse Agent history" } ) . click ( ) ;
46- await expect ( alpha . getByTitle ( "fixture-recent" , { exact : true } ) ) . toBeVisible ( ) ;
47- await alpha . getByRole ( "button" , { name : "Load more sessions" } ) . click ( ) ;
48- await expect ( alpha . getByTitle ( "fixture-older" , { exact : true } ) ) . toBeVisible ( ) ;
49- await expect ( alpha . getByRole ( "button" , { name : "Load more sessions" } ) ) . toHaveCount ( 0 ) ;
54+ await chooseAgents ( page ) ;
55+ // Only the Agent that publishes session discovery asks for a connection
56+ // decision; the other prepares straight into its inline settings.
57+ const panel = await connectionPanel ( page ) ;
58+ await expect ( page . locator ( ".acp-connection-panel" ) ) . toHaveCount ( 1 ) ;
59+ await signIn ( panel ) ;
60+ await panel . getByRole ( "button" , { name : "Browse Agent history" } ) . click ( ) ;
61+ await expect ( panel . getByTitle ( "fixture-recent" , { exact : true } ) ) . toBeVisible ( ) ;
62+ await panel . getByRole ( "button" , { name : "Load more sessions" } ) . click ( ) ;
63+ await expect ( panel . getByTitle ( "fixture-older" , { exact : true } ) ) . toBeVisible ( ) ;
64+ await expect ( panel . getByRole ( "button" , { name : "Load more sessions" } ) ) . toHaveCount ( 0 ) ;
5065 for ( const width of [ 1440 , 1024 , 390 ] ) {
5166 await page . setViewportSize ( { width, height : 900 } ) ;
52- const choice = alpha . getByTitle ( "fixture-older" , { exact : true } ) ;
67+ const choice = panel . getByTitle ( "fixture-older" , { exact : true } ) ;
5368 await choice . scrollIntoViewIfNeeded ( ) ; await choice . focus ( ) ; await expect ( choice ) . toBeFocused ( ) ;
5469 expect ( await page . evaluate ( ( ) => document . documentElement . scrollWidth <= innerWidth ) ) . toBe ( true ) ;
5570 await page . screenshot ( { path : info . outputPath ( `connection-${ width } .png` ) , animations : "disabled" } ) ;
5671 }
57- await alpha . getByTitle ( "fixture-older" , { exact : true } ) . press ( "Enter" ) ;
58- await expect ( alpha . locator ( ".acp-turn-status" ) ) . toHaveText ( "Ready" ) ;
59- await expect ( alpha ) . toContainText ( "Loaded fixture session" ) ;
60- await expect ( alpha ) . toContainText ( "session:fixture-older" ) ;
72+ await panel . getByTitle ( "fixture-older" , { exact : true } ) . press ( "Enter" ) ;
73+ const [ alpha ] = await startComparison ( page ) ;
74+ await expect ( alpha . locator ( ".acp-session-events" ) ) . toContainText ( "Loaded fixture session" ) ;
75+ await expect ( alpha . locator ( ".acp-session-events" ) ) . toContainText ( "turn:21 session:fixture-older" ) ;
6176 await alpha . locator ( ".acp-composer textarea" ) . fill ( "one more turn" ) ;
6277 await alpha . locator ( ".acp-composer textarea" ) . press ( "Enter" ) ;
6378 await expect ( alpha ) . toContainText ( "turn:22 session:fixture-older" ) ;
64- await beta . getByRole ( "button" , { name : "Start new session" } ) . click ( ) ;
65- await expect ( beta . locator ( ".acp-turn-status" ) ) . toHaveText ( "Ready" ) ;
66- await alpha . getByRole ( "button" , { name : "Close session" , exact : true } ) . click ( ) ;
67- await beta . getByRole ( "button" , { name : "Close session" , exact : true } ) . click ( ) ;
6879 const records = await Promise . all ( ( await readdir ( join ( directory , "conversations" ) ) ) . filter ( name => name . endsWith ( ".json" ) ) . map ( async name => JSON . parse ( await readFile ( join ( directory , "conversations" , name ) , "utf8" ) ) ) ) ;
6980 const record = records . find ( item => item . snapshot . sessionId === "fixture-older" ) ;
7081 expect ( record ) . toBeDefined ( ) ;
7182 const methods = record . events . filter ( item => item . event . type === "protocol-event" && item . event . direction === "Client → Agent" ) . map ( item => item . event . method ) ;
7283 expect ( methods . filter ( method => method === "session/load" ) ) . toHaveLength ( 1 ) ;
73- expect ( methods ) . not . toContain ( "session/new" ) ;
84+ // The chosen Session is restored, not replaced: the fixture rejects the single
85+ // pre-authentication session/new attempt and none is made again afterwards.
86+ const authIndex = methods . indexOf ( "authenticate" ) ;
87+ expect ( methods . slice ( 0 , authIndex ) ) . toContain ( "session/new" ) ;
88+ expect ( methods . slice ( authIndex ) ) . not . toContain ( "session/new" ) ;
7489 expect ( errors ) . toEqual ( [ ] ) ;
7590} ) ;
7691
7792test ( "closing preparation releases the connection without creating a session" , async ( { page } ) => {
78- const [ alpha , beta ] = await connect ( page ) ;
79- await alpha . getByRole ( "button" , { name : "Close session" , exact : true } ) . click ( ) ;
80- await expect ( alpha . locator ( ".acp-connection-panel" ) ) . toHaveCount ( 0 ) ;
81- await expect ( alpha . locator ( ".acp-composer " ) ) . toHaveCount ( 0 ) ;
82- await beta . getByRole ( "button" , { name : "Close session" , exact : true } ) . click ( ) ;
83- await page . getByRole ( "button" , { name : "New comparison" , exact : true } ) . click ( ) ;
93+ await chooseAgents ( page ) ;
94+ const panel = await connectionPanel ( page ) ;
95+ await panel . getByRole ( "button" , { name : "Close session" , exact : true } ) . click ( ) ;
96+ await expect ( page . locator ( ".acp-connection-panel " ) ) . toHaveCount ( 0 ) ;
97+ await expect ( page . locator ( ".acp-composer" ) ) . toHaveCount ( 0 ) ;
98+ await expect ( page . locator ( ".live-compare-lane" ) ) . toHaveCount ( 0 ) ;
8499 await expect ( page . getByRole ( "textbox" , { name : "What should these Agents do?" } ) ) . toHaveValue ( "Continue the selected conversation" ) ;
85100} ) ;
86101
@@ -97,6 +112,7 @@ test("Debugger returns failed session setup to authentication and retries the or
97112 await page . getByRole ( "button" , { name : "Run" , exact : true } ) . click ( ) ;
98113 const panel = page . locator ( ".acp-connection-panel" ) ;
99114 await expect ( panel . getByRole ( "alert" ) ) . toBeVisible ( ) ;
115+ await panel . locator ( "details.acp-connection-auth" ) . evaluate ( node => { if ( node instanceof HTMLDetailsElement ) node . open = true ; } ) ;
100116 await panel . getByRole ( "button" , { name : "Fixture login" , exact : true } ) . click ( ) ;
101117 await expect ( panel ) . toContainText ( "Authentication completed." ) ;
102118 for ( const width of [ 1440 , 1024 , 390 ] ) {
@@ -106,8 +122,9 @@ test("Debugger returns failed session setup to authentication and retries the or
106122 await page . screenshot ( { path : info . outputPath ( `debugger-connection-${ width } .png` ) } ) ;
107123 }
108124 await panel . getByRole ( "button" , { name : "Start new session" } ) . click ( ) ;
109- await expect ( page . locator ( ".acp-turn-status" ) ) . toHaveText ( "Ready" ) ;
125+ // The simplified composer retired the caption that stated "Ready", so the
126+ // recovered transcript is what proves the retried prompt reached the Agent.
127+ await expect ( page . locator ( ".acp-connection-panel" ) ) . toHaveCount ( 0 ) ;
110128 await expect ( page . locator ( ".acp-session-events" ) ) . toContainText ( "Retry my original prompt" ) ;
111- await page . getByRole ( "button" , { name : "Close session" , exact : true } ) . click ( ) ;
112129 expect ( errors ) . toEqual ( [ ] ) ;
113130} ) ;
0 commit comments