@@ -59,20 +59,30 @@ describe('OfflineNetworkService connection verification', () => {
5959 expect ( service . checkingConnection ( ) ) . toBe ( false ) ;
6060 } ) ;
6161
62- it ( 'leaves a newer successful observation intact after a status-zero failure and permits retry' , async ( ) => {
62+ it ( 'records a status-zero failure when no newer API observation exists and permits retry' , async ( ) => {
6363 const markApiFailure = vi . spyOn ( service , 'markApiFailure' ) ;
6464 const first = service . verifyConnection ( '/status' ) ;
65- service . markApiSuccess ( ) ;
6665 http . expectOne ( '/status' ) . error ( new ProgressEvent ( 'error' ) ) ;
6766 await expect ( first ) . resolves . toBe ( false ) ;
68- expect ( markApiFailure ) . not . toHaveBeenCalled ( ) ;
69- expect ( service . state ( ) ) . toBe ( 'unverified ' ) ;
67+ expect ( markApiFailure ) . toHaveBeenCalledOnce ( ) ;
68+ expect ( service . state ( ) ) . toBe ( 'offline ' ) ;
7069
7170 const second = service . verifyConnection ( '/status' ) ;
7271 http . expectOne ( '/status' ) . flush ( { } ) ;
7372 await expect ( second ) . resolves . toBe ( true ) ;
7473 } ) ;
7574
75+ it ( 'does not let an older probe failure overwrite a newer successful API observation' , async ( ) => {
76+ const markApiFailure = vi . spyOn ( service , 'markApiFailure' ) ;
77+ const verification = service . verifyConnection ( '/status' ) ;
78+ service . markApiSuccess ( ) ;
79+ http . expectOne ( '/status' ) . error ( new ProgressEvent ( 'error' ) ) ;
80+
81+ await expect ( verification ) . resolves . toBe ( false ) ;
82+ expect ( markApiFailure ) . not . toHaveBeenCalled ( ) ;
83+ expect ( service . state ( ) ) . toBe ( 'unverified' ) ;
84+ } ) ;
85+
7686 it ( 'does not overwrite reachability when a stalled check times out and permits retry' , async ( ) => {
7787 vi . useFakeTimers ( ) ;
7888 const markApiFailure = vi . spyOn ( service , 'markApiFailure' ) ;
0 commit comments