Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 5 additions & 24 deletions spec/system/ai_helper/ai_image_caption_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
let(:composer) { PageObjects::Components::Composer.new }
let(:popup) { PageObjects::Components::AiCaptionPopup.new }
let(:dialog) { PageObjects::Components::Dialog.new }
let(:file_path) { file_from_fixtures("logo.jpg", "images").path }
let(:file_path) { plugin_file_from_fixtures("100x100.jpg").path }
let(:captioned_image_path) do
plugin_file_from_fixtures("An image of discobot in action.png").path
end
let(:caption) do
"The image shows a stylized speech bubble icon with a multicolored border on a black background."
end
Expand Down Expand Up @@ -123,12 +126,9 @@
end

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

context "when the user preference is enabled" do
before { user.user_option.update!(auto_image_caption: true) }

skip "TODO: Fix auto_image_caption user option not present in testing environment?" do
it "should auto caption the image after uploading" do
DiscourseAi::Completions::Llm.with_prepared_responses([caption]) do
visit("/latest")
page.find("#create-topic").click
attach_file([Rails.root.join("spec/fixtures/images/logo.jpg")]) do
composer.click_toolbar_button("upload")
end
wait_for { composer.has_no_in_progress_uploads? }
wait_for { page.find(".image-wrapper img")["alt"] == caption_with_attrs }
expect(page.find(".image-wrapper img")["alt"]).to eq(caption_with_attrs)
end
end
end
end

context "when a post has no uploads" do
before { user.user_option.update!(auto_image_caption: true) }

Expand Down