|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -RSpec.describe "AI Bot - Personal Message", type: :system do |
| 3 | +RSpec.describe "AI Bot - Homepage", type: :system do |
4 | 4 | let(:topic_page) { PageObjects::Pages::Topic.new } |
5 | 5 | let(:composer) { PageObjects::Components::Composer.new } |
6 | 6 | let(:ai_pm_homepage) { PageObjects::Components::AiPmHomepage.new } |
|
9 | 9 | let(:dialog) { PageObjects::Components::Dialog.new } |
10 | 10 |
|
11 | 11 | fab!(:user) { Fabricate(:user, refresh_auto_groups: true) } |
| 12 | + fab!(:user_2) { Fabricate(:user, refresh_auto_groups: true) } |
12 | 13 |
|
13 | 14 | fab!(:claude_2) do |
14 | 15 | Fabricate( |
|
88 | 89 | sign_in(user) |
89 | 90 | end |
90 | 91 |
|
91 | | - it "has normal bot interaction when `ai_enable_experimental_bot_ux` is disabled" do |
92 | | - SiteSetting.ai_enable_experimental_bot_ux = false |
93 | | - visit "/" |
94 | | - find(".ai-bot-button").click |
95 | | - |
96 | | - expect(ai_pm_homepage).to have_no_homepage |
97 | | - expect(composer).to be_opened |
98 | | - end |
99 | | - |
100 | 92 | context "when `ai_enable_experimental_bot_ux` is enabled" do |
101 | 93 | it "renders landing page on bot click" do |
102 | 94 | visit "/" |
|
181 | 173 | composer.submit |
182 | 174 | expect(page).to have_content("Hello bot replying to you") |
183 | 175 | end |
| 176 | + |
| 177 | + it "does not render custom sidebar on non-authored bot pms" do |
| 178 | + # Include user_2 in the PM by creating a new post and topic_allowed_user association |
| 179 | + Fabricate(:post, topic: pm, user: user_2, post_number: 4) |
| 180 | + Fabricate(:topic_allowed_user, topic: pm, user: user_2) |
| 181 | + sign_in(user_2) |
| 182 | + topic_page.visit_topic(pm) |
| 183 | + |
| 184 | + expect(sidebar).to be_visible |
| 185 | + expect(sidebar).to have_no_section("ai-conversations-history") |
| 186 | + expect(sidebar).to have_no_css("button.ai-new-question-button") |
| 187 | + end |
| 188 | + |
| 189 | + it "does not include non-authored bot pms in sidebar" do |
| 190 | + # Include user_2 in the PM by creating a new post and topic_allowed_user association |
| 191 | + Fabricate(:post, topic: pm, user: user_2, post_number: 4) |
| 192 | + Fabricate(:topic_allowed_user, topic: pm, user: user_2) |
| 193 | + sign_in(user_2) |
| 194 | + |
| 195 | + visit "/" |
| 196 | + find(".ai-bot-button").click |
| 197 | + expect(ai_pm_homepage).to have_homepage |
| 198 | + expect(sidebar).to have_no_section_link(pm.title) |
| 199 | + end |
| 200 | + end |
| 201 | + |
| 202 | + context "when `ai_enable_experimental_bot_ux` is disabled" do |
| 203 | + before { SiteSetting.ai_enable_experimental_bot_ux = false } |
| 204 | + |
| 205 | + it "opens composer on bot click" do |
| 206 | + visit "/" |
| 207 | + find(".ai-bot-button").click |
| 208 | + |
| 209 | + expect(ai_pm_homepage).to have_no_homepage |
| 210 | + expect(composer).to be_opened |
| 211 | + end |
| 212 | + |
| 213 | + it "does not render sidebar when navigation menu is set to header on pm" do |
| 214 | + SiteSetting.navigation_menu = "header dropdown" |
| 215 | + topic_page.visit_topic(pm) |
| 216 | + |
| 217 | + expect(ai_pm_homepage).to have_no_homepage |
| 218 | + expect(sidebar).to be_not_visible |
| 219 | + expect(header_dropdown).to be_visible |
| 220 | + end |
| 221 | + |
| 222 | + it "shows default content in the sidebar" do |
| 223 | + topic_page.visit_topic(pm) |
| 224 | + |
| 225 | + expect(sidebar).to have_section("categories") |
| 226 | + expect(sidebar).to have_section("messages") |
| 227 | + expect(sidebar).to have_section("chat-dms") |
| 228 | + expect(sidebar).to have_section("user-threads") |
| 229 | + expect(sidebar).to have_no_css("button.ai-new-question-button") |
| 230 | + end |
184 | 231 | end |
185 | 232 | end |
0 commit comments