fix(backend-defaults): fix flaky TaskWorker initialDelayDuration test

The "respects initialDelayDuration per worker" test had only a 50ms
margin (350ms total sleep vs 300ms initial delay) for the worker to
complete its internal DB roundtrips before asserting. Under CI load
this frequently wasn't enough. Replace the fixed sleep with
waitForExpect, consistent with the rest of the test file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
This commit is contained in:
Fredrik Adelöw
2026-05-13 15:21:06 +02:00
parent f2cb76215b
commit 0624b2eaf6
@@ -328,8 +328,9 @@ describe.each(databases.eachSupportedId())('TaskWorker, %s', databaseId => {
expect(fn1).toHaveBeenCalledTimes(0);
await new Promise(resolve => setTimeout(resolve, 250));
expect(fn1).toHaveBeenCalledTimes(0);
await new Promise(resolve => setTimeout(resolve, 100));
expect(fn1.mock.calls.length).toBeGreaterThan(0);
await waitForExpect(() => {
expect(fn1.mock.calls.length).toBeGreaterThan(0);
});
// Start a second worker and make sure it waits but the first worker still works along
const fn2 = jest.fn();