mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-23 06:30:50 +08:00
I believe the unreliable-network UI was removed in #19531. The test cases are all covered by system specs now, with the exception of message sending retry - this one is redone here.
56 lines
1.8 KiB
JavaScript
Vendored
56 lines
1.8 KiB
JavaScript
Vendored
import { test } from "qunit";
|
|
import sinon from "sinon";
|
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
acceptance("Unit | Service | chat", function (needs) {
|
|
needs.user();
|
|
|
|
needs.hooks.beforeEach(function () {
|
|
Object.defineProperty(this, "currentUser", {
|
|
get: () => this.container.lookup("service:current-user"),
|
|
});
|
|
Object.defineProperty(this, "chat", {
|
|
get: () => this.container.lookup("service:chat"),
|
|
});
|
|
this.chatTrackingStateManager = this.container.lookup(
|
|
"service:chat-tracking-state-manager"
|
|
);
|
|
this.chatPanePendingManager = this.container.lookup(
|
|
"service:chat-pane-pending-manager"
|
|
);
|
|
sinon
|
|
.stub(this.chatTrackingStateManager, "allChannelUrgentCount")
|
|
.returns(5);
|
|
sinon
|
|
.stub(this.chatPanePendingManager, "totalPendingMessageCount")
|
|
.get(() => 10);
|
|
});
|
|
|
|
test("getDocumentTitleCount returns urgent count when title_count_mode is 'notifications'", function (assert) {
|
|
this.currentUser.user_option.title_count_mode = "notifications";
|
|
|
|
const count = this.chat.getDocumentTitleCount();
|
|
|
|
assert.strictEqual(
|
|
count,
|
|
5,
|
|
"returns only urgent count (mentions, DMs, watched threads)"
|
|
);
|
|
});
|
|
|
|
test("getDocumentTitleCount returns pending count when title_count_mode is 'contextual'", function (assert) {
|
|
this.currentUser.user_option.title_count_mode = "contextual";
|
|
|
|
const count = this.chat.getDocumentTitleCount();
|
|
|
|
assert.strictEqual(count, 10, "returns pending count");
|
|
});
|
|
|
|
test("getDocumentTitleCount returns pending count when user_option is null", function (assert) {
|
|
this.currentUser.user_option = null;
|
|
|
|
const count = this.chat.getDocumentTitleCount();
|
|
|
|
assert.strictEqual(count, 10, "returns pending count");
|
|
});
|
|
});
|