diff --git a/app/assets/javascripts/discourse/app/templates/components/invite-panel.hbs b/app/assets/javascripts/discourse/app/templates/components/invite-panel.hbs index c4bff577784..ea571e60927 100644 --- a/app/assets/javascripts/discourse/app/templates/components/invite-panel.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/invite-panel.hbs @@ -27,7 +27,7 @@ hasGroups=hasGroups usernames=emailOrUsername placeholderKey=placeholderKey - allowEmails=true + allowEmails=canInviteViaEmail class="invite-user-input" autocomplete="discourse" value=emailOrUsername diff --git a/test/javascripts/integration/components/invite-panel-test.js b/test/javascripts/integration/components/invite-panel-test.js new file mode 100644 index 00000000000..2d42cc82b4c --- /dev/null +++ b/test/javascripts/integration/components/invite-panel-test.js @@ -0,0 +1,22 @@ +import EmberObject, { set } from "@ember/object"; +import componentTest from "helpers/component-test"; + +moduleForComponent("invite-panel", { integration: true }); + +componentTest("can_invite_via_email", { + template: "{{invite-panel panel=panel}}", + + beforeEach() { + set(this.currentUser, "details", { can_invite_via_email: true }); + const inviteModel = JSON.parse(JSON.stringify(this.currentUser)); + this.set("panel", { + id: "invite", + model: { inviteModel: EmberObject.create(inviteModel) }, + }); + }, + + async test(assert) { + await fillIn(".invite-user-input", "eviltrout@example.com"); + assert.ok(find(".send-invite:disabled").length === 0); + }, +});