mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 23:33:45 +08:00
8437081d94
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.
50 lines
1.6 KiB
JavaScript
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");
|
|
});
|
|
});
|