Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add end-to-end test for OCR in media uploads #29148

Merged
merged 1 commit into from
Feb 8, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class UploadButton extends ImmutablePureComponent {
key={resetFileKey}
ref={this.setRef}
type='file'
name='file-upload-input'
multiple
accept={acceptContentTypes.toArray().join(',')}
onChange={this.handleChange}
Expand Down
Binary file added spec/fixtures/files/text.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions spec/system/ocr_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require 'rails_helper'

describe 'OCR', :paperclip_processing, :sidekiq_inline do
include ProfileStories

let(:email) { 'test@example.com' }
let(:password) { 'password' }
let(:confirmed_at) { Time.zone.now }
let(:finished_onboarding) { true }

before do
as_a_logged_in_user
visit root_path
end

it 'can recognize text in a media attachment' do
expect(page).to have_css('div.app-holder')

within('.compose-form') do
attach_file('file-upload-input', file_fixture('text.png'), make_visible: true)

within('.compose-form__upload') do
click_on('Edit')
end
end

click_on('Detect text from picture')
ClearlyClaire marked this conversation as resolved.
Show resolved Hide resolved

expect(page).to have_css('#upload-modal__description', text: 'Hello Mastodon')
end
end