mirror of
https://github.com/discourse/discourse.git
synced 2024-12-17 05:26:22 +08:00
d07b472b79
* DEV: Rnemae channel path to just c Also swap the channel id and channel slug params to be consistent with core. * linting * channel_path * params in wrong order * Drop slugify helper and channel route without slug * Request slug and route models through the channel model if possible * Add client side redirection for backwards-compatibility Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
import { click, visit } from "@ember/test-helpers";
|
|
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
|
import { skip } from "qunit";
|
|
|
|
acceptance(
|
|
"Discourse Chat - Chat live pane - handling 429 errors",
|
|
function (needs) {
|
|
needs.user({
|
|
username: "eviltrout",
|
|
id: 1,
|
|
has_chat_enabled: true,
|
|
});
|
|
needs.settings({
|
|
chat_enabled: true,
|
|
navigation_menu: "legacy",
|
|
});
|
|
|
|
needs.pretender((server, helper) => {
|
|
server.get("/chat/:chatChannelId/messages.json", () => {
|
|
return helper.response(429);
|
|
});
|
|
|
|
server.get("/chat/chat_channels.json", () =>
|
|
helper.response({
|
|
public_channels: [
|
|
{
|
|
id: 1,
|
|
title: "something",
|
|
current_user_membership: { following: true },
|
|
message_bus_last_ids: { new_mentions: 0, new_messages: 0 },
|
|
},
|
|
],
|
|
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/:chatChannelId", () =>
|
|
helper.response({ id: 1, title: "something" })
|
|
);
|
|
|
|
server.post("/chat/drafts", () => {
|
|
return helper.response([]);
|
|
});
|
|
|
|
server.post("/chat/:chatChannelId.json", () => {
|
|
return helper.response({ success: "OK" });
|
|
});
|
|
});
|
|
|
|
skip("Handles 429 errors by displaying an alert", async function (assert) {
|
|
await visit("/chat/c/cat/1");
|
|
|
|
assert.ok(exists(".dialog-content"), "We displayed a 429 error");
|
|
await click(".dialog-footer .btn-primary");
|
|
});
|
|
}
|
|
);
|