|
110 | 110 |
|
111 | 111 | context "when glimmer_post_stream_mode=#{value}" do |
112 | 112 | context "when `ai_enable_experimental_bot_ux` is enabled" do |
| 113 | + it "allows uploading files to a new conversation" do |
| 114 | + ai_pm_homepage.visit |
| 115 | + expect(ai_pm_homepage).to have_homepage |
| 116 | + |
| 117 | + file_path_1 = file_from_fixtures("logo.png", "images").path |
| 118 | + file_path_2 = file_from_fixtures("logo.jpg", "images").path |
| 119 | + |
| 120 | + attach_file([file_path_1, file_path_2]) do |
| 121 | + find(".ai-bot-upload-btn", visible: true).click |
| 122 | + end |
| 123 | + |
| 124 | + expect(page).to have_css(".ai-bot-upload", count: 2) |
| 125 | + |
| 126 | + ai_pm_homepage.input.fill_in(with: "Here are two image attachments") |
| 127 | + |
| 128 | + responses = ["hello user", "topic title"] |
| 129 | + DiscourseAi::Completions::Llm.with_prepared_responses(responses) do |
| 130 | + ai_pm_homepage.submit |
| 131 | + expect(topic_page).to have_content("Here are two image attachments") |
| 132 | + expect(page).to have_css(".cooked img", count: 2) |
| 133 | + end |
| 134 | + end |
| 135 | + |
| 136 | + it "allows removing an upload before submission" do |
| 137 | + ai_pm_homepage.visit |
| 138 | + expect(ai_pm_homepage).to have_homepage |
| 139 | + |
| 140 | + file_path = file_from_fixtures("logo.png", "images").path |
| 141 | + attach_file([file_path]) { find(".ai-bot-upload-btn", visible: true).click } |
| 142 | + |
| 143 | + expect(page).to have_css(".ai-bot-upload", count: 1) |
| 144 | + |
| 145 | + find(".ai-bot-upload__remove").click |
| 146 | + |
| 147 | + expect(page).to have_no_css(".ai-bot-upload") |
| 148 | + |
| 149 | + ai_pm_homepage.input.fill_in(with: "Message without attachments") |
| 150 | + |
| 151 | + responses = ["hello user", "topic title"] |
| 152 | + DiscourseAi::Completions::Llm.with_prepared_responses(responses) do |
| 153 | + ai_pm_homepage.submit |
| 154 | + expect(topic_page).to have_content("Message without attachments") |
| 155 | + expect(page).to have_no_css(".cooked img") |
| 156 | + end |
| 157 | + end |
| 158 | + |
113 | 159 | it "renders landing page on bot click" do |
114 | 160 | visit "/" |
115 | 161 | header.click_bot_button |
|
0 commit comments