@@ -129,6 +129,18 @@ test("picker, pane drop and clipboard files use the same attachment draft and ex
129129 } ) ;
130130 await expect ( form . getByText ( / R e a d y $ / ) ) . toHaveCount ( 3 ) ;
131131 expect ( uploadRequests ) . toHaveLength ( 3 ) ;
132+ // Real modal focus returns to the navigated generic preview, not its opener.
133+ await form . getByRole ( "button" , { name : "Preview picked.txt" } ) . click ( ) ;
134+ const preview = page . getByRole ( "dialog" , { name : "Attachment preview" } ) ;
135+ await preview . getByRole ( "button" , { name : "Next attachment" } ) . click ( ) ;
136+ await expect (
137+ preview . getByText ( "dropped.txt" , { exact : true } ) . first ( ) ,
138+ ) . toBeVisible ( ) ;
139+ await page . keyboard . press ( "Escape" ) ;
140+ await expect ( preview ) . toHaveCount ( 0 ) ;
141+ await expect (
142+ form . getByRole ( "button" , { name : "Preview dropped.txt" } ) ,
143+ ) . toBeFocused ( ) ;
132144 // Completed eager uploads leave the remove control available.
133145 await expect ( form . locator ( "[data-uploading]" ) ) . toHaveCount ( 0 ) ;
134146 await expect ( remove . locator ( "svg" ) ) . toHaveCount ( 1 ) ;
@@ -567,7 +579,7 @@ test("local previews stay interactive during eager upload and removal collapses
567579 if ( req . url !== "/api/relay/upload" || req . method !== "POST" )
568580 return next ( ) ;
569581 req . resume ( ) ;
570- const status = ++ requests === 1 ? 503 : 204 ;
582+ const status = [ 1 , 4 ] . includes ( ++ requests ) ? 503 : 204 ;
571583 void held . then ( ( ) => {
572584 res . writeHead ( status ) ;
573585 res . end ( ) ;
@@ -914,12 +926,65 @@ test("local previews stay interactive during eager upload and removal collapses
914926 await expect
915927 . poll ( ( ) => form . evaluate ( ( el ) => el . getBoundingClientRect ( ) . height ) )
916928 . toBe ( beforeFailure ) ;
929+ const failedRemove = form . getByRole ( "button" , { name : "Remove photo.png" } ) ;
930+ await expect ( failedRemove ) . toBeVisible ( ) ;
931+ // Both error actions must fit inside the real strip scrollport.
932+ for ( const action of [ retry , failedRemove ] ) {
933+ expect (
934+ await action . evaluate ( ( el ) => {
935+ const control = el . getBoundingClientRect ( ) ;
936+ const strip = el . closest ( "ul" ) . getBoundingClientRect ( ) ;
937+ return Math . min (
938+ control . left - strip . left ,
939+ strip . right - control . right ,
940+ control . top - strip . top ,
941+ ) ;
942+ } ) ,
943+ ) . toBeGreaterThanOrEqual ( 0 ) ;
944+ }
945+ for ( const mode of [ "light" , "dark" ] ) {
946+ await page . evaluate (
947+ ( mode ) =>
948+ document . documentElement . classList . toggle ( "dark" , mode === "dark" ) ,
949+ mode ,
950+ ) ;
951+ for ( const width of [ 390 , 1280 ] ) {
952+ await page . setViewportSize ( { width, height : 800 } ) ;
953+ await page . evaluate ( ( ) => {
954+ document . documentElement . style . fontSize = "200%" ;
955+ } ) ;
956+ await retry . click ( { trial : true } ) ;
957+ await failedRemove . click ( { trial : true } ) ;
958+ }
959+ }
960+ await page . evaluate ( ( ) => {
961+ document . documentElement . style . fontSize = "" ;
962+ } ) ;
963+ await page . setViewportSize ( { width : 1440 , height : 950 } ) ;
917964 await form . screenshot ( {
918965 path : test . info ( ) . outputPath ( "compact-upload-retry.png" ) ,
919966 } ) ;
920967 await retry . click ( ) ;
921968 await expect ( retry ) . toHaveCount ( 0 ) ;
922969 await expect ( form . getByRole ( "progressbar" ) ) . toHaveCount ( 0 ) ;
970+ await form . getByLabel ( "Choose attachments" ) . setInputFiles ( {
971+ name : "failed.txt" ,
972+ mimeType : "text/plain" ,
973+ buffer : Buffer . from ( "failed" ) ,
974+ } ) ;
975+ await expect (
976+ form . getByRole ( "button" , { name : "Retry failed.txt" } ) ,
977+ ) . toBeVisible ( ) ;
978+ await expect (
979+ form . getByRole ( "button" , { name : "Send message" } ) ,
980+ ) . toBeDisabled ( ) ;
981+ await form . getByRole ( "button" , { name : "Remove failed.txt" } ) . click ( ) ;
982+ await expect (
983+ form . getByRole ( "button" , { name : "Retry failed.txt" } ) ,
984+ ) . toHaveCount ( 0 ) ;
985+ await expect (
986+ form . getByRole ( "button" , { name : "Send message" } ) ,
987+ ) . toBeEnabled ( ) ;
923988 await page . emulateMedia ( { reducedMotion : "reduce" } ) ;
924989 await page . evaluate ( ( ) => {
925990 window . reviewTransitions = [ ] ;
0 commit comments