discourse/plugins/discourse-ai/test/javascripts/acceptance/ai-bot-sidebar-link-test.js
Sam e3fae646d4
DEV: AI persona to agent migration (#38319)
Co-authored-by: Keegan George <kgeorge13@gmail.com>
2026-03-10 15:59:45 +11:00

145 lines
3.5 KiB
JavaScript
Vendored

import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("AI Bot - Sidebar community link", function (needs) {
needs.user({
ai_enabled_chat_bots: [
{
id: 1,
model_name: "gpt-4",
is_agent: false,
},
],
});
needs.settings({
discourse_ai_enabled: true,
ai_bot_enabled: true,
ai_bot_add_to_community_section: true,
});
test("displays AI bot link in community section when enabled", async function (assert) {
await visit("/");
assert
.dom(".sidebar-section-link[data-link-name='ai-bot']")
.exists("AI bot link is displayed in the sidebar");
assert
.dom(".sidebar-section-link[data-link-name='ai-bot'] .d-icon-robot")
.exists("AI bot link has robot icon");
assert
.dom(".sidebar-section-link[data-link-name='ai-bot']")
.hasText("AI bot", "AI bot link has correct text");
});
});
acceptance("AI Bot - Sidebar community link - disabled", function (needs) {
needs.user({
ai_enabled_chat_bots: [
{
id: 1,
model_name: "gpt-4",
is_agent: false,
},
],
});
needs.settings({
discourse_ai_enabled: true,
ai_bot_enabled: true,
ai_bot_add_to_community_section: false,
});
test("does not display AI bot link when setting is disabled", async function (assert) {
await visit("/");
assert
.dom(".sidebar-section-link[data-link-name='ai-bot']")
.doesNotExist("AI bot link is not displayed when setting is disabled");
});
});
acceptance("AI Bot - Sidebar community link - no bots", function (needs) {
needs.user({
ai_enabled_chat_bots: [],
});
needs.settings({
discourse_ai_enabled: true,
ai_bot_enabled: true,
ai_bot_add_to_community_section: true,
});
test("does not display AI bot link when no bots are available", async function (assert) {
await visit("/");
assert
.dom(".sidebar-section-link[data-link-name='ai-bot']")
.doesNotExist("AI bot link is not displayed when no bots are available");
});
});
acceptance(
"AI Bot - Sidebar community link - agent without default LLM",
function (needs) {
needs.user({
ai_enabled_chat_bots: [
{
id: 1,
model_name: "custom-agent",
is_agent: true,
has_default_llm: false,
},
],
});
needs.settings({
discourse_ai_enabled: true,
ai_bot_enabled: true,
ai_bot_add_to_community_section: true,
});
test("does not display AI bot link when agent has no default LLM", async function (assert) {
await visit("/");
assert
.dom(".sidebar-section-link[data-link-name='ai-bot']")
.doesNotExist(
"AI bot link is not displayed when agent lacks default LLM"
);
});
}
);
acceptance(
"AI Bot - Sidebar community link - agent with default LLM",
function (needs) {
needs.user({
ai_enabled_chat_bots: [
{
id: 1,
model_name: "custom-agent",
is_agent: true,
has_default_llm: true,
},
],
});
needs.settings({
discourse_ai_enabled: true,
ai_bot_enabled: true,
ai_bot_add_to_community_section: true,
});
test("displays AI bot link when agent has default LLM", async function (assert) {
await visit("/");
assert
.dom(".sidebar-section-link[data-link-name='ai-bot']")
.exists("AI bot link is displayed when agent has default LLM");
});
}
);