DEV: Add compatibility with the Glimmer Post Stream (#1230)
This commit is contained in:
parent
09a6841480
commit
ede65c971f
|
@ -1,3 +1,4 @@
|
||||||
|
< 3.5.0.beta3-dev: 09a68414804a1447f52e5d60691ba59742cda9ec
|
||||||
< 3.5.0.beta2-dev: de8624416a15b3d8e7ad350b083cc1420451ccec
|
< 3.5.0.beta2-dev: de8624416a15b3d8e7ad350b083cc1420451ccec
|
||||||
< 3.5.0.beta1-dev: bdef136080074a993e7c4f5ca562edc31a8ba756
|
< 3.5.0.beta1-dev: bdef136080074a993e7c4f5ca562edc31a8ba756
|
||||||
< 3.4.0.beta4-dev: a53719ab8eb071459f215227421b3ea4987e5f87
|
< 3.4.0.beta4-dev: a53719ab8eb071459f215227421b3ea4987e5f87
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import Component from "@glimmer/component";
|
||||||
|
import { isGPTBot } from "../../lib/ai-bot-helper";
|
||||||
|
|
||||||
|
export default class AiPersonaFlair extends Component {
|
||||||
|
static shouldRender(args) {
|
||||||
|
return isGPTBot(args.post.user);
|
||||||
|
}
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<span class="persona-flair">
|
||||||
|
{{@outletArgs.post.topic.ai_persona_name}}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
}
|
|
@ -1,11 +1,29 @@
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
|
import { getOwnerWithFallback } from "discourse/lib/get-owner";
|
||||||
import Composer from "discourse/models/composer";
|
import Composer from "discourse/models/composer";
|
||||||
import { i18n } from "discourse-i18n";
|
import { i18n } from "discourse-i18n";
|
||||||
import ShareFullTopicModal from "../components/modal/share-full-topic-modal";
|
import ShareFullTopicModal from "../components/modal/share-full-topic-modal";
|
||||||
|
|
||||||
const MAX_PERSONA_USER_ID = -1200;
|
const MAX_PERSONA_USER_ID = -1200;
|
||||||
|
|
||||||
|
let enabledChatBotIds;
|
||||||
|
|
||||||
|
export function isGPTBot(user) {
|
||||||
|
if (!user) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enabledChatBotIds) {
|
||||||
|
const currentUser = getOwnerWithFallback(this).lookup(
|
||||||
|
"service:current-user"
|
||||||
|
);
|
||||||
|
enabledChatBotIds = currentUser.ai_enabled_chat_bots.map((bot) => bot.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return enabledChatBotIds.includes(user.id);
|
||||||
|
}
|
||||||
|
|
||||||
export function isPostFromAiBot(post, currentUser) {
|
export function isPostFromAiBot(post, currentUser) {
|
||||||
return (
|
return (
|
||||||
post.user_id <= MAX_PERSONA_USER_ID ||
|
post.user_id <= MAX_PERSONA_USER_ID ||
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
|
import { withSilencedDeprecations } from "discourse/lib/deprecated";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import { registerWidgetShim } from "discourse/widgets/render-glimmer";
|
import { registerWidgetShim } from "discourse/widgets/render-glimmer";
|
||||||
import AiBotHeaderIcon from "../discourse/components/ai-bot-header-icon";
|
import AiBotHeaderIcon from "../discourse/components/ai-bot-header-icon";
|
||||||
|
import AiPersonaFlair from "../discourse/components/post/ai-persona-flair";
|
||||||
import AiCancelStreamingButton from "../discourse/components/post-menu/ai-cancel-streaming-button";
|
import AiCancelStreamingButton from "../discourse/components/post-menu/ai-cancel-streaming-button";
|
||||||
import AiDebugButton from "../discourse/components/post-menu/ai-debug-button";
|
import AiDebugButton from "../discourse/components/post-menu/ai-debug-button";
|
||||||
import AiShareButton from "../discourse/components/post-menu/ai-share-button";
|
import AiShareButton from "../discourse/components/post-menu/ai-share-button";
|
||||||
import { showShareConversationModal } from "../discourse/lib/ai-bot-helper";
|
import {
|
||||||
|
isGPTBot,
|
||||||
|
showShareConversationModal,
|
||||||
|
} from "../discourse/lib/ai-bot-helper";
|
||||||
import { streamPostText } from "../discourse/lib/ai-streamer/progress-handlers";
|
import { streamPostText } from "../discourse/lib/ai-streamer/progress-handlers";
|
||||||
|
|
||||||
let enabledChatBotIds = [];
|
|
||||||
let allowDebug = false;
|
let allowDebug = false;
|
||||||
|
|
||||||
function isGPTBot(user) {
|
|
||||||
return user && enabledChatBotIds.includes(user.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function attachHeaderIcon(api) {
|
function attachHeaderIcon(api) {
|
||||||
api.headerIcons.add("ai", AiBotHeaderIcon);
|
api.headerIcons.add("ai", AiBotHeaderIcon);
|
||||||
}
|
}
|
||||||
|
@ -53,28 +53,28 @@ function initializeAIBotReplies(api) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializePersonaDecorator(api) {
|
function initializePersonaDecorator(api) {
|
||||||
let topicController = null;
|
api.renderAfterWrapperOutlet("post-meta-data-poster-name", AiPersonaFlair);
|
||||||
|
|
||||||
|
withSilencedDeprecations("discourse.post-stream-widget-overrides", () =>
|
||||||
|
initializeWidgetPersonaDecorator(api)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeWidgetPersonaDecorator(api) {
|
||||||
api.decorateWidget(`poster-name:after`, (dec) => {
|
api.decorateWidget(`poster-name:after`, (dec) => {
|
||||||
if (!isGPTBot(dec.attrs.user)) {
|
if (!isGPTBot(dec.attrs.user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// this is hacky and will need to change
|
|
||||||
// trouble is we need to get the model for the topic
|
|
||||||
// and it is not available in the decorator
|
|
||||||
// long term this will not be a problem once we remove widgets and
|
|
||||||
// have a saner structure for our model
|
|
||||||
topicController =
|
|
||||||
topicController || api.container.lookup("controller:topic");
|
|
||||||
|
|
||||||
return dec.widget.attach("persona-flair", {
|
return dec.widget.attach("persona-flair", {
|
||||||
topicController,
|
personaName: dec.model?.topic?.ai_persona_name,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWidgetShim(
|
registerWidgetShim(
|
||||||
"persona-flair",
|
"persona-flair",
|
||||||
"span.persona-flair",
|
"span.persona-flair",
|
||||||
hbs`{{@data.topicController.model.ai_persona_name}}`
|
hbs`{{@data.personaName}}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,16 +159,16 @@ export default {
|
||||||
const user = container.lookup("service:current-user");
|
const user = container.lookup("service:current-user");
|
||||||
|
|
||||||
if (user?.ai_enabled_chat_bots) {
|
if (user?.ai_enabled_chat_bots) {
|
||||||
enabledChatBotIds = user.ai_enabled_chat_bots.map((bot) => bot.id);
|
|
||||||
allowDebug = user.can_debug_ai_bot_conversations;
|
allowDebug = user.can_debug_ai_bot_conversations;
|
||||||
withPluginApi("1.6.0", attachHeaderIcon);
|
|
||||||
withPluginApi("1.34.0", initializeAIBotReplies);
|
withPluginApi((api) => {
|
||||||
withPluginApi("1.6.0", initializePersonaDecorator);
|
attachHeaderIcon(api);
|
||||||
withPluginApi("1.34.0", (api) => initializeDebugButton(api, container));
|
initializeAIBotReplies(api);
|
||||||
withPluginApi("1.34.0", (api) => initializeShareButton(api, container));
|
initializePersonaDecorator(api);
|
||||||
withPluginApi("1.22.0", (api) =>
|
initializeDebugButton(api, container);
|
||||||
initializeShareTopicButton(api, container)
|
initializeShareButton(api, container);
|
||||||
);
|
initializeShareTopicButton(api, container);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -105,230 +105,236 @@ RSpec.describe "AI Bot - Homepage", type: :system do
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when `ai_enable_experimental_bot_ux` is enabled" do
|
%w[enabled disabled].each do |value|
|
||||||
it "renders landing page on bot click" do
|
before { SiteSetting.glimmer_post_stream_mode = value }
|
||||||
visit "/"
|
|
||||||
header.click_bot_button
|
|
||||||
expect(ai_pm_homepage).to have_homepage
|
|
||||||
expect(sidebar).to be_visible
|
|
||||||
end
|
|
||||||
|
|
||||||
it "displays error when message is too short" do
|
context "when glimmer_post_stream_mode=#{value}" do
|
||||||
visit "/"
|
context "when `ai_enable_experimental_bot_ux` is enabled" do
|
||||||
header.click_bot_button
|
it "renders landing page on bot click" do
|
||||||
|
visit "/"
|
||||||
|
header.click_bot_button
|
||||||
|
expect(ai_pm_homepage).to have_homepage
|
||||||
|
expect(sidebar).to be_visible
|
||||||
|
end
|
||||||
|
|
||||||
ai_pm_homepage.input.fill_in(with: "a")
|
it "displays error when message is too short" do
|
||||||
ai_pm_homepage.submit
|
visit "/"
|
||||||
expect(ai_pm_homepage).to have_too_short_dialog
|
header.click_bot_button
|
||||||
dialog.click_yes
|
|
||||||
expect(composer).to be_closed
|
|
||||||
end
|
|
||||||
|
|
||||||
it "hides default content in the sidebar" do
|
ai_pm_homepage.input.fill_in(with: "a")
|
||||||
visit "/"
|
ai_pm_homepage.submit
|
||||||
header.click_bot_button
|
expect(ai_pm_homepage).to have_too_short_dialog
|
||||||
|
dialog.click_yes
|
||||||
|
expect(composer).to be_closed
|
||||||
|
end
|
||||||
|
|
||||||
expect(ai_pm_homepage).to have_homepage
|
it "hides default content in the sidebar" do
|
||||||
expect(sidebar).to have_no_tags_section
|
visit "/"
|
||||||
expect(sidebar).to have_no_section("categories")
|
header.click_bot_button
|
||||||
expect(sidebar).to have_no_section("messages")
|
|
||||||
expect(sidebar).to have_no_section("chat-dms")
|
|
||||||
expect(sidebar).to have_no_section("chat-channels")
|
|
||||||
expect(sidebar).to have_no_section("user-threads")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "shows the bot conversation in the sidebar" do
|
expect(ai_pm_homepage).to have_homepage
|
||||||
visit "/"
|
expect(sidebar).to have_no_tags_section
|
||||||
header.click_bot_button
|
expect(sidebar).to have_no_section("categories")
|
||||||
|
expect(sidebar).to have_no_section("messages")
|
||||||
|
expect(sidebar).to have_no_section("chat-dms")
|
||||||
|
expect(sidebar).to have_no_section("chat-channels")
|
||||||
|
expect(sidebar).to have_no_section("user-threads")
|
||||||
|
end
|
||||||
|
|
||||||
expect(ai_pm_homepage).to have_homepage
|
it "shows the bot conversation in the sidebar" do
|
||||||
expect(sidebar).to have_section("ai-conversations-history")
|
visit "/"
|
||||||
expect(sidebar).to have_section_link("Today")
|
header.click_bot_button
|
||||||
expect(sidebar).to have_section_link(pm.title)
|
|
||||||
expect(sidebar).to have_no_css("button.ai-new-question-button")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "displays last_7_days label in the sidebar" do
|
expect(ai_pm_homepage).to have_homepage
|
||||||
pm.update!(last_posted_at: Time.zone.now - 5.days)
|
expect(sidebar).to have_section("ai-conversations-history")
|
||||||
visit "/"
|
expect(sidebar).to have_section_link("Today")
|
||||||
header.click_bot_button
|
expect(sidebar).to have_section_link(pm.title)
|
||||||
|
expect(sidebar).to have_no_css("button.ai-new-question-button")
|
||||||
|
end
|
||||||
|
|
||||||
expect(ai_pm_homepage).to have_homepage
|
it "displays last_7_days label in the sidebar" do
|
||||||
expect(sidebar).to have_section_link("Last 7 days")
|
pm.update!(last_posted_at: Time.zone.now - 5.days)
|
||||||
end
|
visit "/"
|
||||||
|
header.click_bot_button
|
||||||
|
|
||||||
it "displays last_30_days label in the sidebar" do
|
expect(ai_pm_homepage).to have_homepage
|
||||||
pm.update!(last_posted_at: Time.zone.now - 28.days)
|
expect(sidebar).to have_section_link("Last 7 days")
|
||||||
visit "/"
|
end
|
||||||
header.click_bot_button
|
|
||||||
|
|
||||||
expect(ai_pm_homepage).to have_homepage
|
it "displays last_30_days label in the sidebar" do
|
||||||
expect(sidebar).to have_section_link("Last 30 days")
|
pm.update!(last_posted_at: Time.zone.now - 28.days)
|
||||||
end
|
visit "/"
|
||||||
|
header.click_bot_button
|
||||||
|
|
||||||
it "displays month and year label in the sidebar for older conversations" do
|
expect(ai_pm_homepage).to have_homepage
|
||||||
pm.update!(last_posted_at: "2024-04-10 15:39:11.406192000 +00:00")
|
expect(sidebar).to have_section_link("Last 30 days")
|
||||||
visit "/"
|
end
|
||||||
header.click_bot_button
|
|
||||||
|
|
||||||
expect(ai_pm_homepage).to have_homepage
|
it "displays month and year label in the sidebar for older conversations" do
|
||||||
expect(sidebar).to have_section_link("Apr 2024")
|
pm.update!(last_posted_at: "2024-04-10 15:39:11.406192000 +00:00")
|
||||||
end
|
visit "/"
|
||||||
|
header.click_bot_button
|
||||||
|
|
||||||
it "navigates to the bot conversation when clicked" do
|
expect(ai_pm_homepage).to have_homepage
|
||||||
visit "/"
|
expect(sidebar).to have_section_link("Apr 2024")
|
||||||
header.click_bot_button
|
end
|
||||||
|
|
||||||
expect(ai_pm_homepage).to have_homepage
|
it "navigates to the bot conversation when clicked" do
|
||||||
ai_pm_homepage.click_fist_sidebar_conversation
|
visit "/"
|
||||||
expect(topic_page).to have_topic_title(pm.title)
|
header.click_bot_button
|
||||||
end
|
|
||||||
|
|
||||||
it "displays the shuffle icon when on homepage or bot PM" do
|
expect(ai_pm_homepage).to have_homepage
|
||||||
visit "/"
|
ai_pm_homepage.click_fist_sidebar_conversation
|
||||||
expect(header).to have_icon_in_bot_button(icon: "robot")
|
expect(topic_page).to have_topic_title(pm.title)
|
||||||
header.click_bot_button
|
end
|
||||||
|
|
||||||
expect(header).to have_icon_in_bot_button(icon: "shuffle")
|
it "displays the shuffle icon when on homepage or bot PM" do
|
||||||
|
visit "/"
|
||||||
|
expect(header).to have_icon_in_bot_button(icon: "robot")
|
||||||
|
header.click_bot_button
|
||||||
|
|
||||||
# Go to a PM and assert that the icon is still shuffle
|
expect(header).to have_icon_in_bot_button(icon: "shuffle")
|
||||||
ai_pm_homepage.click_fist_sidebar_conversation
|
|
||||||
expect(header).to have_icon_in_bot_button(icon: "shuffle")
|
|
||||||
|
|
||||||
# Go back home and assert that the icon is now robot again
|
# Go to a PM and assert that the icon is still shuffle
|
||||||
header.click_bot_button
|
ai_pm_homepage.click_fist_sidebar_conversation
|
||||||
expect(header).to have_icon_in_bot_button(icon: "robot")
|
expect(header).to have_icon_in_bot_button(icon: "shuffle")
|
||||||
end
|
|
||||||
|
|
||||||
it "displays sidebar and 'new question' on the topic page" do
|
# Go back home and assert that the icon is now robot again
|
||||||
topic_page.visit_topic(pm)
|
header.click_bot_button
|
||||||
expect(sidebar).to be_visible
|
expect(header).to have_icon_in_bot_button(icon: "robot")
|
||||||
expect(sidebar).to have_css("button.ai-new-question-button")
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it "redirect to the homepage when 'new question' is clicked" do
|
it "displays sidebar and 'new question' on the topic page" do
|
||||||
topic_page.visit_topic(pm)
|
topic_page.visit_topic(pm)
|
||||||
expect(sidebar).to be_visible
|
expect(sidebar).to be_visible
|
||||||
sidebar.find("button.ai-new-question-button").click
|
expect(sidebar).to have_css("button.ai-new-question-button")
|
||||||
expect(ai_pm_homepage).to have_homepage
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it "can send a new message to the bot" do
|
it "redirect to the homepage when 'new question' is clicked" do
|
||||||
topic_page.visit_topic(pm)
|
topic_page.visit_topic(pm)
|
||||||
topic_page.click_reply_button
|
expect(sidebar).to be_visible
|
||||||
expect(composer).to be_opened
|
sidebar.find("button.ai-new-question-button").click
|
||||||
|
expect(ai_pm_homepage).to have_homepage
|
||||||
|
end
|
||||||
|
|
||||||
composer.fill_in(with: "Hello bot replying to you")
|
it "can send a new message to the bot" do
|
||||||
composer.submit
|
topic_page.visit_topic(pm)
|
||||||
expect(page).to have_content("Hello bot replying to you")
|
topic_page.click_reply_button
|
||||||
end
|
expect(composer).to be_opened
|
||||||
|
|
||||||
it "does not render custom sidebar on non-authored bot pms" do
|
composer.fill_in(with: "Hello bot replying to you")
|
||||||
# Include user_2 in the PM by creating a new post and topic_allowed_user association
|
composer.submit
|
||||||
Fabricate(:post, topic: pm, user: user_2, post_number: 4)
|
expect(page).to have_content("Hello bot replying to you")
|
||||||
Fabricate(:topic_allowed_user, topic: pm, user: user_2)
|
end
|
||||||
sign_in(user_2)
|
|
||||||
topic_page.visit_topic(pm)
|
|
||||||
|
|
||||||
expect(sidebar).to be_visible
|
it "does not render custom sidebar on non-authored bot pms" do
|
||||||
expect(sidebar).to have_no_section("ai-conversations-history")
|
# Include user_2 in the PM by creating a new post and topic_allowed_user association
|
||||||
expect(sidebar).to have_no_css("button.ai-new-question-button")
|
Fabricate(:post, topic: pm, user: user_2, post_number: 4)
|
||||||
end
|
Fabricate(:topic_allowed_user, topic: pm, user: user_2)
|
||||||
|
sign_in(user_2)
|
||||||
|
topic_page.visit_topic(pm)
|
||||||
|
|
||||||
it "does not include non-authored bot pms in sidebar" do
|
expect(sidebar).to be_visible
|
||||||
# Include user_2 in the PM by creating a new post and topic_allowed_user association
|
expect(sidebar).to have_no_section("ai-conversations-history")
|
||||||
Fabricate(:post, topic: pm, user: user_2, post_number: 4)
|
expect(sidebar).to have_no_css("button.ai-new-question-button")
|
||||||
Fabricate(:topic_allowed_user, topic: pm, user: user_2)
|
end
|
||||||
sign_in(user_2)
|
|
||||||
|
|
||||||
visit "/"
|
it "does not include non-authored bot pms in sidebar" do
|
||||||
header.click_bot_button
|
# Include user_2 in the PM by creating a new post and topic_allowed_user association
|
||||||
expect(ai_pm_homepage).to have_homepage
|
Fabricate(:post, topic: pm, user: user_2, post_number: 4)
|
||||||
expect(sidebar).to have_no_section_link(pm.title)
|
Fabricate(:topic_allowed_user, topic: pm, user: user_2)
|
||||||
end
|
sign_in(user_2)
|
||||||
|
|
||||||
it "Allows choosing persona and LLM" do
|
visit "/"
|
||||||
ai_pm_homepage.visit
|
header.click_bot_button
|
||||||
|
expect(ai_pm_homepage).to have_homepage
|
||||||
|
expect(sidebar).to have_no_section_link(pm.title)
|
||||||
|
end
|
||||||
|
|
||||||
ai_pm_homepage.persona_selector.expand
|
it "Allows choosing persona and LLM" do
|
||||||
ai_pm_homepage.persona_selector.select_row_by_name(persona.name)
|
ai_pm_homepage.visit
|
||||||
ai_pm_homepage.persona_selector.collapse
|
|
||||||
|
|
||||||
ai_pm_homepage.llm_selector.expand
|
ai_pm_homepage.persona_selector.expand
|
||||||
ai_pm_homepage.llm_selector.select_row_by_name(claude_2_dup.display_name)
|
ai_pm_homepage.persona_selector.select_row_by_name(persona.name)
|
||||||
ai_pm_homepage.llm_selector.collapse
|
ai_pm_homepage.persona_selector.collapse
|
||||||
end
|
|
||||||
|
|
||||||
it "renders back to forum link" do
|
ai_pm_homepage.llm_selector.expand
|
||||||
ai_pm_homepage.visit
|
ai_pm_homepage.llm_selector.select_row_by_name(claude_2_dup.display_name)
|
||||||
expect(ai_pm_homepage).to have_sidebar_back_link
|
ai_pm_homepage.llm_selector.collapse
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with hamburger menu" do
|
it "renders back to forum link" do
|
||||||
before { SiteSetting.navigation_menu = "header dropdown" }
|
ai_pm_homepage.visit
|
||||||
it "keeps robot icon in the header and doesn't display sidebar back link" do
|
expect(ai_pm_homepage).to have_sidebar_back_link
|
||||||
visit "/"
|
end
|
||||||
expect(header).to have_icon_in_bot_button(icon: "robot")
|
|
||||||
header.click_bot_button
|
context "with hamburger menu" do
|
||||||
expect(ai_pm_homepage).to have_homepage
|
before { SiteSetting.navigation_menu = "header dropdown" }
|
||||||
expect(header).to have_icon_in_bot_button(icon: "robot")
|
it "keeps robot icon in the header and doesn't display sidebar back link" do
|
||||||
expect(ai_pm_homepage).to have_no_sidebar_back_link
|
visit "/"
|
||||||
|
expect(header).to have_icon_in_bot_button(icon: "robot")
|
||||||
|
header.click_bot_button
|
||||||
|
expect(ai_pm_homepage).to have_homepage
|
||||||
|
expect(header).to have_icon_in_bot_button(icon: "robot")
|
||||||
|
expect(ai_pm_homepage).to have_no_sidebar_back_link
|
||||||
|
end
|
||||||
|
|
||||||
|
it "still renders the sidebar" do
|
||||||
|
visit "/"
|
||||||
|
header.click_bot_button
|
||||||
|
expect(ai_pm_homepage).to have_homepage
|
||||||
|
expect(sidebar).to be_visible
|
||||||
|
expect(header_dropdown).to be_visible
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "still renders the sidebar" do
|
context "when `ai_enable_experimental_bot_ux` is disabled" do
|
||||||
visit "/"
|
before { SiteSetting.ai_enable_experimental_bot_ux = false }
|
||||||
header.click_bot_button
|
|
||||||
expect(ai_pm_homepage).to have_homepage
|
it "opens composer on bot click" do
|
||||||
expect(sidebar).to be_visible
|
visit "/"
|
||||||
expect(header_dropdown).to be_visible
|
header.click_bot_button
|
||||||
|
|
||||||
|
expect(ai_pm_homepage).to have_no_homepage
|
||||||
|
expect(composer).to be_opened
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not render sidebar when navigation menu is set to header on pm" do
|
||||||
|
SiteSetting.navigation_menu = "header dropdown"
|
||||||
|
topic_page.visit_topic(pm)
|
||||||
|
|
||||||
|
expect(ai_pm_homepage).to have_no_homepage
|
||||||
|
expect(sidebar).to be_not_visible
|
||||||
|
expect(header_dropdown).to be_visible
|
||||||
|
end
|
||||||
|
|
||||||
|
it "shows default content in the sidebar" do
|
||||||
|
topic_page.visit_topic(pm)
|
||||||
|
|
||||||
|
expect(sidebar).to have_section("categories")
|
||||||
|
expect(sidebar).to have_section("messages")
|
||||||
|
expect(sidebar).to have_section("chat-dms")
|
||||||
|
expect(sidebar).to have_no_css("button.ai-new-question-button")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when `ai_enable_experimental_bot_ux` is disabled" do
|
context "with header dropdown on mobile", mobile: true do
|
||||||
before { SiteSetting.ai_enable_experimental_bot_ux = false }
|
before { SiteSetting.navigation_menu = "header dropdown" }
|
||||||
|
|
||||||
it "opens composer on bot click" do
|
it "displays the new question button in the menu when viewing a PM" do
|
||||||
visit "/"
|
ai_pm_homepage.visit
|
||||||
header.click_bot_button
|
header_dropdown.open
|
||||||
|
expect(ai_pm_homepage).to have_no_new_question_button
|
||||||
|
|
||||||
expect(ai_pm_homepage).to have_no_homepage
|
topic_page.visit_topic(pm)
|
||||||
expect(composer).to be_opened
|
header_dropdown.open
|
||||||
end
|
ai_pm_homepage.click_new_question_button
|
||||||
|
|
||||||
it "does not render sidebar when navigation menu is set to header on pm" do
|
# Hamburger sidebar is closed
|
||||||
SiteSetting.navigation_menu = "header dropdown"
|
expect(header_dropdown).to have_no_dropdown_visible
|
||||||
topic_page.visit_topic(pm)
|
end
|
||||||
|
end
|
||||||
expect(ai_pm_homepage).to have_no_homepage
|
|
||||||
expect(sidebar).to be_not_visible
|
|
||||||
expect(header_dropdown).to be_visible
|
|
||||||
end
|
|
||||||
|
|
||||||
it "shows default content in the sidebar" do
|
|
||||||
topic_page.visit_topic(pm)
|
|
||||||
|
|
||||||
expect(sidebar).to have_section("categories")
|
|
||||||
expect(sidebar).to have_section("messages")
|
|
||||||
expect(sidebar).to have_section("chat-dms")
|
|
||||||
expect(sidebar).to have_no_css("button.ai-new-question-button")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with header dropdown on mobile", mobile: true do
|
|
||||||
before { SiteSetting.navigation_menu = "header dropdown" }
|
|
||||||
|
|
||||||
it "displays the new question button in the menu when viewing a PM" do
|
|
||||||
ai_pm_homepage.visit
|
|
||||||
header_dropdown.open
|
|
||||||
expect(ai_pm_homepage).to have_no_new_question_button
|
|
||||||
|
|
||||||
topic_page.visit_topic(pm)
|
|
||||||
header_dropdown.open
|
|
||||||
ai_pm_homepage.click_new_question_button
|
|
||||||
|
|
||||||
# Hamburger sidebar is closed
|
|
||||||
expect(header_dropdown).to have_no_dropdown_visible
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue