discourse/plugins/chat/test/javascripts/acceptance/delete-chat-channel-modal-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

50 lines
1.6 KiB
JavaScript

import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import fabricators from "../helpers/fabricators";
acceptance("Discourse Chat - delete chat channel modal", function (needs) {
needs.user({ has_chat_enabled: true, can_chat: true });
needs.settings({ chat_enabled: true });
needs.pretender((server, helper) => {
server.get("/chat/chat_channels.json", () => {
return helper.response({
public_channels: [fabricators.chatChannel({ id: 2 })],
direct_message_channels: [],
message_bus_last_ids: {
channel_metadata: 0,
channel_edits: 0,
channel_status: 0,
new_channel: 0,
user_tracking_state: 0,
},
});
});
server.get("/chat/chat_channels/:id", (request) => {
return helper.response(
fabricators.chatChannel({ id: request.params.id })
);
});
server.get("/chat/:id/messages.json", () => {
return helper.response({ meta: {}, chat_messages: [] });
});
server.delete("/chat/chat_channels/:id.json", () => {
return helper.response({});
});
});
test("Redirection after deleting a channel", async function (assert) {
await visit("chat/channel/1/my-category-title/info/settings");
await click(".delete-btn");
await fillIn("#channel-delete-confirm-name", "My category title");
await click("#chat-confirm-delete-channel");
assert.equal(currentURL(), "/chat/channel/2/my-category-title");
});
});