@@ -281,13 +281,50 @@ test.describe("MIDI Studio V2", () => {
281281 }
282282 } ) ;
283283
284- test ( "keeps the Status Clear action aligned with MIDI Studio status layout " , async ( { page } ) => {
284+ test ( "keeps header actions inside section headers " , async ( { page } ) => {
285285 const server = await openMidiStudio ( page ) ;
286286 try {
287287 const clearButton = page . locator ( "#clearStatusButton" ) ;
288+ await expect ( clearButton . locator ( "xpath=ancestor::*[contains(concat(' ', normalize-space(@class), ' '), ' accordion-v2__header ')][1]" ) ) . toHaveAttribute ( "aria-controls" , "statusLogContent" ) ;
289+ await expect ( page . locator ( "#statusLogContent #clearStatusButton" ) ) . toHaveCount ( 0 ) ;
290+ await expect ( page . locator ( ".accordion-v2__header #clearStatusButton" ) ) . toHaveCount ( 1 ) ;
288291 await expect ( clearButton ) . toHaveClass ( / m i d i - s t u d i o - v 2 _ _ s t a t u s - c l e a r - b u t t o n / ) ;
289292 await expect ( clearButton ) . toHaveCSS ( "padding-left" , "0px" ) ;
290293 await expect ( clearButton ) . toHaveCSS ( "padding-right" , "0px" ) ;
294+ expect ( await page . locator ( ".accordion-v2" ) . evaluateAll ( ( sections ) => sections . every ( ( section ) => {
295+ const header = section . querySelector ( ".accordion-v2__header" ) ;
296+ const icon = section . querySelector ( ".accordion-v2__icon" ) ;
297+ return Boolean ( header && icon && header . contains ( icon ) ) ;
298+ } ) ) ) . toBe ( true ) ;
299+ expect ( await page . locator ( "body" ) . evaluate ( ( body ) => Array . from ( body . querySelectorAll ( '[aria-label*="close" i], [title*="close" i], [data-close], .tool-starter__close-button' ) ) . every ( ( control ) => Boolean ( control . closest ( ".accordion-v2__header, .tools-platform-frame__accordion-summary, .is-collapsible__summary" ) ) ) ) ) . toBe ( true ) ;
300+ } finally {
301+ await workspaceV2CoverageReporter . stop ( page ) ;
302+ await server . close ( ) ;
303+ }
304+ } ) ;
305+
306+ test ( "clears status content and preserves accordion open close behavior" , async ( { page } ) => {
307+ const server = await openMidiStudio ( page ) ;
308+ try {
309+ const statusHeader = page . locator ( '.accordion-v2__header[aria-controls="statusLogContent"]' ) ;
310+ await expect ( page . locator ( "#statusLog" ) ) . toHaveValue ( / O K L o a d e d 3 M I D I s o n g s / ) ;
311+ await page . locator ( "#clearStatusButton" ) . click ( ) ;
312+ await expect ( page . locator ( "#statusLog" ) ) . toHaveValue ( "" ) ;
313+ await expect ( statusHeader ) . toHaveAttribute ( "aria-expanded" , "true" ) ;
314+ await expect ( page . locator ( "#statusLogContent" ) ) . toBeVisible ( ) ;
315+ await statusHeader . click ( ) ;
316+ await expect ( statusHeader ) . toHaveAttribute ( "aria-expanded" , "false" ) ;
317+ await expect ( page . locator ( "#statusLogContent" ) ) . toBeHidden ( ) ;
318+ await statusHeader . click ( ) ;
319+ await expect ( statusHeader ) . toHaveAttribute ( "aria-expanded" , "true" ) ;
320+ await expect ( page . locator ( "#statusLogContent" ) ) . toBeVisible ( ) ;
321+ const sourceHeader = page . locator ( '.accordion-v2__header[aria-controls="songSourceContent"]' ) ;
322+ await sourceHeader . click ( ) ;
323+ await expect ( sourceHeader ) . toHaveAttribute ( "aria-expanded" , "false" ) ;
324+ await expect ( page . locator ( "#songSourceContent" ) ) . toBeHidden ( ) ;
325+ await sourceHeader . click ( ) ;
326+ await expect ( sourceHeader ) . toHaveAttribute ( "aria-expanded" , "true" ) ;
327+ await expect ( page . locator ( "#songSourceContent" ) ) . toBeVisible ( ) ;
291328 } finally {
292329 await workspaceV2CoverageReporter . stop ( page ) ;
293330 await server . close ( ) ;
0 commit comments