Make export test resilient to out-of-order handling

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2026-03-17 14:19:01 -05:00
committed by GitHub
parent b0f3f5fa56
commit 17d746bf40

View File

@@ -393,7 +393,7 @@ describe('backup/attachments', () => {
key: attachment1.key, key: attachment1.key,
size: attachment1.size, size: attachment1.size,
}; };
let roundtrippedAttachment: AttachmentType | undefined;
await asymmetricRoundtripHarness( await asymmetricRoundtripHarness(
[ [
composeMessage(1, { composeMessage(1, {
@@ -408,19 +408,31 @@ describe('backup/attachments', () => {
attachments: [expectedRoundtrippedFields(attachment1)], attachments: [expectedRoundtrippedFields(attachment1)],
}), }),
composeMessage(2, { composeMessage(2, {
attachments: [ attachments: [expectedRoundtrippedFields(attachment2)],
expectedRoundtrippedFields({
...attachment2,
cdnKey: attachment1.cdnKey,
cdnNumber: attachment1.cdnNumber,
uploadTimestamp: attachment1.uploadTimestamp,
incrementalMac: attachment1.incrementalMac,
chunkSize: attachment1.chunkSize,
}),
],
}), }),
], ],
{ 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 () => { it('roundtrips voice message attachments', async () => {