UX: hide chat button on user card when suspended (#20292)
This commit is contained in:
parent
14a447175b
commit
585d1e2f4d
|
@ -1,4 +1,4 @@
|
|||
{{#if this.chat.userCanDirectMessage}}
|
||||
{{#if (and this.chat.userCanDirectMessage (not @user.suspended))}}
|
||||
<DButton
|
||||
@class="btn-primary user-card-chat-btn"
|
||||
@action={{action "startChatting"}}
|
||||
|
|
|
@ -4,6 +4,7 @@ import { render } from "@ember/test-helpers";
|
|||
import { module, test } from "qunit";
|
||||
import sinon from "sinon";
|
||||
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
import User from "discourse/models/user";
|
||||
|
||||
module("Discourse Chat | Component | user-card-chat-button", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
@ -30,4 +31,21 @@ module("Discourse Chat | Component | user-card-chat-button", function (hooks) {
|
|||
"it doesn’t show the chat button"
|
||||
);
|
||||
});
|
||||
|
||||
test("when displayed user is suspended", async function (assert) {
|
||||
sinon
|
||||
.stub(this.owner.lookup("service:chat"), "userCanDirectMessage")
|
||||
.value(true);
|
||||
|
||||
this.user = User.create({
|
||||
suspended_till: moment().add(1, "year").toDate(),
|
||||
});
|
||||
|
||||
await render(hbs`<UserCardChatButton @user={{user}}/>`);
|
||||
|
||||
assert.false(
|
||||
exists(".user-card-chat-btn"),
|
||||
"it doesn’t show the chat button"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue