@@ -28,6 +28,33 @@ const c = { id: "ses_tab_c", title: "Tab C session" }
2828
2929test . use ( { serviceWorkers : "block" } )
3030
31+ for ( const locale of [ "en" , "ar" ] as const ) {
32+ test ( `Side bar keeps opposite-direction titles clear of the close affordance in ${ locale } ` , async ( { page } ) => {
33+ await mockWorkspace ( page , {
34+ name : "Mixed direction" ,
35+ sessions : [ { ...a , title : locale === "ar" ? "Project task" : "مهمة المشروع" } ] ,
36+ seed : { locale, tabs : [ a . id ] , settings : { appearance : { tabLayout : "sidebar" } } } ,
37+ } )
38+ await page . goto ( sessionHref ( a . id ) )
39+ const link = page . locator ( `[data-slot="vertical-tabs-sidebar"] a[href="${ sessionHref ( a . id ) } "]` )
40+ await expect ( link ) . toBeVisible ( )
41+ await link . hover ( )
42+ await expect
43+ . poll ( ( ) =>
44+ link . evaluate ( ( element ) => {
45+ const title = element . querySelector ( "[data-titlebar-tab-title]" )
46+ if ( ! title ) throw new Error ( "Missing session title" )
47+ const range = document . createRange ( )
48+ range . selectNodeContents ( title )
49+ const text = range . getBoundingClientRect ( )
50+ const row = element . getBoundingClientRect ( )
51+ return getComputedStyle ( element ) . direction === "rtl" ? text . left - row . left : row . right - text . right
52+ } ) ,
53+ )
54+ . toBeGreaterThan ( 40 )
55+ } )
56+ }
57+
3158test ( "Side bar keeps project history and running sessions separate from the official interface modes" , async ( {
3259 page,
3360} ) => {
@@ -167,6 +194,149 @@ test("sidebar and Home share projects and history without opening session tabs",
167194 )
168195} )
169196
197+ test ( "project headers collapse every session independently of the recent preview and preserve the choice" , async ( {
198+ page,
199+ } ) => {
200+ await mockWorkspace ( page , {
201+ name : "Collapse project" ,
202+ sessions : Array . from ( { length : 7 } , ( _ , index ) => ( { id : `ses_collapse_${ index } ` , title : `Task ${ index } ` } ) ) ,
203+ seed : { tabs : [ ] , settings : { appearance : { tabLayout : "sidebar" } } } ,
204+ } )
205+ await page . goto ( "/" )
206+ const sidebar = page . locator ( '[data-slot="vertical-tabs-sidebar"]' )
207+ const titles = sidebar . locator ( "[data-titlebar-tab-title]" )
208+ const collapse = sidebar . getByRole ( "button" , { name : "Collapse project Collapse project" , exact : true } )
209+ await expect ( titles ) . toHaveCount ( 5 )
210+ await expect ( collapse ) . toHaveAttribute ( "aria-expanded" , "true" )
211+ await collapse . focus ( )
212+ await page . keyboard . press ( "Enter" )
213+ await expect ( titles ) . toHaveCount ( 0 )
214+ await expect ( sidebar . getByRole ( "button" , { name : / S h o w 2 m o r e s e s s i o n s / } ) ) . toHaveCount ( 0 )
215+ await expect ( sidebar . getByRole ( "heading" , { name : "Collapse project" , exact : true } ) ) . toBeVisible ( )
216+ await expect ( sidebar . getByRole ( "region" , { name : "Running sessions" , exact : true } ) ) . toBeVisible ( )
217+ await page . reload ( )
218+ await expect ( titles ) . toHaveCount ( 0 )
219+ await sidebar . getByRole ( "button" , { name : "Expand project Collapse project" , exact : true } ) . click ( )
220+ await expect ( titles ) . toHaveCount ( 5 )
221+ await sidebar . getByRole ( "button" , { name : "Show 2 more sessions in Collapse project" , exact : true } ) . click ( )
222+ await expect ( titles ) . toHaveCount ( 7 )
223+ await collapse . click ( )
224+ await expect ( titles ) . toHaveCount ( 0 )
225+ await sidebar . getByRole ( "button" , { name : "Group sessions By project" , exact : true } ) . click ( )
226+ await page . getByRole ( "option" , { name : "List" , exact : true } ) . click ( )
227+ await expect ( titles ) . toHaveCount ( 7 )
228+ await sidebar . getByRole ( "button" , { name : "Group sessions List" , exact : true } ) . click ( )
229+ await page . getByRole ( "option" , { name : "By project" , exact : true } ) . click ( )
230+ await expect ( titles ) . toHaveCount ( 0 )
231+ await sidebar . getByRole ( "button" , { name : "New session in Collapse project" , exact : true } ) . click ( )
232+ await expect ( collapse ) . toHaveAttribute ( "aria-expanded" , "true" )
233+ await expect ( titles ) . toHaveCount ( 8 )
234+ await expect ( page . locator ( '[data-component="new-session"] [data-action="prompt-project"]' ) ) . toContainText (
235+ "Collapse project" ,
236+ )
237+ } )
238+
239+ test ( "recent parents stay busy while descendants execute and busy icons resume after idle" , async ( { page } ) => {
240+ await page . emulateMedia ( { reducedMotion : "no-preference" } )
241+ const child = { id : "ses_busy_descendant" , title : "Running child" , parentID : a . id }
242+ const grandchild = { id : "ses_busy_grandchild" , title : "Running grandchild" , parentID : child . id }
243+ const workspace = await mockWorkspace ( page , {
244+ name : "Family status" ,
245+ sessions : [
246+ a ,
247+ child ,
248+ grandchild ,
249+ ...Array . from ( { length : 24 } , ( _ , index ) => ( { id : `ses_scroll_${ index } ` , title : `Scroll task ${ index } ` } ) ) ,
250+ ] ,
251+ sessionStatus : { [ grandchild . id ] : { type : "running" } } ,
252+ seed : { tabs : [ ] , settings : { appearance : { tabLayout : "sidebar" , tabGrouping : "none" } } } ,
253+ } )
254+ await page . goto ( "/" )
255+ const sidebar = page . locator ( '[data-slot="vertical-tabs-sidebar"]' )
256+ const tab = sidebar . locator ( `[data-titlebar-tab-slot]:has(a[href="${ sessionHref ( a . id ) } "])` )
257+ const spinner = tab . locator ( '[data-component="activity-ring"]' )
258+ await expect ( tab . locator ( "[data-titlebar-tab]" ) ) . toHaveAttribute ( "data-status" , "busy" )
259+ await expect ( spinner ) . toBeVisible ( )
260+ await spinner . scrollIntoViewIfNeeded ( )
261+ await expect (
262+ page
263+ . locator ( '[data-component="home-session-row"]' )
264+ . filter ( { hasText : a . title } )
265+ . locator ( '[data-component="activity-ring"]' ) ,
266+ ) . toBeVisible ( )
267+ const animations = ( target = spinner ) =>
268+ target . evaluate ( ( element ) =>
269+ element
270+ . getAnimations ( { subtree : true } )
271+ . map ( ( animation ) => ( { state : animation . playState , time : Number ( animation . currentTime ) } ) ) ,
272+ )
273+ await expect . poll ( async ( ) => ( await animations ( ) ) . every ( ( animation ) => animation . state === "running" ) ) . toBe ( true )
274+ const childSpinner = sidebar
275+ . getByRole ( "region" , { name : "Running sessions" , exact : true } )
276+ . getByRole ( "button" )
277+ . filter ( { hasText : grandchild . title } )
278+ . locator ( '[data-component="activity-ring"]' )
279+ await expect
280+ . poll ( async ( ) => {
281+ const values = await animations ( childSpinner )
282+ return values . length > 0 && values . every ( ( animation ) => animation . state === "running" )
283+ } )
284+ . toBe ( true )
285+ await workspace . push ( [
286+ {
287+ id : "evt_family_finish" ,
288+ created : 1700000002000 ,
289+ type : "session.execution.succeeded" ,
290+ durable : { aggregateID : grandchild . id , seq : 1 , version : 1 } ,
291+ data : { sessionID : grandchild . id } ,
292+ } ,
293+ ] )
294+ await expect ( tab . locator ( "[data-titlebar-tab]" ) ) . not . toHaveAttribute ( "data-status" , "busy" )
295+ await workspace . push ( [
296+ {
297+ id : "evt_family_restart" ,
298+ created : 1700000003000 ,
299+ type : "session.execution.started" ,
300+ durable : { aggregateID : grandchild . id , seq : 2 , version : 1 } ,
301+ data : { sessionID : grandchild . id } ,
302+ } ,
303+ ] )
304+ await expect ( spinner ) . toBeVisible ( )
305+ await expect
306+ . poll ( async ( ) => {
307+ const values = await animations ( )
308+ return values . length > 0 && values . every ( ( animation ) => animation . state === "running" )
309+ } )
310+ . toBe ( true )
311+ const time = ( await animations ( ) ) [ 0 ] ! . time
312+ await expect . poll ( async ( ) => ( await animations ( ) ) [ 0 ] ! . time ) . toBeGreaterThan ( time )
313+ const scroll = sidebar . locator ( '[data-slot="vertical-tabs-scroll"]' )
314+ await scroll . evaluate ( ( element ) => {
315+ element . scrollTop = 0
316+ } )
317+ await expect ( spinner ) . toHaveAttribute ( "data-offscreen" , "" )
318+ await spinner . scrollIntoViewIfNeeded ( )
319+ await expect ( spinner ) . not . toHaveAttribute ( "data-offscreen" )
320+ await expect . poll ( async ( ) => ( await animations ( ) ) . every ( ( animation ) => animation . state === "running" ) ) . toBe ( true )
321+ await page . emulateMedia ( { reducedMotion : "reduce" } )
322+ await expect ( page . locator ( "html" ) ) . toHaveAttribute ( "data-motion" , "reduce" )
323+ await expect . poll ( async ( ) => ( await animations ( ) ) . length ) . toBe ( 0 )
324+ await expect . poll ( async ( ) => ( await animations ( childSpinner ) ) . length ) . toBe ( 0 )
325+ await page . emulateMedia ( { reducedMotion : "no-preference" } )
326+ await expect
327+ . poll ( async ( ) => {
328+ const values = await animations ( )
329+ return values . length > 0 && values . every ( ( animation ) => animation . state === "running" )
330+ } )
331+ . toBe ( true )
332+ await expect
333+ . poll ( async ( ) => {
334+ const values = await animations ( childSpinner )
335+ return values . length > 0 && values . every ( ( animation ) => animation . state === "running" )
336+ } )
337+ . toBe ( true )
338+ } )
339+
170340test ( "recent sessions caps each project at five and can reveal a selected overflow session" , async ( { page } ) => {
171341 const large = Array . from ( { length : 10 } , ( _ , index ) => ( { id : `ses_limit_${ index } ` , title : `Large task ${ index } ` } ) )
172342 const small = Array . from ( { length : 3 } , ( _ , index ) => ( {
0 commit comments