From 4f9bb8f8207900350c2750382dcaf07b3703cb8d Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:37:07 -0700 Subject: [PATCH] Make export test resilient to out-of-order handling --- .../backup/attachments_test.preload.ts | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/ts/test-electron/backup/attachments_test.preload.ts b/ts/test-electron/backup/attachments_test.preload.ts index bf8d92caa2..b7e42a9964 100644 --- a/ts/test-electron/backup/attachments_test.preload.ts +++ b/ts/test-electron/backup/attachments_test.preload.ts @@ -393,7 +393,7 @@ describe('backup/attachments', () => { key: attachment1.key, size: attachment1.size, }; - + let roundtrippedAttachment: AttachmentType | undefined; await asymmetricRoundtripHarness( [ composeMessage(1, { @@ -408,19 +408,31 @@ describe('backup/attachments', () => { attachments: [expectedRoundtrippedFields(attachment1)], }), composeMessage(2, { - attachments: [ - expectedRoundtrippedFields({ - ...attachment2, - cdnKey: attachment1.cdnKey, - cdnNumber: attachment1.cdnNumber, - uploadTimestamp: attachment1.uploadTimestamp, - incrementalMac: attachment1.incrementalMac, - chunkSize: attachment1.chunkSize, - }), - ], + attachments: [expectedRoundtrippedFields(attachment2)], }), ], - { backupLevel: BackupLevel.Paid } + { + backupLevel: BackupLevel.Paid, + comparator: (before, after) => { + assert.deepEqual( + omit(before, 'attachments'), + omit(after, 'attachments') + ); + if (!roundtrippedAttachment) { + roundtrippedAttachment = after?.attachments?.[0]; + } else { + assert.equal( + roundtrippedAttachment.cdnKey, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + after.attachments?.[0]!.cdnKey + ); + } + }, + } + ); + strictAssert( + roundtrippedAttachment != null, + 'attachment was roundtripped' ); }); it('roundtrips voice message attachments', async () => {