@@ -911,9 +911,20 @@ suite.define(() => {
911911 await expect . poll ( ( ) => navigation . getAttribute ( "class" ) ) . not . toContain ( "nav-drawer" ) ;
912912 } ) ;
913913
914- it . each ( [ "dark" , "light" ] as const ) (
915- "keeps the toast above the mobile drawer in %s mode" ,
916- async ( colorScheme ) => {
914+ it . each ( [
915+ {
916+ colorScheme : "dark" ,
917+ finalLayout : "compact" ,
918+ finalViewport : { height : 844 , width : 390 } ,
919+ } ,
920+ {
921+ colorScheme : "light" ,
922+ finalLayout : "desktop" ,
923+ finalViewport : { height : 900 , width : 1280 } ,
924+ } ,
925+ ] as const ) (
926+ "keeps drawer toast actionable and handed-off toast clear of chat chrome in $finalLayout $colorScheme mode" ,
927+ async ( { colorScheme, finalLayout, finalViewport } ) => {
917928 const page = await openPage ( {
918929 colorScheme,
919930 height : 844 ,
@@ -937,31 +948,68 @@ suite.define(() => {
937948 const toast = host . locator ( ".app-toast" ) ;
938949 await toast . waitFor ( ) ;
939950 await expect . poll ( ( ) => toast . textContent ( ) ) . toContain ( "Codex hidden" ) ;
951+ const drawerToastGeometry = await host . evaluate ( ( node ) => {
952+ const toastElement = node . querySelector < HTMLElement > ( ".app-toast" ) ;
953+ return {
954+ computedTop : toastElement
955+ ? Math . round ( Number . parseFloat ( getComputedStyle ( toastElement ) . top ) )
956+ : null ,
957+ placement : node . dataset . toastPlacement ,
958+ } ;
959+ } ) ;
960+ expect ( drawerToastGeometry . placement ) . toBe ( "overlay" ) ;
961+ expect ( drawerToastGeometry . computedTop ) . toBe ( 20 ) ;
940962 const dismiss = toast . getByRole ( "button" , { name : "Dismiss" } ) ;
941963 await dismiss . click ( { trial : true } ) ;
942964
943965 await page . screenshot ( {
944966 animations : "disabled" ,
945967 path : path . join ( TOAST_PROOF_DIR , `mobile-drawer-toast-${ colorScheme } .png` ) ,
946968 } ) ;
947- if ( colorScheme === "dark " ) {
969+ if ( finalLayout === "compact " ) {
948970 await page . keyboard . press ( "Escape" ) ;
949971 await expect . poll ( ( ) => dialog . isVisible ( ) ) . toBe ( false ) ;
950972 } else {
951- await page . setViewportSize ( { width : 1280 , height : 900 } ) ;
973+ await page . setViewportSize ( finalViewport ) ;
952974 await expect . poll ( ( ) => drawer . count ( ) ) . toBe ( 0 ) ;
953975 }
954- const retainedToast = page . locator ( ".shell > openclaw-toast-host .app-toast" ) ;
976+ expect ( page . viewportSize ( ) ) . toEqual ( finalViewport ) ;
977+ const retainedHost = page . locator ( ".shell > openclaw-toast-host" ) ;
978+ await expect . poll ( ( ) => retainedHost . getAttribute ( "data-toast-placement" ) ) . toBe ( "shell" ) ;
979+ const retainedToast = retainedHost . locator ( ".app-toast" ) ;
955980 await expect . poll ( ( ) => retainedToast . textContent ( ) ) . toContain ( "Codex hidden" ) ;
956- const [ toastBounds , composerBounds ] = await Promise . all ( [
957- retainedToast . boundingBox ( ) ,
958- page . locator ( ".agent-chat__composer-shell" ) . boundingBox ( ) ,
959- ] ) ;
960- if ( ! toastBounds || ! composerBounds ) {
961- throw new Error ( "expected the handed-off toast and chat composer to have layout boxes" ) ;
981+ if ( finalLayout === "compact" ) {
982+ await expect
983+ . poll ( async ( ) => {
984+ const [ toastBounds , headerBounds ] = await Promise . all ( [
985+ retainedToast . boundingBox ( ) ,
986+ page . locator ( ".chat-pane__header:visible" ) . first ( ) . boundingBox ( ) ,
987+ ] ) ;
988+ return Boolean (
989+ toastBounds && headerBounds && toastBounds . y >= headerBounds . y + headerBounds . height ,
990+ ) ;
991+ } )
992+ . toBe ( true ) ;
993+ } else {
994+ await expect
995+ . poll ( async ( ) => Math . round ( ( await retainedToast . boundingBox ( ) ) ?. y ?? - 1 ) )
996+ . toBe ( 20 ) ;
962997 }
963- expect ( Math . round ( toastBounds . y ) ) . toBe ( 20 ) ;
964- expect ( toastBounds . y + toastBounds . height ) . toBeLessThan ( composerBounds . y ) ;
998+ await expect
999+ . poll ( async ( ) => {
1000+ const [ toastBounds , composerBounds ] = await Promise . all ( [
1001+ retainedToast . boundingBox ( ) ,
1002+ page . locator ( ".agent-chat__composer-shell" ) . boundingBox ( ) ,
1003+ ] ) ;
1004+ return Boolean (
1005+ toastBounds && composerBounds && toastBounds . y + toastBounds . height < composerBounds . y ,
1006+ ) ;
1007+ } )
1008+ . toBe ( true ) ;
1009+ await page . screenshot ( {
1010+ animations : "disabled" ,
1011+ path : path . join ( TOAST_PROOF_DIR , `handed-off-toast-${ finalLayout } -${ colorScheme } .png` ) ,
1012+ } ) ;
9651013 await retainedToast . getByRole ( "button" , { name : "Dismiss" } ) . click ( ) ;
9661014 await expect . poll ( ( ) => retainedToast . isVisible ( ) ) . toBe ( false ) ;
9671015 } ,
0 commit comments