File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,23 @@ describe("StatusIcon", () => {
127127 expect ( result . current ) . to . equal ( 0 ) ;
128128 unmount ( ) ;
129129 } ) ;
130+ it ( "should continue progress when waitingForInput is true" , async ( ) => {
131+ const { result, unmount } = renderHook ( ( ) => {
132+ return useStageProgress ( {
133+ ...mockStage ,
134+ state : Result . running ,
135+ startTimeMillis : now - 2_000 ,
136+ previousTotalDurationMillis : 20_000 ,
137+ waitingForInput : true ,
138+ } ) ;
139+ } ) ;
140+ expect ( result . current ) . to . equal ( 10 ) ;
141+ await act ( ( ) => vi . advanceTimersByTime ( 1_000 ) ) ;
142+ expect ( result . current ) . to . equal ( 15 ) ;
143+ await act ( ( ) => vi . advanceTimersByTime ( 1_000 ) ) ;
144+ expect ( result . current ) . to . equal ( 20 ) ;
145+ unmount ( ) ;
146+ } ) ;
130147 } ) ;
131148 describe ( "other states" , function ( ) {
132149 for ( const state in Result ) {
Original file line number Diff line number Diff line change @@ -8,3 +8,20 @@ const IntersectionObserverMock = vi.fn(() => ({
88} ) ) ;
99
1010vi . stubGlobal ( "IntersectionObserver" , IntersectionObserverMock ) ;
11+
12+ // Ensure a functional localStorage implementation for tests that persist user preferences.
13+ if (
14+ ! ( 'localStorage' in window ) ||
15+ typeof window . localStorage ?. getItem !== 'function' ||
16+ typeof window . localStorage ?. setItem !== 'function'
17+ ) {
18+ const store : Record < string , string > = { } ;
19+ const localStoragePolyfill = {
20+ getItem : ( key : string ) => ( key in store ? store [ key ] : null ) ,
21+ setItem : ( key : string , value : string ) => { store [ key ] = String ( value ) ; } ,
22+ removeItem : ( key : string ) => { delete store [ key ] ; } ,
23+ clear : ( ) => { Object . keys ( store ) . forEach ( k => delete store [ k ] ) ; } ,
24+ } ;
25+ // @ts -expect-error override for test environment
26+ window . localStorage = localStoragePolyfill ;
27+ }
You can’t perform that action at this time.
0 commit comments