Files
2024-11-26 22:41:29 +01:00

60 lines
2.2 KiB
JavaScript

import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Post - History", function (needs) {
needs.user();
needs.pretender((server, helper) => {
server.get("/posts/419/revisions/latest.json", () => {
return helper.response({
created_at: "2021-11-24T10:59:36.163Z",
post_id: 419,
previous_hidden: false,
current_hidden: false,
first_revision: 1,
previous_revision: 1,
current_revision: 2,
next_revision: null,
last_revision: 2,
current_version: 2,
version_count: 2,
username: "bianca",
display_username: "bianca",
avatar_template: "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
edit_reason: null,
body_changes: {
inline: '<div class="inline-diff"><p>Welcome to Discourse!</p</div>',
side_by_side:
'<div class="revision-content"><p>Welcome to Discourse!</p</div><div class="revision-content"><p>Welcome to Discourse!</p</div>',
side_by_side_markdown:
'<table class="markdown"><tr><td>Welcome to Discourse!</td><td>Welcome to Discourse!</td></tr></table>',
},
title_changes: {
inline:
'<div class="inline-diff"><div>Welcome to Discourse!</div></div>',
side_by_side:
'<div class="revision-content"><div>Welcome to Discourse!</div></div><div class="revision-content"><div>Welcome to Discourse!</div></div>',
},
user_changes: null,
tags_changes: {
previous: ["tag1", "tag2"],
current: ["tag2", "tag3"],
},
wiki: false,
can_edit: true,
});
});
});
test("Shows highlighted tag changes", async function (assert) {
await visit("/t/internationalization-localization/280");
await click("article[data-post-id='419'] .edits button");
assert.dom(".discourse-tag").exists({ count: 4 });
assert.dom(".discourse-tag.diff-del").exists({ count: 1 });
assert.dom(".discourse-tag.diff-del").hasText("tag1");
assert.dom(".discourse-tag.diff-ins").exists({ count: 1 });
assert.dom(".discourse-tag.diff-ins").hasText("tag3");
});
});