@@ -375,9 +375,129 @@ test("shell toggle restores the shared sidebar for Channels and Agents", async (
375375 expect ( help . overflow ) . toBe ( "visible" ) ;
376376 }
377377 const sidebarNode = await sidebar . elementHandle ( ) ;
378- const expandedWidth = await sidebar . evaluate (
379- ( node ) => node . closest ( ".shell-sidebar" ) . getBoundingClientRect ( ) . width ,
380- ) ;
378+ let expandedWidth ;
379+ for ( const viewportWidth of [ 1440 , 800 ] ) {
380+ if ( viewportWidth === 800 ) await handle . press ( "End" ) ;
381+ await page . setViewportSize ( { width : viewportWidth , height : 950 } ) ;
382+ expandedWidth = await sidebar . evaluate (
383+ ( node ) => node . closest ( ".shell-sidebar" ) . getBoundingClientRect ( ) . width ,
384+ ) ;
385+ const gutterWidth = await handle . evaluate ( ( element ) => {
386+ const style = getComputedStyle ( element ) ;
387+ return (
388+ element . getBoundingClientRect ( ) . width +
389+ Number . parseFloat ( style . marginLeft ) +
390+ Number . parseFloat ( style . marginRight )
391+ ) ;
392+ } ) ;
393+ const track = await shellNavigation . evaluate ( ( node ) => {
394+ const style = getComputedStyle ( node ) ;
395+ return {
396+ width : node . getBoundingClientRect ( ) . width ,
397+ property : style . transitionProperty ,
398+ duration : style . transitionDuration ,
399+ } ;
400+ } ) ;
401+ expect ( track . width ) . toBe ( expandedWidth + gutterWidth ) ;
402+ expect ( track . property ) . toContain ( "grid-template-columns" ) ;
403+ expect ( parseFloat ( track . duration ) ) . toBeGreaterThan ( 0 ) ;
404+ const openGap = await page . evaluate ( ( ) => {
405+ const sidebar = document . querySelector ( ".shell-sidebar" ) ;
406+ const main = document . querySelector ( "#main-content" ) ;
407+ if ( ! ( sidebar instanceof HTMLElement ) || ! ( main instanceof HTMLElement ) )
408+ throw new Error ( "Missing shell panels" ) ;
409+ return (
410+ main . getBoundingClientRect ( ) . left -
411+ sidebar . getBoundingClientRect ( ) . right
412+ ) ;
413+ } ) ;
414+ expect ( openGap ) . toBe ( gutterWidth ) ;
415+ // Seek paused real transitions so runner speed cannot hide an immediate jump.
416+ // Pause them when the toggle commits, before any frame: transitionrun arrives
417+ // in a later frame, and a stalled WebKit frame can finish the 220ms transition
418+ // first. Only the track and the sidebar it holds are seeked; the resize help's
419+ // own descendant transitions are unrelated.
420+ for ( const label of [ "Hide Channel sidebar" , "Show Channel sidebar" ] ) {
421+ const samples = await page . evaluate ( async ( label ) => {
422+ const nav = document . querySelector ( "#shell-navigation" ) ;
423+ const sidebar = nav . querySelector ( ".shell-sidebar" ) ;
424+ const button = document . querySelector ( `button[aria-label="${ label } "]` ) ;
425+ const committed = new Promise ( ( resolve ) => {
426+ const observer = new MutationObserver ( ( ) => {
427+ observer . disconnect ( ) ;
428+ // getAnimations() flushes style, so the toggle's transitions exist.
429+ const transitions = [
430+ ...nav . getAnimations ( ) ,
431+ ...sidebar . getAnimations ( ) ,
432+ ] ;
433+ for ( const transition of transitions ) transition . pause ( ) ;
434+ resolve ( transitions ) ;
435+ } ) ;
436+ observer . observe ( nav , {
437+ attributes : true ,
438+ attributeFilter : [ "aria-hidden" ] ,
439+ } ) ;
440+ } ) ;
441+ button . click ( ) ;
442+ const transitions = await committed ;
443+ try {
444+ const properties = transitions . map (
445+ ( transition ) => transition . transitionProperty ,
446+ ) ;
447+ for ( const property of [ "grid-template-columns" , "clip-path" ] )
448+ if ( ! properties . includes ( property ) )
449+ throw new Error ( `Missing ${ property } transition` ) ;
450+ return [ 0 , 0.1 , 0.25 , 0.5 , 0.75 , 1 ] . map ( ( progress ) => {
451+ for ( const transition of transitions )
452+ transition . currentTime =
453+ transition . effect . getTiming ( ) . duration * progress ;
454+ return {
455+ width : nav . getBoundingClientRect ( ) . width ,
456+ sidebar : sidebar . getBoundingClientRect ( ) . width ,
457+ clip : getComputedStyle ( nav ) . clipPath ,
458+ } ;
459+ } ) ;
460+ } finally {
461+ for ( const transition of transitions ) transition . finish ( ) ;
462+ await Promise . all (
463+ transitions . map ( ( transition ) => transition . finished ) ,
464+ ) ;
465+ }
466+ } , label ) ;
467+ const width = expandedWidth + gutterWidth ;
468+ const hiding = label . startsWith ( "Hide" ) ;
469+ // The track leaves its real extent on the first sampled step and crosses
470+ // the midpoint halfway through, instead of stalling behind a larger
471+ // ceiling; the sidebar itself keeps its width and is only clipped.
472+ expect ( samples [ 0 ] . width ) . toBe ( hiding ? width : 0 ) ;
473+ expect ( samples [ 1 ] . width ) . toBeGreaterThan ( 0 ) ;
474+ expect ( samples [ 1 ] . width ) . toBeLessThan ( width ) ;
475+ expect ( Math . abs ( samples [ 3 ] . width - width / 2 ) ) . toBeLessThan ( 1 ) ;
476+ for ( let index = 1 ; index < samples . length ; index ++ ) {
477+ const step = samples [ index ] . width - samples [ index - 1 ] . width ;
478+ expect ( hiding ? - step : step ) . toBeGreaterThan ( 0 ) ;
479+ }
480+ expect ( samples . at ( - 1 ) . width ) . toBe ( hiding ? 0 : width ) ;
481+ for ( const sample of samples ) expect ( sample . sidebar ) . toBe ( expandedWidth ) ;
482+ for ( const sample of samples . slice ( 1 , - 1 ) )
483+ expect ( sample . clip ) . toBe ( "inset(0px)" ) ;
484+ expect ( samples . at ( - 1 ) . clip ) . toBe ( hiding ? "inset(0px)" : "none" ) ;
485+ }
486+
487+ if ( viewportWidth === 800 ) {
488+ expect ( expandedWidth ) . toBeGreaterThan ( 220 ) ;
489+ expect ( expandedWidth ) . toBeLessThan ( 520 ) ;
490+ }
491+ }
492+ await page . setViewportSize ( { width : 1440 , height : 950 } ) ;
493+ await expect
494+ . poll ( ( ) =>
495+ sidebar . evaluate (
496+ ( node ) => node . closest ( ".shell-sidebar" ) . getBoundingClientRect ( ) . width ,
497+ ) ,
498+ )
499+ . toBe ( 520 ) ;
500+ expandedWidth = 520 ;
381501 const gutterWidth = await handle . evaluate ( ( element ) => {
382502 const style = getComputedStyle ( element ) ;
383503 return (
@@ -386,100 +506,6 @@ test("shell toggle restores the shared sidebar for Channels and Agents", async (
386506 Number . parseFloat ( style . marginRight )
387507 ) ;
388508 } ) ;
389- const track = await shellNavigation . evaluate ( ( node ) => {
390- const style = getComputedStyle ( node ) ;
391- return {
392- width : node . getBoundingClientRect ( ) . width ,
393- property : style . transitionProperty ,
394- duration : style . transitionDuration ,
395- } ;
396- } ) ;
397- expect ( track . width ) . toBe ( expandedWidth + gutterWidth ) ;
398- expect ( track . property ) . toContain ( "grid-template-columns" ) ;
399- expect ( parseFloat ( track . duration ) ) . toBeGreaterThan ( 0 ) ;
400- const openGap = await page . evaluate ( ( ) => {
401- const sidebar = document . querySelector ( ".shell-sidebar" ) ;
402- const main = document . querySelector ( "#main-content" ) ;
403- if ( ! ( sidebar instanceof HTMLElement ) || ! ( main instanceof HTMLElement ) )
404- throw new Error ( "Missing shell panels" ) ;
405- return (
406- main . getBoundingClientRect ( ) . left - sidebar . getBoundingClientRect ( ) . right
407- ) ;
408- } ) ;
409- expect ( openGap ) . toBe ( gutterWidth ) ;
410- // Seek paused real transitions so runner speed cannot hide an immediate jump.
411- // Pause them when the toggle commits, before any frame: transitionrun arrives
412- // in a later frame, and a stalled WebKit frame can finish the 220ms transition
413- // first. Only the track and the sidebar it holds are seeked; the resize help's
414- // own descendant transitions are unrelated.
415- for ( const label of [ "Hide Channel sidebar" , "Show Channel sidebar" ] ) {
416- const samples = await page . evaluate ( async ( label ) => {
417- const nav = document . querySelector ( "#shell-navigation" ) ;
418- const sidebar = nav . querySelector ( ".shell-sidebar" ) ;
419- const button = document . querySelector ( `button[aria-label="${ label } "]` ) ;
420- const committed = new Promise ( ( resolve ) => {
421- const observer = new MutationObserver ( ( ) => {
422- observer . disconnect ( ) ;
423- // getAnimations() flushes style, so the toggle's transitions exist.
424- const transitions = [
425- ...nav . getAnimations ( ) ,
426- ...sidebar . getAnimations ( ) ,
427- ] ;
428- for ( const transition of transitions ) transition . pause ( ) ;
429- resolve ( transitions ) ;
430- } ) ;
431- observer . observe ( nav , {
432- attributes : true ,
433- attributeFilter : [ "aria-hidden" ] ,
434- } ) ;
435- } ) ;
436- button . click ( ) ;
437- const transitions = await committed ;
438- try {
439- const properties = transitions . map (
440- ( transition ) => transition . transitionProperty ,
441- ) ;
442- for ( const property of [
443- "grid-template-columns" ,
444- "clip-path" ,
445- "max-width" ,
446- ] )
447- if ( ! properties . includes ( property ) )
448- throw new Error ( `Missing ${ property } transition` ) ;
449- return [ 0 , 0.1 , 0.25 , 0.5 , 0.75 , 1 ] . map ( ( progress ) => {
450- for ( const transition of transitions )
451- transition . currentTime =
452- transition . effect . getTiming ( ) . duration * progress ;
453- return {
454- width : nav . getBoundingClientRect ( ) . width ,
455- sidebar : sidebar . getBoundingClientRect ( ) . width ,
456- clip : getComputedStyle ( nav ) . clipPath ,
457- } ;
458- } ) ;
459- } finally {
460- for ( const transition of transitions ) transition . finish ( ) ;
461- await Promise . all ( transitions . map ( ( transition ) => transition . finished ) ) ;
462- }
463- } , label ) ;
464- const width = expandedWidth + gutterWidth ;
465- const hiding = label . startsWith ( "Hide" ) ;
466- // The track leaves its real extent on the first sampled step and crosses
467- // the midpoint halfway through, instead of stalling behind a larger
468- // ceiling; the sidebar itself keeps its width and is only clipped.
469- expect ( samples [ 0 ] . width ) . toBe ( hiding ? width : 0 ) ;
470- expect ( samples [ 1 ] . width ) . toBeGreaterThan ( 0 ) ;
471- expect ( samples [ 1 ] . width ) . toBeLessThan ( width ) ;
472- expect ( Math . abs ( samples [ 3 ] . width - width / 2 ) ) . toBeLessThan ( 1 ) ;
473- for ( let index = 1 ; index < samples . length ; index ++ ) {
474- const step = samples [ index ] . width - samples [ index - 1 ] . width ;
475- expect ( hiding ? - step : step ) . toBeGreaterThan ( 0 ) ;
476- }
477- expect ( samples . at ( - 1 ) . width ) . toBe ( hiding ? 0 : width ) ;
478- for ( const sample of samples ) expect ( sample . sidebar ) . toBe ( expandedWidth ) ;
479- for ( const sample of samples . slice ( 1 , - 1 ) )
480- expect ( sample . clip ) . toBe ( "inset(0px)" ) ;
481- expect ( samples . at ( - 1 ) . clip ) . toBe ( hiding ? "inset(0px)" : "none" ) ;
482- }
483509
484510 await page . emulateMedia ( { reducedMotion : "reduce" } ) ;
485511 await expect
0 commit comments