File tree Expand file tree Collapse file tree
packages/data-table/src/scroll/tests/browser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,9 +106,14 @@ describe('loading slots', () => {
106106
107107 test ( 'refresh overlay appears during action-driven re-fetch and clears on success' , async ( ) => {
108108 let modelHandle : DataModelHandle < Item >
109+ const refreshRequest = Promise . withResolvers < void > ( )
109110 const fetch = vi . fn ( async ( params : AppendFetchParams ) => {
110- await delay ( 25 )
111111 const filterParams = params . params as FilterParams
112+ if ( filterParams . filter ) {
113+ await refreshRequest . promise
114+ } else {
115+ await delay ( 25 )
116+ }
112117 const base = Array . from ( { length : 20 } , ( _ , index ) => ( {
113118 id : index ,
114119 name : filterParams . filter ? `${ filterParams . filter } -${ index } ` : `item-${ index } ` ,
@@ -159,9 +164,12 @@ describe('loading slots', () => {
159164
160165 modelHandle ! . send ( { action : 'filter' , payload : 'books' , viewId : 'default' } )
161166
167+ await expect . poll ( ( ) => fetch . mock . calls . some ( ( c ) => ( c [ 0 ] . params as FilterParams ) . filter === 'books' ) ) . toBe ( true )
162168 await expect . poll ( ( ) => screen . container . querySelector ( '[data-testid=loading-overlay]' ) ?. textContent ?? null ) . toBe ( 'loading' )
163169 expect ( screen . container . textContent ) . toContain ( 'item-0' )
164170
171+ refreshRequest . resolve ( )
172+
165173 await expect . poll ( ( ) => screen . container . querySelector ( '[data-testid=loading-overlay]' ) ) . toBeNull ( )
166174 await expect . poll ( ( ) => screen . container . textContent ?. includes ( 'books-0' ) ?? false ) . toBe ( true )
167175 } )
You can’t perform that action at this time.
0 commit comments