Skip to content

Commit 6ff4df3

Browse files
chrisbobbegnprice
authored andcommitted
content test: Add explicit test case for Zulip Cloud external image preview
This kind of URL is already covered in the tests of *clusters* of image previews, but it seems helpful to isolate it like this with its own comment. We're also about to add a third variant, testing that we accept images generated with an arbitrary CAMO_URI, which actually we don't currently do, so that'll be a regression test.
1 parent 2f1dcc9 commit 6ff4df3

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

test/model/content_test.dart

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,8 @@ class ContentExample {
785785
]),
786786
]);
787787

788-
static const imagePreviewSingleExternal = ContentExample(
789-
'single image preview external',
788+
static const imagePreviewSingleExternal1 = ContentExample(
789+
'single image preview external, src starts with /external_content',
790790
// https://chat.zulip.org/#narrow/stream/7-test-here/topic/Greg/near/1892172
791791
"https://upload.wikimedia.org/wikipedia/commons/7/78/Verregende_bloem_van_een_Helenium_%27El_Dorado%27._22-07-2023._%28d.j.b%29.jpg",
792792
'<div class="message_inline_image">'
@@ -799,6 +799,21 @@ class ContentExample {
799799
]),
800800
]);
801801

802+
static const imagePreviewSingleExternal2 = ContentExample(
803+
'single image preview external, src starts with https://uploads.zulipusercontent.net/',
804+
// Zulip Cloud has CAMO_URI = "https://uploads.zulipusercontent.net/";
805+
// this example is from a DM on a closed Zulip Cloud org.
806+
"https://upload.wikimedia.org/wikipedia/commons/7/78/Verregende_bloem_van_een_Helenium_%27El_Dorado%27._22-07-2023._%28d.j.b%29.jpg",
807+
'<div class="message_inline_image">'
808+
'<a href="https://upload.wikimedia.org/wikipedia/commons/7/78/Verregende_bloem_van_een_Helenium_%27El_Dorado%27._22-07-2023._%28d.j.b%29.jpg">'
809+
'<img src="https://uploads.zulipusercontent.net/99742b0f992be15283c428dd42f3b9f5db138d69/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f372f37382f566572726567656e64655f626c6f656d5f76616e5f65656e5f48656c656e69756d5f253237456c5f446f7261646f2532372e5f32322d30372d323032332e5f253238642e6a2e622532392e6a7067"></a></div>', [
810+
ImagePreviewNodeList([
811+
ImagePreviewNode(srcUrl: 'https://uploads.zulipusercontent.net/99742b0f992be15283c428dd42f3b9f5db138d69/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f372f37382f566572726567656e64655f626c6f656d5f76616e5f65656e5f48656c656e69756d5f253237456c5f446f7261646f2532372e5f32322d30372d323032332e5f253238642e6a2e622532392e6a7067',
812+
thumbnailUrl: null, loading: false,
813+
originalWidth: null, originalHeight: null),
814+
]),
815+
]);
816+
802817
static const imagePreviewInvalidUrl = ContentExample(
803818
'single image preview with invalid URL',
804819
null, // hypothetical, to test for a risk of crashing
@@ -1816,7 +1831,8 @@ void main() async {
18161831
testParseExample(ContentExample.imagePreviewSingleNoDimensions);
18171832
testParseExample(ContentExample.imagePreviewSingleNoThumbnail);
18181833
testParseExample(ContentExample.imagePreviewSingleLoadingPlaceholder);
1819-
testParseExample(ContentExample.imagePreviewSingleExternal);
1834+
testParseExample(ContentExample.imagePreviewSingleExternal1);
1835+
testParseExample(ContentExample.imagePreviewSingleExternal2);
18201836
testParseExample(ContentExample.imagePreviewInvalidUrl);
18211837
testParseExample(ContentExample.imagePreviewCluster);
18221838
testParseExample(ContentExample.imagePreviewClusterNoThumbnails);

0 commit comments

Comments
 (0)