🥎 test: Handle Erasure Rejections Before Awaiting Database Reads (#18526)

The account-erasure recovery test started a favorite write that is expected to reject, then awaited a MongoDB read before handing the promise to the matcher. If PostgreSQL answered first the rejection had no handler and jest failed the test. The write now starts inside the awaited matcher.
This commit is contained in:
Danny Avila 2026-11-19 12:58:23 -05:00 • committed by GitHub
parent 5826626353
commit 4376b29740
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -231,14 +231,14 @@ realPostgres('delete-user CLI durable erasure recovery', () => {
itemType: 'tool',
itemId: 'after-recovery',
});
const add =
const add = () =>
origin === 'tenant'
? schemas.tenantStorage.run({ tenantId: 'tenant-a' }, addFavorite)
: addFavorite();
if (outcome === 'cancel') {
expect((await owned(id)).agentTriggerDeletionStartedAt).toBeUndefined();
expect((await owned(id)).agentTriggerDeletionAttemptId).toBeUndefined();
await expect(add).resolves.toEqual({ ok: true, added: true });
await expect(add()).resolves.toEqual({ ok: true, added: true });
expect(
(
await db.query(
@ -249,7 +249,7 @@ realPostgres('delete-user CLI durable erasure recovery', () => {
).toEqual([]);
} else {
expect(await owned(id)).toBeNull();
await expect(add).rejects.toThrow('erasure');
await expect(add()).rejects.toThrow('erasure');
}
} finally {
await restarted.close();