discourse-ai/spec/system/ai_bot/ai_bot_helper_spec.rb
Sam 8b1b6811f4
FEATURE: add support for uploads when starting a convo (#1301)
This commit introduces file upload capabilities to the AI Bot conversations interface and improves the overall dedicated UX experience. It also changes the experimental setting to a more permanent one.

## Key changes:

- **File upload support**:
  - Integrates UppyUpload for handling file uploads in conversations
  - Adds UI for uploading, displaying, and managing attachments
  - Supports drag & drop, clipboard paste, and manual file selection
  - Shows upload progress indicators for in-progress uploads
  - Appends uploaded file markdown to message content

- **Renamed setting**:
  - Changed `ai_enable_experimental_bot_ux` to `ai_bot_enable_dedicated_ux`
  - Updated setting description to be clearer
  - Changed default value to `true` as this is now a stable feature
  - Added migration to handle the setting name change in database

- **UI improvements**:
  - Enhanced input area with better focus states
  - Improved layout and styling for conversations page
  - Added visual feedback for upload states
  - Better error handling for uploads in progress

- **Code organization**:
  - Refactored message submission logic to handle attachments
  - Updated DOM element IDs for consistency
  - Fixed focus management after submission

- **Added tests**:
  - Tests for file upload functionality
  - Tests for removing uploads before submission
  - Updated existing tests to work with the renamed setting


---------

Co-authored-by: awesomerobot <kris.aubuchon@discourse.org>
2025-05-01 12:21:07 +10:00

61 lines
1.9 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "AI chat channel summarization", type: :system, js: true do
fab!(:user)
fab!(:group) { Fabricate(:group, visibility_level: Group.visibility_levels[:staff]) }
fab!(:gpt_4) { Fabricate(:llm_model, name: "gpt-4") }
fab!(:gpt_3_5_turbo) { Fabricate(:llm_model, name: "gpt-3.5-turbo") }
before do
SiteSetting.ai_bot_enabled = true
toggle_enabled_bots(bots: [gpt_4, gpt_3_5_turbo])
SiteSetting.ai_bot_allowed_groups = group.id.to_s
sign_in(user)
end
it "does not show AI button to users not in group" do
visit "/latest"
expect(page).not_to have_selector(".ai-bot-button")
end
it "shows the AI bot button, which is clickable (even if group is hidden)" do
# test was authored with this in mind
SiteSetting.ai_bot_enable_dedicated_ux = false
group.add(user)
group.save
allowed_persona = AiPersona.last
allowed_persona.update!(allowed_group_ids: [group.id], enabled: true)
visit "/latest"
expect(page).to have_selector(".ai-bot-button")
find(".ai-bot-button").click
find(".gpt-persona").click
expect(page).to have_css(".gpt-persona ul li", count: 1)
find(".llm-selector").click
expect(page).to have_css(".llm-selector ul li", count: 2)
expect(page).to have_selector(".d-editor-container")
# lets disable bots but still allow 1 persona
allowed_persona.create_user!
allowed_persona.update!(default_llm_id: gpt_4.id)
gpt_4.update!(enabled_chat_bot: false)
gpt_3_5_turbo.update!(enabled_chat_bot: false)
visit "/latest"
find(".ai-bot-button").click
find(".gpt-persona").click
expect(page).to have_css(".gpt-persona ul li", count: 1)
expect(page).not_to have_selector(".llm-selector")
SiteSetting.ai_bot_add_to_header = false
visit "/latest"
expect(page).not_to have_selector(".ai-bot-button")
end
end