This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/components/user-menu/message-item-test.js
Osama Sayegh 473695ee4d
DEV: Add messages tab to the new user menu (#17850)
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.
2022-08-10 08:25:39 +03:00

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"
);
});
});