mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
FIX: improvements to chat message streaming (#26892)
- prevents re-rendering avatars while updating messages quickly in the thread preview indicator - ensures the cancel button is shown when you are admin OR when the streamed message is a reply to the current user
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { clearRender, render } from "@ember/test-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
@ -58,4 +58,56 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
|
||||
"has the correct css class"
|
||||
);
|
||||
});
|
||||
|
||||
test("Message with streaming", async function (assert) {
|
||||
// admin
|
||||
this.currentUser.admin = true;
|
||||
|
||||
this.message = new ChatFabricators(getOwner(this)).message({
|
||||
inReplyTo: new ChatFabricators(getOwner(this)).message(),
|
||||
streaming: true,
|
||||
});
|
||||
await this.message.cook();
|
||||
await render(template);
|
||||
|
||||
assert
|
||||
.dom(".stop-streaming-btn")
|
||||
.exists("when admin, it has the stop streaming button");
|
||||
|
||||
await clearRender();
|
||||
|
||||
// not admin - not replying to current user
|
||||
this.currentUser.admin = false;
|
||||
|
||||
this.message = new ChatFabricators(getOwner(this)).message({
|
||||
inReplyTo: new ChatFabricators(getOwner(this)).message(),
|
||||
streaming: true,
|
||||
});
|
||||
await this.message.cook();
|
||||
await render(template);
|
||||
|
||||
assert
|
||||
.dom(".stop-streaming-btn")
|
||||
.doesNotExist("when admin, it doesn't have the stop streaming button");
|
||||
|
||||
await clearRender();
|
||||
|
||||
// not admin - replying to current user
|
||||
this.currentUser.admin = false;
|
||||
|
||||
this.message = new ChatFabricators(getOwner(this)).message({
|
||||
inReplyTo: new ChatFabricators(getOwner(this)).message({
|
||||
user: this.currentUser,
|
||||
}),
|
||||
streaming: true,
|
||||
});
|
||||
await this.message.cook();
|
||||
await render(template);
|
||||
|
||||
assert
|
||||
.dom(".stop-streaming-btn")
|
||||
.exists(
|
||||
"when replying to current user, it has the stop streaming button"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user