mirror of
https://github.com/discourse/discourse.git
synced 2026-08-10 22:51:02 +08:00
When a chat message containing an uploaded image, video, or file was flagged, the review queue showed only the message text: chat uploads are stored separately from the cooked message, so moderators had no way to see the actual reported content. This was especially concerning for direct messages, where staff cannot otherwise view the media. This change snapshots the flagged message's uploads into the reviewable's payload and renders them in the review queue using the same component chat itself uses, so moderators now see the flagged image/video/attachment (with lightbox support) directly on the reviewable.
56 lines
1.7 KiB
Text
Vendored
56 lines
1.7 KiB
Text
Vendored
import { render } from "@ember/test-helpers";
|
|
import { module, test } from "qunit";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import ReviewableChatMessage from "discourse/plugins/chat/discourse/components/reviewable/chat-message";
|
|
|
|
function reviewable(payload) {
|
|
return {
|
|
type: "ReviewableChatMessage",
|
|
target_id: 1,
|
|
cooked: "<p>flagged message</p>",
|
|
payload,
|
|
};
|
|
}
|
|
|
|
module("Integration | Component | Reviewable | chat-message", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test("renders the message uploads captured in the payload", async function (assert) {
|
|
const item = reviewable({
|
|
message_cooked: "<p>look at this</p>",
|
|
message_uploads: [
|
|
{
|
|
id: 1,
|
|
original_filename: "flagged.png",
|
|
extension: "png",
|
|
width: 200,
|
|
height: 100,
|
|
url: "/uploads/default/original/1X/flagged.png",
|
|
short_url: "upload://flagged.png",
|
|
short_path: "/uploads/short-url/flagged.png",
|
|
},
|
|
],
|
|
});
|
|
|
|
await render(
|
|
<template><ReviewableChatMessage @reviewable={{item}} /></template>
|
|
);
|
|
|
|
assert
|
|
.dom(".review-item__post-content .chat-uploads img.chat-img-upload")
|
|
.exists("renders the flagged upload as an image");
|
|
});
|
|
|
|
test("renders no uploads section when the payload has none", async function (assert) {
|
|
const item = reviewable({ message_cooked: "<p>just text</p>" });
|
|
|
|
await render(
|
|
<template><ReviewableChatMessage @reviewable={{item}} /></template>
|
|
);
|
|
|
|
assert
|
|
.dom(".review-item__post-content")
|
|
.containsText("just text", "still renders the cooked message");
|
|
assert.dom(".chat-uploads").doesNotExist("renders no uploads section");
|
|
});
|
|
});
|