mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 15:26:09 +08:00
c34f8b65cb
As of #23867 this is now a real package, so updating the imports to use the real package name, rather than relying on the alias. The name change in the package name is because `I18n` is not a valid name as NPM packages must be all lowercase. This commit also introduces an eslint rule to prevent importing from the old I18n path. For themes/plugins, the old 'i18n' name remains functional.
96 lines
3.1 KiB
JavaScript
96 lines
3.1 KiB
JavaScript
import { render } from "@ember/test-helpers";
|
|
import { hbs } from "ember-cli-htmlbars";
|
|
import { module, test } from "qunit";
|
|
import sinon from "sinon";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import I18n from "discourse-i18n";
|
|
import { HEADER_INDICATOR_PREFERENCE_ALL_NEW } from "discourse/plugins/chat/discourse/controllers/preferences-chat";
|
|
|
|
module("Discourse Chat | Component | chat-header-icon", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {});
|
|
|
|
test("full page - never separated sidebar mode", async function (assert) {
|
|
this.currentUser.user_option.chat_separate_sidebar_mode = "never";
|
|
sinon
|
|
.stub(this.owner.lookup("service:chat-state-manager"), "isFullPageActive")
|
|
.value(true);
|
|
|
|
await render(hbs`<Chat::Header::Icon />`);
|
|
|
|
assert
|
|
.dom(".icon.btn-flat")
|
|
.hasAttribute("title", I18n.t("chat.title_capitalized"))
|
|
.hasAttribute("href", "/chat");
|
|
|
|
assert.dom(".d-icon-d-chat").exists();
|
|
});
|
|
|
|
test("full page - always separated mode", async function (assert) {
|
|
this.currentUser.user_option.chat_separate_sidebar_mode = "always";
|
|
sinon
|
|
.stub(this.owner.lookup("service:chat-state-manager"), "isFullPageActive")
|
|
.value(true);
|
|
|
|
await render(hbs`<Chat::Header::Icon />`);
|
|
|
|
assert
|
|
.dom(".icon.btn-flat")
|
|
.hasAttribute("title", I18n.t("sidebar.panels.forum.label"))
|
|
.hasAttribute("href", "/latest");
|
|
|
|
assert.dom(".d-icon-random").exists();
|
|
});
|
|
|
|
test("mobile", async function (assert) {
|
|
this.site.mobileView = true;
|
|
|
|
await render(hbs`<Chat::Header::Icon />`);
|
|
|
|
assert
|
|
.dom(".icon.btn-flat")
|
|
.hasAttribute("title", I18n.t("chat.title_capitalized"))
|
|
.hasAttribute("href", "/chat");
|
|
|
|
assert.dom(".d-icon-d-chat").exists();
|
|
});
|
|
|
|
test("full page - with unread", async function (assert) {
|
|
this.currentUser.user_option.chat_separate_sidebar_mode = "always";
|
|
this.currentUser.user_option.chat_header_indicator_preference =
|
|
HEADER_INDICATOR_PREFERENCE_ALL_NEW;
|
|
|
|
sinon
|
|
.stub(this.owner.lookup("service:chat-state-manager"), "isFullPageActive")
|
|
.value(true);
|
|
|
|
await render(hbs`<Chat::Header::Icon @urgentCount={{1}} />`);
|
|
|
|
assert
|
|
.dom(".icon.btn-flat")
|
|
.hasAttribute("title", I18n.t("sidebar.panels.forum.label"))
|
|
.hasAttribute("href", "/latest");
|
|
assert.dom(".d-icon-random").exists();
|
|
assert.dom(".chat-channel-unread-indicator__number").doesNotExist();
|
|
});
|
|
|
|
test("drawer - with unread", async function (assert) {
|
|
this.currentUser.user_option.chat_separate_sidebar_mode = "always";
|
|
this.currentUser.user_option.chat_header_indicator_preference =
|
|
HEADER_INDICATOR_PREFERENCE_ALL_NEW;
|
|
|
|
await render(hbs`<Chat::Header::Icon @urgentCount={{1}} />`);
|
|
|
|
assert
|
|
.dom(".icon.btn-flat")
|
|
.hasAttribute("title", I18n.t("sidebar.panels.chat.label"))
|
|
.hasAttribute("href", "/chat");
|
|
assert.dom(".d-icon-d-chat").exists();
|
|
assert
|
|
.dom(".chat-channel-unread-indicator__number")
|
|
.exists()
|
|
.containsText("1");
|
|
});
|
|
});
|