UX: hide chat button on user card when suspended (#20292)

This commit is contained in:
Joffrey JAFFEUX 2023-02-14 21:12:50 +01:00 committed by GitHub
parent 14a447175b
commit 585d1e2f4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -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"}}

View File

@ -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 doesnt 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 doesnt show the chat button"
);
});
});