Skip to content

Commit 09f348d

Browse files
committed
Stabilize loading overlay browser test
1 parent 782aae7 commit 09f348d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

packages/data-table/src/scroll/tests/browser/loading-slots.test.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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
})

0 commit comments

Comments
 (0)