discourse/plugins/chat/test/javascripts/acceptance/chat-preferences-test.js
Martin Brennan 8437081d94
FIX: Add MessageBust.last_id to chat channel subscriptions (#19255)
This commit adds variousMessageBus.last_ids to serializer payloads
for chat channels and the chat view (for chat live pane) so
we can use those IDs when subscribing to MessageBus channels
from chat.

This allows us to ensure that any messages created between the
server being hit and the UI loaded and subscribing end up being
delivered to the client, rather than just silently dropped.

This commit also fixes an issue where we were subscribing to
the new-messages and new-mentions MessageBus channels multiple
times when following/unfollowing a channel multiple times.
2022-12-02 10:57:53 +10:00

35 lines
1.2 KiB
JavaScript

import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { chatChannels } from "discourse/plugins/chat/chat-fixtures";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { CHAT_SOUNDS } from "discourse/plugins/chat/discourse/services/chat-audio-manager";
function preferencesPretender(server, helper) {
server.get("/u/eviltrout/activity.json", () => helper.response({}));
server.get("/chat/chat_channels.json", () => helper.response(chatChannels));
}
acceptance("Discourse Chat | User Preferences", function (needs) {
needs.user({ can_chat: true, has_chat_enabled: true });
needs.settings({ chat_enabled: true });
needs.pretender(preferencesPretender);
test("when user has no chat sound set", async function (assert) {
const sounds = Object.keys(CHAT_SOUNDS);
await visit("/u/eviltrout/preferences/chat");
const dropdown = selectKit("#user_chat_sounds");
assert.strictEqual(dropdown.header().value(), null, "it displays no sound");
await dropdown.expand();
await dropdown.selectRowByValue(sounds[1]);
assert.strictEqual(
dropdown.header().value(),
sounds[1],
"it selects the sound"
);
});
});