@@ -93,26 +93,27 @@ async function waitForConnected(window) {
9393 . poll (
9494 async ( ) =>
9595 window . evaluate ( async ( ) => {
96- const statusResult = await window . appAPI . checkServerStatus ( ) ;
9796 const startupStatus = await window . appAPI . getStartupStatus ( ) ;
9897 return {
99- connected : Boolean ( statusResult ?. success ) ,
100- error : statusResult ?. error || '' ,
101- startupState : startupStatus ?. state || 'unknown' ,
102- startupMessage : startupStatus ?. message || '' ,
103- label : document . getElementById ( 'server-status' ) ?. textContent || ''
98+ state : startupStatus ?. state || 'unknown' ,
99+ message : startupStatus ?. message || ''
104100 } ;
105101 } ) ,
106102 { timeout : 50000 }
107103 )
108- . toMatchObject ( { connected : true } ) ;
109-
110- await expect
111- . poll (
112- ( ) => window . evaluate ( ( ) => document . getElementById ( 'server-status' ) ?. textContent || '' ) ,
113- { timeout : 10000 }
114- )
115- . toContain ( 'Connected' ) ;
104+ . toMatchObject ( { state : 'ready' } ) ;
105+
106+ // Best-effort status refresh to update renderer badges before UI interactions.
107+ await window . evaluate ( async ( ) => {
108+ try {
109+ await Promise . race ( [
110+ window . appAPI . checkServerStatus ( ) ,
111+ new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) )
112+ ] ) ;
113+ } catch ( error ) {
114+ // Startup readiness is the source of truth for test setup.
115+ }
116+ } ) ;
116117}
117118
118119test . describe ( 'DeepSeek OCR Electron E2E' , ( ) => {
0 commit comments