Some of the changes in this PR are extracted from https://github.com/discourse/discourse/pull/17379. Similar to the bookmarks tab in the new user menu, the messages tab also displays a mix of notifications and messages. When there are unread message notifications, the tab displays all of these notifications at the top and fills the remaining space in the menu with a list of the user's messages. The bubble/badge count on the messages tab indicates how many unread message notifications there are.
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import { module, test } from "qunit";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import { query } from "discourse/tests/helpers/qunit-helpers";
|
|
import { render } from "@ember/test-helpers";
|
|
import { cloneJSON, deepMerge } from "discourse-common/lib/object";
|
|
import { hbs } from "ember-cli-htmlbars";
|
|
import PrivateMessagesFixture from "discourse/tests/fixtures/private-messages-fixtures";
|
|
|
|
function getMessage(overrides = {}) {
|
|
const data = cloneJSON(
|
|
PrivateMessagesFixture["/topics/private-messages/eviltrout.json"].topic_list
|
|
.topics[0]
|
|
);
|
|
return deepMerge(data, overrides);
|
|
}
|
|
|
|
module("Integration | Component | user-menu | message-item", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
const template = hbs`<UserMenu::MessageItem @item={{this.message}}/>`;
|
|
|
|
test("item description is the fancy title of the message", async function (assert) {
|
|
this.set(
|
|
"message",
|
|
getMessage({ fancy_title: "This is a <b>safe</b> title!" })
|
|
);
|
|
await render(template);
|
|
assert.strictEqual(
|
|
query("li.message .item-description").textContent.trim(),
|
|
"This is a safe title!"
|
|
);
|
|
assert.strictEqual(
|
|
query("li.message .item-description b").textContent.trim(),
|
|
"safe",
|
|
"fancy title is not escaped"
|
|
);
|
|
});
|
|
});
|