mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
postprocess_test: Replace contrived example with real-world one.
The removed lines appear to be fully contrived, as there is no apparent case where the server would deliver a block of HTML with `.message_inline_image` without also delivering an inner <img> or <video> element. It appears the original outer block was introduced as part of3df0cacd9efor ensuring coverage of the post-processing of the `title` attribute to `aria-label`, which change has since become covered by numerous other non-contrived examples. The replaced (and contrived) `<a role="button">` part introduced by911b3b5365is meant to test the absence of an `href` attribute, which is the minimal new line introduced here to maintain test coverage while also testing a genuinely possible pattern a user could send, namely `[missing href]()`. See https://chat.zulip.org/#narrow/channel/43-automated-testing/topic/unusual.20.60.2Emessage_inline_image.60.20HTML/with/2261114 for further discussion.
This commit is contained in:
@@ -13,6 +13,9 @@ const {initialize_user_settings} = zrequire("user_settings");
|
||||
const user_settings = {web_font_size_px: 16};
|
||||
initialize_user_settings({user_settings});
|
||||
|
||||
// Care should be taken to present real-world cases here and
|
||||
// throughout, rather than contrived examples that serve
|
||||
// only to satisfy 100% test coverage.
|
||||
run_test("postprocess_content", () => {
|
||||
assert.equal(
|
||||
postprocess_content(
|
||||
@@ -21,10 +24,7 @@ run_test("postprocess_content", () => {
|
||||
'<a href="http://localhost:NNNN">invalid</a> ' +
|
||||
'<a href="javascript:alert(1)">unsafe</a> ' +
|
||||
'<a href="/#fragment" target="_blank">fragment</a>' +
|
||||
'<div class="message_inline_image">' +
|
||||
'<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/inline.png" title="inline image">upload</a> ' +
|
||||
'<a role="button">button</a> ' +
|
||||
"</div>" +
|
||||
"<a>missing href</a>" +
|
||||
'<div class="message_inline_image message_inline_video">' +
|
||||
'<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/inline.mp4">' +
|
||||
'<video src="http://zulip.zulipdev.com/user_uploads/w/ha/tever/inline.mp4"></video>' +
|
||||
@@ -50,11 +50,8 @@ run_test("postprocess_content", () => {
|
||||
"<a>invalid</a> " +
|
||||
"<a>unsafe</a> " +
|
||||
'<a href="/#fragment" title="http://zulip.zulipdev.com/#fragment">fragment</a>' +
|
||||
"<a>missing href</a>" +
|
||||
'<div class="message-thumbnail-gallery">' +
|
||||
'<div class="message_inline_image">' +
|
||||
'<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/inline.png" target="_blank" rel="noopener noreferrer" aria-label="inline image">upload</a> ' +
|
||||
'<a role="button">button</a> ' +
|
||||
"</div>" +
|
||||
'<div class="message_inline_image message_inline_video">' +
|
||||
'<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/inline.mp4" target="_blank" rel="noopener noreferrer" class="media-anchor-element">' +
|
||||
'<video src="http://zulip.zulipdev.com/user_uploads/w/ha/tever/inline.mp4" class="media-video-element media-image-element"></video>' +
|
||||
|
||||
Reference in New Issue
Block a user