Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 48fff48

Browse files
authored
FIX: failing image caption spec (#1195)
1 parent bd40076 commit 48fff48

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed
14.5 KB
Loading

spec/system/ai_helper/ai_image_caption_spec.rb

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
let(:composer) { PageObjects::Components::Composer.new }
1111
let(:popup) { PageObjects::Components::AiCaptionPopup.new }
1212
let(:dialog) { PageObjects::Components::Dialog.new }
13-
let(:file_path) { file_from_fixtures("logo.jpg", "images").path }
13+
let(:file_path) { plugin_file_from_fixtures("100x100.jpg").path }
14+
let(:captioned_image_path) do
15+
plugin_file_from_fixtures("An image of discobot in action.png").path
16+
end
1417
let(:caption) do
1518
"The image shows a stylized speech bubble icon with a multicolored border on a black background."
1619
end
@@ -123,12 +126,9 @@
123126
end
124127

125128
it "should not show a prompt when submitting a post with no captionable images uploaded" do
126-
original_file_path = Rails.root.join("spec/fixtures/images/logo.jpg")
127-
temp_file_path = Rails.root.join("spec/fixtures/images/An image of Discourse logo.jpg")
128-
FileUtils.cp(original_file_path, temp_file_path)
129129
visit("/latest")
130130
page.find("#create-topic").click
131-
attach_file([temp_file_path]) { composer.click_toolbar_button("upload") }
131+
attach_file([captioned_image_path]) { composer.click_toolbar_button("upload") }
132132
wait_for { composer.has_no_in_progress_uploads? }
133133
composer.fill_title("I love using Discourse! It is my favorite forum software")
134134
composer.create
@@ -150,25 +150,6 @@
150150
end
151151
end
152152

153-
context "when the user preference is enabled" do
154-
before { user.user_option.update!(auto_image_caption: true) }
155-
156-
skip "TODO: Fix auto_image_caption user option not present in testing environment?" do
157-
it "should auto caption the image after uploading" do
158-
DiscourseAi::Completions::Llm.with_prepared_responses([caption]) do
159-
visit("/latest")
160-
page.find("#create-topic").click
161-
attach_file([Rails.root.join("spec/fixtures/images/logo.jpg")]) do
162-
composer.click_toolbar_button("upload")
163-
end
164-
wait_for { composer.has_no_in_progress_uploads? }
165-
wait_for { page.find(".image-wrapper img")["alt"] == caption_with_attrs }
166-
expect(page.find(".image-wrapper img")["alt"]).to eq(caption_with_attrs)
167-
end
168-
end
169-
end
170-
end
171-
172153
context "when a post has no uploads" do
173154
before { user.user_option.update!(auto_image_caption: true) }
174155

0 commit comments

Comments
 (0)