mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FIX: prevents chat to enter in endless loop when getting 404 (#18867)
Doing DOM operations in finally would cause them to happen even when the request was a failure. Consequence of these DOM operations would be new request, which would also end up in a 404, and so on. This commit simply moves the DOM operations in the then block where it should be safe to make.
This commit is contained in:
@ -252,6 +252,10 @@ acceptance(
|
||||
server.get("/chat/chat_channels/:chatChannelId", () =>
|
||||
helper.response({ id: 1, title: "something" })
|
||||
);
|
||||
|
||||
server.get("/chat/lookup/:messageId.json", () => {
|
||||
return helper.response(404);
|
||||
});
|
||||
});
|
||||
|
||||
test("Handles 404 errors by displaying an alert", async function (assert) {
|
||||
@ -260,6 +264,13 @@ acceptance(
|
||||
assert.ok(exists(".dialog-content"), "it displays a 404 error");
|
||||
await click(".dialog-footer .btn-primary");
|
||||
});
|
||||
|
||||
test("Handles 404 errors with unexisting messageId", async function (assert) {
|
||||
await visit("/chat/channel/1/cat?messageId=2");
|
||||
|
||||
assert.ok(exists(".dialog-content"), "it displays a 404 error");
|
||||
await click(".dialog-footer .btn-primary");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user