Skip to content

Commit d982fe9

Browse files
committed
test: harden action callback timing in resumable suite
1 parent 243a5b5 commit d982fe9

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

test/resumable.test.ts

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,15 @@ describe('reactify$', () => {
167167
}),
168168
container,
169169
)
170-
const actionButton = await waitForElement<HTMLButtonElement>(container, '#action-button')
171-
actionButton.click()
172-
await tick(30)
173-
174-
expect(actionHost.__FICT_REACT_ACTION_CALLS__).toEqual(['clicked:run'])
175-
176-
dispose()
170+
try {
171+
const actionButton = await waitForElement<HTMLButtonElement>(container, '#action-button')
172+
actionButton.click()
173+
await waitForExpectation(() => {
174+
expect(actionHost.__FICT_REACT_ACTION_CALLS__).toEqual(['clicked:run'])
175+
})
176+
} finally {
177+
dispose()
178+
}
177179
})
178180

179181
it('materializes configured non-onX action props from reactify$ options', async () => {
@@ -205,16 +207,18 @@ describe('reactify$', () => {
205207
}),
206208
container,
207209
)
208-
const customActionButton = await waitForElement<HTMLButtonElement>(
209-
container,
210-
'#custom-action-button',
211-
)
212-
customActionButton.click()
213-
await tick(30)
214-
215-
expect(actionHost.__FICT_REACT_ACTION_CALLS__).toEqual(['custom:option'])
216-
217-
dispose()
210+
try {
211+
const customActionButton = await waitForElement<HTMLButtonElement>(
212+
container,
213+
'#custom-action-button',
214+
)
215+
customActionButton.click()
216+
await waitForExpectation(() => {
217+
expect(actionHost.__FICT_REACT_ACTION_CALLS__).toEqual(['custom:option'])
218+
})
219+
} finally {
220+
dispose()
221+
}
218222
})
219223

220224
it('recovers from transient component load failures with bounded backoff retries', async () => {
@@ -403,13 +407,15 @@ describe('installReactIslands', () => {
403407
document.body.appendChild(host)
404408

405409
const stop = installReactIslands()
406-
await tick(30)
407-
;(host.querySelector('#action-button') as HTMLButtonElement).click()
408-
await tick(30)
409-
410-
expect(actionHost.__FICT_REACT_ACTION_CALLS__).toEqual(['clicked:loader'])
411-
412-
stop()
410+
try {
411+
await tick(30)
412+
;(host.querySelector('#action-button') as HTMLButtonElement).click()
413+
await waitForExpectation(() => {
414+
expect(actionHost.__FICT_REACT_ACTION_CALLS__).toEqual(['clicked:loader'])
415+
})
416+
} finally {
417+
stop()
418+
}
413419
})
414420

415421
it('loader materializes configured non-onX action props from host attributes', async () => {
@@ -436,13 +442,15 @@ describe('installReactIslands', () => {
436442
document.body.appendChild(host)
437443

438444
const stop = installReactIslands()
439-
await tick(30)
440-
;(host.querySelector('#custom-action-button') as HTMLButtonElement).click()
441-
await tick(30)
442-
443-
expect(actionHost.__FICT_REACT_ACTION_CALLS__).toEqual(['custom:loader-option'])
444-
445-
stop()
445+
try {
446+
await tick(30)
447+
;(host.querySelector('#custom-action-button') as HTMLButtonElement).click()
448+
await waitForExpectation(() => {
449+
expect(actionHost.__FICT_REACT_ACTION_CALLS__).toEqual(['custom:loader-option'])
450+
})
451+
} finally {
452+
stop()
453+
}
446454
})
447455

448456
it('loader recovers from transient component load failures with bounded backoff retries', async () => {

0 commit comments

Comments
 (0)