diff --git a/test/features/composer/data/html_analyzer_test.dart b/test/features/composer/data/html_analyzer_test.dart
index ea2d81189..14f8efd7d 100644
--- a/test/features/composer/data/html_analyzer_test.dart
+++ b/test/features/composer/data/html_analyzer_test.dart
@@ -190,6 +190,41 @@ void main() {
verify(mockFileUploader.uploadAttachment(any, any, uploadUri)).called(2);
});
+ test(
+ 'When processing 100 base64 images,\n'
+ 'should replace each with a unique CID and add corresponding attachments',
+ () async {
+ int countImage = 100;
+ final htmlContent = '''
+ ${List.generate(countImage, (index) => '
').join(' ')}
+ ''';
+ final inlineAttachments = {};
+ final uploadUri = Uri.parse('https://example.com/upload');
+
+ when(mockUuid.v1()).thenAnswer((_) => 'uuid1');
+
+ when(mockFileUploader.uploadAttachment(any, any, any))
+ .thenAnswer((_) async => Attachment(
+ blobId: Id('blob123'),
+ type: MediaType('image', 'png'),
+ disposition: ContentDisposition.inline,
+ ));
+
+ final result = await htmlAnalyzer.replaceImageBase64ToImageCID(
+ emailContent: htmlContent,
+ inlineAttachments: inlineAttachments,
+ uploadUri: uploadUri,
+ );
+
+ final document = parse(result.value1);
+ final imgTags = document.querySelectorAll('img');
+ expect(imgTags.length, countImage);
+ expect(imgTags.every((img) => img.attributes['src']!.contains('cid:')), isTrue);
+ expect(result.value2.length, countImage);
+ verify(mockUuid.v1()).called(countImage);
+ verify(mockFileUploader.uploadAttachment(any, any, uploadUri)).called(countImage);
+ });
+
test(
'When one image upload throws an exception out of multiple base64 images,\n'
'should replace successful upload with CID and keep original src for failed one',