FIX: Don't load images that don't exist in test

This makes 404 requests and fills up the logs with junk
This commit is contained in:
Robin Ward 2020-07-17 14:12:47 -04:00
parent 0ecca3a2d2
commit f68ea29236
5 changed files with 22 additions and 25 deletions

View File

@ -112,7 +112,7 @@ QUnit.test("Composer upload placeholder", async assert => {
original_filename: "test.png",
thumbnail_width: 200,
thumbnail_height: 300,
url: "/uploads/test1.ext"
url: "/images/avatar.png?1"
}
};
@ -124,7 +124,7 @@ QUnit.test("Composer upload placeholder", async assert => {
original_filename: "test.png",
thumbnail_width: 100,
thumbnail_height: 200,
url: "/uploads/test2.ext"
url: "/images/avatar.png?2"
}
};
@ -136,7 +136,7 @@ QUnit.test("Composer upload placeholder", async assert => {
original_filename: "image.png",
thumbnail_width: 300,
thumbnail_height: 400,
url: "/uploads/test3.ext"
url: "/images/avatar.png?3"
}
};
@ -148,7 +148,7 @@ QUnit.test("Composer upload placeholder", async assert => {
original_filename: "ima++ge.png",
thumbnail_width: 300,
thumbnail_height: 400,
url: "/uploads/test3.ext"
url: "/images/avatar.png?3"
}
};
@ -177,19 +177,19 @@ QUnit.test("Composer upload placeholder", async assert => {
await find(".wmd-controls").trigger("fileuploaddone", data2);
assert.equal(
find(".d-editor-input").val(),
"[Uploading: test.png...]() ![test|100x200](/uploads/test2.ext) [Uploading: ima++ge.png...]() [Uploading: image.png...]() "
"[Uploading: test.png...]() ![test|100x200](/images/avatar.png?2) [Uploading: ima++ge.png...]() [Uploading: image.png...]() "
);
await find(".wmd-controls").trigger("fileuploaddone", data3);
assert.equal(
find(".d-editor-input").val(),
"[Uploading: test.png...]() ![test|100x200](/uploads/test2.ext) [Uploading: ima++ge.png...]() ![image|300x400](/uploads/test3.ext) "
"[Uploading: test.png...]() ![test|100x200](/images/avatar.png?2) [Uploading: ima++ge.png...]() ![image|300x400](/images/avatar.png?3) "
);
await find(".wmd-controls").trigger("fileuploaddone", data1);
assert.equal(
find(".d-editor-input").val(),
"![test|200x300](/uploads/test1.ext) ![test|100x200](/uploads/test2.ext) [Uploading: ima++ge.png...]() ![image|300x400](/uploads/test3.ext) "
"![test|200x300](/images/avatar.png?1) ![test|100x200](/images/avatar.png?2) [Uploading: ima++ge.png...]() ![image|300x400](/images/avatar.png?3) "
);
});
@ -760,7 +760,7 @@ QUnit.test("Image resizing buttons", async assert => {
// 4 Wrapped in backquetes should not work
"`![test|690x313](upload://test.png)`",
// 5 html image - should not work
"<img src='http://someimage.jpg' wight='20' height='20'>",
"<img src='/images/avatar.png' wight='20' height='20'>",
// 6 two images one the same line, but both are syntactically correct - both should work
"![onTheSameLine1|200x200](upload://onTheSameLine1.jpeg) ![onTheSameLine2|250x250](upload://onTheSameLine2.jpeg)",
// 7 & 8 Identical images - both should work
@ -771,7 +771,7 @@ QUnit.test("Image resizing buttons", async assert => {
// 10 Image with markdown title - should work
`![image|690x220](upload://test.png "image title")`,
// 11 bbcode - should not work
"[img]http://example.com/image.jpg[/img]",
"[img]/images/avatar.png[/img]",
// 12 Image with data attributes
"![test|foo=bar|690x313,50%|bar=baz](upload://test.png)"
];

View File

@ -24,8 +24,8 @@ componentTest("resolves short URLs", {
[
{
short_url: "upload://a.png",
url: "/uploads/default/original/3X/c/b/1.png",
short_path: "/uploads/short-url/a.png"
url: "/images/avatar.png",
short_path: "/images/d-logo-sketch.png"
}
]
];
@ -38,9 +38,6 @@ componentTest("resolves short URLs", {
test(assert) {
const html = find(".post-body")[0].innerHTML.trim();
assert.equal(
html,
'<p><img src="/uploads/default/original/3X/c/b/1.png" alt="an image"></p>'
);
assert.equal(html, '<p><img src="/images/avatar.png" alt="an image"></p>');
}
});

View File

@ -814,7 +814,7 @@ export function applyDefaultHandlers(pretender) {
<a href="http://test.com/somepage" target="_blank">test.com</a>
</header>
<article class="onebox-body">
<div class="aspect-image" style="--aspect-ratio:690/362;"><img src="https://test.com/image.png" class="thumbnail"></div>
<div class="aspect-image" style="--aspect-ratio:690/362;"><img src="" class="thumbnail"></div>
<h3><a href="http://test.com/somepage" target="_blank">Test Page</a></h3>
<p>Yet another collaboration tool</p>
</article>

View File

@ -41,7 +41,7 @@ QUnit.test("load - successful onebox", async assert => {
<a href="http://test.com/somepage" target="_blank">test.com</a>
</header>
<article class="onebox-body">
<div class="aspect-image" style="--aspect-ratio:690/362;"><img src="https://test.com/image.png" class="thumbnail"></div>
<div class="aspect-image" style="--aspect-ratio:690/362;"><img src="" class="thumbnail"></div>
<h3><a href="http://test.com/somepage" target="_blank">Test Page</a></h3>
<p>Yet another collaboration tool</p>
</article>

View File

@ -15,17 +15,17 @@ function stubUrls(imageSrcs, attachmentSrcs, otherMediaSrcs) {
imageSrcs = [
{
short_url: "upload://a.jpeg",
url: "/uploads/default/original/3X/c/b/1.jpeg",
url: "/images/avatar.png?a",
short_path: "/uploads/short-url/a.jpeg"
},
{
short_url: "upload://b.jpeg",
url: "/uploads/default/original/3X/c/b/2.jpeg",
url: "/images/avatar.png?b",
short_path: "/uploads/short-url/b.jpeg"
},
{
short_url: "upload://z.jpeg",
url: "/uploads/default/original/3X/c/b/9.jpeg",
url: "/images/avatar.png?z",
short_path: "/uploads/short-url/z.jpeg"
}
];
@ -89,14 +89,14 @@ QUnit.test("resolveAllShortUrls", async assert => {
lookup = lookupCachedUploadUrl("upload://a.jpeg");
assert.deepEqual(lookup, {
url: "/uploads/default/original/3X/c/b/1.jpeg",
url: "/images/avatar.png?a",
short_path: "/uploads/short-url/a.jpeg"
});
lookup = lookupCachedUploadUrl("upload://b.jpeg");
assert.deepEqual(lookup, {
url: "/uploads/default/original/3X/c/b/2.jpeg",
url: "/images/avatar.png?b",
short_path: "/uploads/short-url/b.jpeg"
});
@ -136,8 +136,8 @@ QUnit.test(
.eq(1);
let link = fixture().find("a");
assert.equal(image1.attr("src"), "/uploads/default/original/3X/c/b/1.jpeg");
assert.equal(image2.attr("src"), "/uploads/default/original/3X/c/b/2.jpeg");
assert.equal(image1.attr("src"), "/images/avatar.png?a");
assert.equal(image2.attr("src"), "/images/avatar.png?b");
assert.equal(link.attr("href"), "/uploads/short-url/c.pdf");
}
);
@ -176,7 +176,7 @@ QUnit.test("resolveAllShortUrls - scoped", async assert => {
lookup = lookupCachedUploadUrl("upload://z.jpeg");
assert.deepEqual(lookup, {
url: "/uploads/default/original/3X/c/b/9.jpeg",
url: "/images/avatar.png?z",
short_path: "/uploads/short-url/z.jpeg"
});