@@ -12,11 +12,12 @@ const sessionID = "ses_mcp_workspace"
1212
1313const title = "Workspace MCP routing"
1414
15- type Surface = "popover" | "dialog"
15+ type Surface = "popover" | "dialog" | "settings"
1616
1717// A session in a worktree of the project. The harness answers the MCP list for each location directory and stores
1818// connect/disconnect results per directory; `requests` records every MCP request and the directory it targeted.
19- // The popover belongs to the summary extension; the dialog (Ctrl+;) is the app's own MCP toggle.
19+ // The popover belongs to the summary extension; the dialog (Ctrl+;) is the app's own MCP toggle; settings is the
20+ // Extensions page opened (Ctrl+,) from the session.
2021async function open ( page : Page , input : { surface : Surface } & Pick < MockServerConfig , "mcp" | "onMcpAction" > ) {
2122 const requests : { path : string ; directory : string } [ ] = [ ]
2223 page . on ( "request" , ( request ) => {
@@ -38,16 +39,32 @@ async function open(page: Page, input: { surface: Surface } & Pick<MockServerCon
3839 await page . goto ( sessionHref ( sessionID ) )
3940 await expectSessionTitle ( page , title )
4041 await expect ( page . getByRole ( "textbox" , { name : "Prompt" , exact : true } ) ) . toBeEditable ( )
41- const panel = page . getByRole ( "dialog" , { name : input . surface === "popover" ? "MCP" : "MCPs" , exact : true } )
42+
43+ const panel =
44+ input . surface === "settings"
45+ ? page . getByTestId ( "settings-screen" )
46+ : page . getByRole ( "dialog" , { name : input . surface === "popover" ? "MCP" : "MCPs" , exact : true } )
4247
4348 const show = async ( ) => {
4449 if ( input . surface === "dialog" ) return page . keyboard . press ( "Control+;" )
50+
51+ if ( input . surface === "settings" ) {
52+ await page . keyboard . press ( "Control+," )
53+
54+ return panel . getByRole ( "tab" , { name : "Extensions" , exact : true } ) . click ( )
55+ }
56+
4557 await page . getByRole ( "button" , { name : "Session details" , exact : true } ) . click ( )
4658 await page . getByRole ( "button" , { name : "MCP" , exact : true } ) . click ( )
4759 }
4860
4961 await show ( )
50- await expect ( panel . getByText ( "figma-desktop" , { exact : true } ) ) . toBeVisible ( )
62+ // The settings row also names its switch with a visually hidden label.
63+ await expect (
64+ input . surface === "settings"
65+ ? panel . getByRole ( "switch" , { name : "figma-desktop" , exact : true } )
66+ : panel . getByText ( "figma-desktop" , { exact : true } ) ,
67+ ) . toBeVisible ( )
5168
5269 return { requests, panel, show, toggle : panel . getByRole ( "switch" ) }
5370}
@@ -93,6 +110,26 @@ for (const shared of [true, false]) {
93110 } )
94111}
95112
113+ test ( "settings shows and toggles the MCP of the session it was opened from" , async ( { page } ) => {
114+ const actions : Parameters < NonNullable < MockServerConfig [ "onMcpAction" ] > > [ 0 ] [ ] = [ ]
115+
116+ const view = await open ( page , {
117+ surface : "settings" ,
118+ mcp : ( target ) => [ { name : "figma-desktop" , status : { status : target === workspace ? "connected" : "disabled" } } ] ,
119+ onMcpAction : ( action ) => void actions . push ( action ) ,
120+ } )
121+
122+ await expect ( view . toggle ) . toBeChecked ( )
123+ await expect ( view . toggle ) . toBeEnabled ( )
124+ view . requests . length = 0
125+
126+ await view . panel . locator ( '[data-slot="switch-control"]' ) . click ( )
127+ await expect ( view . toggle ) . not . toBeChecked ( )
128+ await expect ( view . toggle ) . toBeEnabled ( )
129+ expect ( actions ) . toEqual ( [ { server : "figma-desktop" , action : "disconnect" , directory : workspace } ] )
130+ expect ( view . requests ) . toContainEqual ( { path : "/api/experimental/mcp/figma-desktop/disconnect" , directory : workspace } )
131+ } )
132+
96133for ( const surface of [ "popover" , "dialog" ] as const ) {
97134 test ( `shows connection failures from the MCP ${ surface } and allows reconnecting` , async ( { page } ) => {
98135 const error = "Streamable HTTP error: Error POSTing to endpoint: 404 Not Found"
0 commit comments