mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-27 11:53:31 +08:00
The header space is becoming very crowded with translations, chat, and AI bot all enabled. This commit makes the new default for AI conversations a link in the community section in the sidebar instead of a header button. <img width="1412" height="246" alt="CleanShot 2025-10-04 at 15 44 05@2x" src="https://github.com/user-attachments/assets/45c48607-bbaa-4993-9e92-bb8db2d7f45a" /> <img width="478" height="650" alt="CleanShot 2025-10-04 at 15 44 32@2x" src="https://github.com/user-attachments/assets/67af3afa-6a46-4c79-8aa9-fc789a086056" /> There is also a new back-to-forum button added in, conform with other custom-sidebar pages such as /admin and /docs. <img width="1966" height="1004" alt="CleanShot 2025-10-04 at 15 45 04@2x" src="https://github.com/user-attachments/assets/5b167aba-9305-476f-a449-ec4a186bc6f7" /> --------- Co-authored-by: awesomerobot <kris.aubuchon@discourse.org>
145 lines
3.5 KiB
JavaScript
Vendored
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_persona: 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_persona: 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 - persona without default LLM",
|
|
function (needs) {
|
|
needs.user({
|
|
ai_enabled_chat_bots: [
|
|
{
|
|
id: 1,
|
|
model_name: "custom-persona",
|
|
is_persona: 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 persona 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 persona lacks default LLM"
|
|
);
|
|
});
|
|
}
|
|
);
|
|
|
|
acceptance(
|
|
"AI Bot - Sidebar community link - persona with default LLM",
|
|
function (needs) {
|
|
needs.user({
|
|
ai_enabled_chat_bots: [
|
|
{
|
|
id: 1,
|
|
model_name: "custom-persona",
|
|
is_persona: 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 persona 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 persona has default LLM");
|
|
});
|
|
}
|
|
);
|