FIX: only show discourse-ai CTA to admins (#26895)

This commit is contained in:
Joffrey JAFFEUX
2024-05-07 00:43:30 +02:00
committed by GitHub
parent 2f2355b0ad
commit 2347ff7074
2 changed files with 46 additions and 11 deletions

View File

@ -0,0 +1,32 @@
import { getOwner } from "@ember/application";
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import ChatModalThreadSettings from "discourse/plugins/chat/discourse/components/chat/modal/thread-settings";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module("Discourse Chat | Component | <ThreadSettings />", function (hooks) {
setupRenderingTest(hooks);
test("discourse-ai - admin", async function (assert) {
this.currentUser.admin = true;
const thread = new ChatFabricators(getOwner(this)).thread();
await render(<template>
<ChatModalThreadSettings @inline={{true}} @model={{thread}} />
</template>);
assert.dom(".discourse-ai-cta").exists();
});
test("discourse-ai - not admin", async function (assert) {
this.currentUser.admin = false;
const thread = new ChatFabricators(getOwner(this)).thread();
await render(<template>
<ChatModalThreadSettings @inline={{true}} @model={{thread}} />
</template>);
assert.dom(".discourse-ai-cta").doesNotExist();
});
});