From 16876d4025942d5de03f649a10f2a26653f89eba Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Wed, 7 Aug 2024 08:36:58 -0500 Subject: [PATCH] Fix CI test flake for AttachmentDownloadManager --- .../services/AttachmentDownloadManager_test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ts/test-electron/services/AttachmentDownloadManager_test.ts b/ts/test-electron/services/AttachmentDownloadManager_test.ts index 736f2ad82e..08d2dc80a5 100644 --- a/ts/test-electron/services/AttachmentDownloadManager_test.ts +++ b/ts/test-electron/services/AttachmentDownloadManager_test.ts @@ -157,18 +157,22 @@ describe('AttachmentDownloadManager/JobManager', () => { ); } + async function flushSQLReads() { + await DataWriter.getNextAttachmentDownloadJobs({ limit: 10 }); + } + async function advanceTime(ms: number) { // When advancing the timers, we want to make sure any DB operations are completed // first. In cases like maybeStartJobs where we prevent re-entrancy, without this, // prior (unfinished) invocations can prevent subsequent calls after the clock is // ticked forward and make tests unreliable - await DataReader.getAllItems(); + await flushSQLReads(); const now = Date.now(); while (Date.now() < now + ms) { // eslint-disable-next-line no-await-in-loop await clock.tickAsync(downloadManager?.tickInterval ?? 1000); // eslint-disable-next-line no-await-in-loop - await DataReader.getAllItems(); + await flushSQLReads(); } }