fix: stabilize flaky ChangeExtractorService invalidation test
The test races stale and fresh worker calls to verify that invalidation prevents stale results from populating the cache. On slow CI, the fresh worker mock could be reached before the stale deferred was resolved, causing the version guard to mismatch. Flush microtasks after starting freshPromise so it advances past internal awaits and reaches the worker mock before we resolve the stale deferred.
This commit is contained in:
parent
5efc3dd63f
commit
8570ed13fd
1 changed files with 8 additions and 0 deletions
|
|
@ -651,6 +651,14 @@ describe('ChangeExtractorService', () => {
|
|||
const stalePromise = service.getTaskChanges(TEAM_NAME, TASK_ID, SUMMARY_OPTIONS);
|
||||
await service.invalidateTaskChangeSummaries(TEAM_NAME, [TASK_ID], { deletePersisted: true });
|
||||
const freshPromise = service.getTaskChanges(TEAM_NAME, TASK_ID, SUMMARY_OPTIONS);
|
||||
// Flush microtasks so freshPromise advances past its internal awaits
|
||||
// and reaches the worker mock before we resolve the stale deferred.
|
||||
// Without this, CI timing can cause the stale resolution to race with
|
||||
// the fresh worker call, making the test flaky.
|
||||
await vi.advanceTimersByTimeAsync?.(0).catch(() => undefined);
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
first.resolve(makeTaskChangeResult());
|
||||
const stale = await stalePromise;
|
||||
const fresh = await freshPromise;
|
||||
|
|
|
|||
Loading…
Reference in a new issue