OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
refactor: Extract spec uploading code in a class
Christophe Bliard97600a6c49e8
diff --git a/modules/budgets/spec/features/budgets/attachment_upload_spec.rb b/modules/budgets/spec/features/budgets/attachment_upload_spec.rbindex 7dd24e0c96f..f4999408ce2 100644--- a/modules/budgets/spec/features/budgets/attachment_upload_spec.rb+++ b/modules/budgets/spec/features/budgets/attachment_upload_spec.rb@@ -37,6 +37,7 @@ describe 'Upload attachment to budget', js: true dolet(:attachments) { Components::Attachments.new }let(:image_fixture) { UploadedFile.load_from('spec/fixtures/files/image.png') }let(:editor) { Components::WysiwygEditor.new }+ let(:attachments_list) { Components::AttachmentsList.new }before dologin_as(user)@@ -54,13 +55,13 @@ describe 'Upload attachment to budget', js: true do# adding an imageeditor.drag_attachment image_fixture.path, 'Image uploaded on creation'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')+ editor.attachments_list.expect_attached('image.png')click_on 'Create'expect(page).to have_selector('#content img', count: 1)expect(page).to have_content('Image uploaded on creation')- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')+ attachments_list.expect_attached('image.png')within '.toolbar-items' doclick_on "Update"@@ -68,14 +69,14 @@ describe 'Upload attachment to budget', js: true doeditor.drag_attachment image_fixture.path, 'Image uploaded the second time'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)+ editor.attachments_list.expect_attached('image.png', count: 2)click_on 'Submit'expect(page).to have_selector('#content img', count: 2)expect(page).to have_content('Image uploaded on creation')expect(page).to have_content('Image uploaded the second time')- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)+ attachments_list.expect_attached('image.png', count: 2)endit 'can upload an image to new and existing budgets via drag & drop on attachment list' do@@ -89,33 +90,26 @@ describe 'Upload attachment to budget', js: true doeditor.set_markdown "Some content because it's required"# adding an image- find("[data-qa-selector='op-attachments--drop-box']").drop(image_fixture.path)+ editor.attachments_list.drop(image_fixture)- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')+ editor.attachments_list.expect_attached('image.png')click_on 'Create'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')+ attachments_list.expect_attached('image.png')within '.toolbar-items' doclick_on "Update"end- # Wait for page load- expect(page).to have_selector('[data-qa-selector="op-attachments"]')- script = <<~JS- const event = new DragEvent('dragenter');- document.body.dispatchEvent(event);- JS- page.execute_script(script)-# adding an image- find("[data-qa-selector='op-attachments--drop-box']").drop(image_fixture.path)+ editor.attachments_list.drag_enter+ editor.attachments_list.drop(image_fixture)- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)+ editor.attachments_list.expect_attached('image.png', count: 2)click_on 'Submit'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)+ attachments_list.expect_attached('image.png', count: 2)endenddiff --git a/modules/documents/spec/features/attachment_upload_spec.rb b/modules/documents/spec/features/attachment_upload_spec.rbindex 43eb2c0a968..52802071614 100644--- a/modules/documents/spec/features/attachment_upload_spec.rb+++ b/modules/documents/spec/features/attachment_upload_spec.rb@@ -53,6 +53,7 @@ describe 'Upload attachment to documents',let(:attachments) { Components::Attachments.new }let(:image_fixture) { UploadedFile.load_from('spec/fixtures/files/image.png') }let(:editor) { Components::WysiwygEditor.new }+ let(:attachments_list) { Components::AttachmentsList.new }before dologin_as(user)@@ -70,12 +71,12 @@ describe 'Upload attachment to documents',# adding an image via the attachments-listfind("[data-qa-selector='op-attachments--drop-box']").drop(image_fixture.path)- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 1)+ editor.attachments_list.expect_attached('image.png')# adding an imageeditor.drag_attachment image_fixture.path, 'Image uploaded on creation'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.attachments_list.expect_attached('image.png', count: 2)+ editor.wait_until_upload_progress_toaster_clearedperform_enqueued_jobs doclick_on 'Create'@@ -104,26 +105,18 @@ describe 'Upload attachment to documents',# editor.click_and_type_slowly 'abc'SeleniumHubWaiter.wait- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)+ editor.attachments_list.expect_attached('image.png', count: 2)editor.drag_attachment image_fixture.path, 'Image uploaded the second time'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 3)+ editor.attachments_list.expect_attached('image.png', count: 3)- scroll_to_element(page.find('[data-qa-selector="op-attachments"]'))+ editor.attachments_list.drag_enter+ editor.attachments_list.drop(image_fixture)- script = <<~JS- const event = new DragEvent('dragenter');- document.body.dispatchEvent(event);- JS- page.execute_script(script)+ editor.attachments_list.expect_attached('image.png', count: 4)- # adding an image via the attachments-list- find("[data-qa-selector='op-attachments--drop-box']").drop(image_fixture.path)-- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 4)-- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.wait_until_upload_progress_toaster_clearedperform_enqueued_jobs doclick_on 'Save'@@ -133,7 +126,7 @@ describe 'Upload attachment to documents',expect(page).to have_selector('#content img', count: 2)expect(page).to have_content('Image uploaded on creation')expect(page).to have_content('Image uploaded the second time')- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 4)+ attachments_list.expect_attached('image.png', count: 4)# Expect a mail to be sent to the user having subscribed to all notificationsexpect(ActionMailer::Base.deliveries.size)diff --git a/modules/meeting/spec/features/meetings_attachments_spec.rb b/modules/meeting/spec/features/meetings_attachments_spec.rbindex 8076385e05f..a8de9154c1a 100644--- a/modules/meeting/spec/features/meetings_attachments_spec.rb+++ b/modules/meeting/spec/features/meetings_attachments_spec.rb@@ -24,6 +24,7 @@ describe 'Add an attachment to a meeting (agenda)', js: true dolet(:attachments) { Components::Attachments.new }let(:image_fixture) { UploadedFile.load_from('spec/fixtures/files/image.png') }let(:editor) { Components::WysiwygEditor.new }+ let(:attachments_list) { Components::AttachmentsList.new }before dologin_as(dev)@@ -56,24 +57,22 @@ describe 'Add an attachment to a meeting (agenda)', js: true dodescribe 'attachment dropzone' doit 'can upload an image via attaching and drag & drop' do- # called the same for all Wysiwyg dditors no matter if for work packages- # or not- container = page.find('[data-qa-selector="op-attachments"]')- scroll_to_element(container)+ editor.wait_until_loaded+ attachments_list.wait_until_visible### Attach file manually- expect(page).not_to have_selector('[data-qa-selector="op-files-tab--file-list-item-title"]')+ editor.attachments_list.expect_emptyattachments.attach_file_on_input(image_fixture.path)- expect(page).not_to have_selector('op-toasters-upload-progress')- expect(page).to have_selector('[data-qa-selector="op-files-tab--file-list-item-title"]', text: 'image.png', wait: 5)+ editor.wait_until_upload_progress_toaster_cleared+ editor.attachments_list.expect_attached('image.png')### and via drag & drop- attachments.drag_and_drop_file(container, image_fixture.path)- expect(page).not_to have_selector('op-toasters-upload-progress')- expect(page)- .to have_selector('[data-qa-selector="op-files-tab--file-list-item-title"]', text: 'image.png', count: 2, wait: 5)+ editor.attachments_list.drag_enter+ editor.attachments_list.drop(image_fixture)+ editor.wait_until_upload_progress_toaster_cleared+ editor.attachments_list.expect_attached('image.png', count: 2)endendenddiff --git a/spec/features/admin/attribute_help_texts_spec.rb b/spec/features/admin/attribute_help_texts_spec.rbindex 7c474ed65e6..7c58650868b 100644--- a/spec/features/admin/attribute_help_texts_spec.rb+++ b/spec/features/admin/attribute_help_texts_spec.rb@@ -57,7 +57,7 @@ describe 'Attribute help texts', js: true doeditor.set_markdown('My attribute help text')editor.drag_attachment image_fixture.path, 'Image uploaded on creation'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')+ editor.attachments_list.expect_attached('image.png')click_button 'Save'expect(instance.help_text).to include 'My attribute help text'@@ -81,7 +81,7 @@ describe 'Attribute help texts', js: true do# Add an image# adding an imageeditor.drag_attachment image_fixture.path, 'Image uploaded on creation'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')+ editor.attachments_list.expect_attached('image.png')click_button 'Save'# Should now show on index for editingdiff --git a/spec/features/forums/attachment_upload_spec.rb b/spec/features/forums/attachment_upload_spec.rbindex b82a8a4bffa..93bae34d48d 100644--- a/spec/features/forums/attachment_upload_spec.rb+++ b/spec/features/forums/attachment_upload_spec.rb@@ -39,9 +39,9 @@ describe 'Upload attachment to forum message', js: true doedit_messages])endlet(:project) { forum.project }- let(:attachments) { Components::Attachments.new }let(:image_fixture) { UploadedFile.load_from('spec/fixtures/files/image.png') }let(:editor) { Components::WysiwygEditor.new }+ let(:attachments_list) { Components::AttachmentsList.new }let(:index_page) { Pages::Messages::Index.new(forum.project) }before do@@ -59,14 +59,14 @@ describe 'Upload attachment to forum message', js: true dosleep 20editor.drag_attachment image_fixture.path, 'Image uploaded on creation'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.attachments_list.expect_attached('image.png')+ editor.wait_until_upload_progress_toaster_clearedshow_page = create_page.click_saveexpect(page).to have_selector('#content .wiki img', count: 1)expect(page).to have_content('Image uploaded on creation')- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')+ attachments_list.expect_attached('image.png')within '.toolbar-items' doclick_on "Edit"@@ -79,8 +79,8 @@ describe 'Upload attachment to forum message', js: true doeditor.drag_attachment image_fixture.path, 'Image uploaded the second time'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.attachments_list.expect_attached('image.png', count: 2)+ editor.wait_until_upload_progress_toaster_clearedshow_page.click_save@@ -88,7 +88,7 @@ describe 'Upload attachment to forum message', js: true doexpect(page).to have_content('Image uploaded on creation')expect(page).to have_content('Image uploaded the second time')- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)+ attachments_list.expect_attached('image.png', count: 2)endit 'can upload an image to new and existing messages via drag & drop on attachments' do@@ -98,38 +98,32 @@ describe 'Upload attachment to forum message', js: true docreate_page = index_page.click_create_messagecreate_page.set_subject 'A new message'- expect(page).not_to have_selector('[data-qa-selector="op-attachment-list-item"]')+ editor.attachments_list.expect_emptyeditor.set_markdown "Some text because it's required"# adding an image- find("[data-qa-selector='op-attachments--drop-box']").drop(image_fixture.path)+ editor.attachments_list.drop(image_fixture)- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.attachments_list.expect_attached('image.png')+ editor.wait_until_upload_progress_toaster_clearedshow_page = create_page.click_save- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')+ attachments_list.expect_attached('image.png')within '.toolbar-items' doclick_on "Edit"end- page.find("[data-qa-selector='op-attachments']") # wait for attachments element to be displayed before starting drag and drop- script = <<~JS- const event = new DragEvent('dragenter');- document.body.dispatchEvent(event);- JS- page.execute_script(script)+ editor.attachments_list.drag_enter+ editor.attachments_list.drop(image_fixture)- find("[data-qa-selector='op-attachments--drop-box']").drop(image_fixture.path)-- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.attachments_list.expect_attached('image.png', count: 2)+ editor.wait_until_upload_progress_toaster_clearedshow_page.click_save- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)+ attachments_list.expect_attached('image.png', count: 2)endenddiff --git a/spec/features/wiki/attachment_upload_spec.rb b/spec/features/wiki/attachment_upload_spec.rbindex 99593e31721..9408f9d63e6 100644--- a/spec/features/wiki/attachment_upload_spec.rb+++ b/spec/features/wiki/attachment_upload_spec.rb@@ -39,6 +39,7 @@ describe 'Upload attachment to wiki page', js: true dolet(:attachments) { Components::Attachments.new }let(:image_fixture) { UploadedFile.load_from('spec/fixtures/files/image.png') }let(:editor) { Components::WysiwygEditor.new }+ let(:attachments_list) { Components::AttachmentsList.new }let(:wiki_page_content) { project.wiki.pages.first.content.text }before do@@ -51,15 +52,15 @@ describe 'Upload attachment to wiki page', js: true do# adding an imageeditor.drag_attachment image_fixture.path, 'Image uploaded the first time'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.attachments_list.expect_attached('image.png')+ editor.wait_until_upload_progress_toaster_clearedclick_on 'Save'expect(page).to have_text("Successful creation")expect(page).to have_selector('#content img', count: 1)expect(page).to have_content('Image uploaded the first time')- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')+ attachments_list.expect_attached('image.png')# required sleep otherwise clicking on the Edit button doesn't do anythingSeleniumHubWaiter.wait@@ -69,12 +70,12 @@ describe 'Upload attachment to wiki page', js: true doend# Replace the image with a named attachment URL (Regression #28381)- expect(page).to have_selector('.ck-editor__editable', wait: 5)+ editor.wait_until_loadededitor.set_markdown "\n\nSome text\n\n\nText that prevents the two images colliding"editor.drag_attachment image_fixture.path, 'Image uploaded the second time'- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)+ editor.attachments_list.expect_attached('image.png', count: 2)editor.in_editor do |container, _|# Expect URL is mapped to the correct URL@@ -92,7 +93,7 @@ describe 'Upload attachment to wiki page', js: true doexpect(page).to have_selector('#content img', count: 2)# First figcaption is lost by having replaced the markdownexpect(page).to have_content('Image uploaded the second time')- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)+ attachments_list.expect_attached('image.png', count: 2)# Both images rendered referring to the api endpointexpect(page).to have_selector('img[src^="/api/v3/attachments/"]', count: 2)@@ -106,18 +107,18 @@ describe 'Upload attachment to wiki page', js: true doit 'can upload an image to new and existing wiki page via drag & drop on attachments' dovisit project_wiki_path(project, 'test')- expect(page).not_to have_selector('[data-qa-selector="op-attachment-list-item"]')+ editor.attachments_list.expect_empty# adding an image- find("[data-qa-selector='op-attachments--drop-box']").drop(image_fixture.path)+ editor.attachments_list.drop(image_fixture.path)- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.attachments_list.expect_attached('image.png')+ editor.wait_until_upload_progress_toaster_clearedclick_on 'Save'expect(page).to have_text("Successful creation")- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png')+ attachments_list.expect_attached('image.png')# required sleep otherwise clicking on the Edit button doesn't do anythingSeleniumHubWaiter.wait@@ -126,22 +127,15 @@ describe 'Upload attachment to wiki page', js: true doclick_on "Edit"end- expect(page).to have_selector('.ck-editor__editable', wait: 5)-- script = <<~JS- const event = new DragEvent('dragenter');- document.body.dispatchEvent(event);- JS- page.execute_script(script)-# adding an image- find("[data-qa-selector='op-attachments--drop-box']").drop(image_fixture.path)+ editor.attachments_list.drag_enter+ editor.attachments_list.drop(image_fixture)- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.attachments_list.expect_attached('image.png', count: 2)+ editor.wait_until_upload_progress_toaster_clearedclick_on 'Save'expect(page).to have_text("Successful update")- expect(page).to have_selector('[data-qa-selector="op-attachment-list-item"]', text: 'image.png', count: 2)+ attachments_list.expect_attached('image.png', count: 2)endenddiff --git a/spec/features/work_packages/attachments/attachment_upload_spec.rb b/spec/features/work_packages/attachments/attachment_upload_spec.rbindex eaafe1091ac..c9cc525d471 100644--- a/spec/features/work_packages/attachments/attachment_upload_spec.rb+++ b/spec/features/work_packages/attachments/attachment_upload_spec.rb@@ -123,7 +123,7 @@ describe 'Upload attachment to work package', js: true doattachments.drag_and_drop_file(target, image_fixture.path)sleep 2- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.wait_until_upload_progress_toaster_clearededitor.in_editor do |_container, editable|expect(editable).to have_selector('img[src*="/api/v3/attachments/"]', wait: 20)@@ -191,7 +191,7 @@ describe 'Upload attachment to work package', js: true doattachments.drag_and_drop_file(target, image_fixture.path)sleep 2- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.wait_until_upload_progress_toaster_clearededitor.in_editor do |_container, editable|expect(editable).to have_selector('img[src*="/api/v3/attachments/"]', wait: 20)@@ -253,7 +253,7 @@ describe 'Upload attachment to work package', js: true dopage.find('[data-qa-tab-id="files"]')expect(page).to have_selector('[data-qa-selector="op-files-tab--file-list-item-title"]', text: 'image.png', wait: 10)- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.wait_until_upload_progress_toaster_clearedwp_page.expect_tab 'Files'end@@ -276,13 +276,13 @@ describe 'Upload attachment to work package', js: true do# Attach file manuallyexpect(page).not_to have_selector('[data-qa-selector="op-files-tab--file-list-item-title"]')attachments.attach_file_on_input(image_fixture.path)- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.wait_until_upload_progress_toaster_clearedexpect(page).to have_selector('[data-qa-selector="op-files-tab--file-list-item-title"]', text: 'image.png', wait: 5)### and via drag & dropattachments.drag_and_drop_file(container, image_fixture.path)- expect(page).not_to have_selector('op-toasters-upload-progress')+ editor.wait_until_upload_progress_toaster_clearedexpect(page).to have_selector('[data-qa-selector="op-files-tab--file-list-item-title"]', text: 'image.png', count: 2, wait: 5)enddiff --git a/spec/support/components/attachments_list.rb b/spec/support/components/attachments_list.rbnew file mode 100644index 00000000000..9e99305d08f--- /dev/null+++ b/spec/support/components/attachments_list.rb@@ -0,0 +1,49 @@+# Handles attachments list generally found under the wysiwyg editor.+module Components+ class AttachmentsList+ include Capybara::DSL+ include Capybara::RSpecMatchers+ include RSpec::Matchers++ attr_reader :context_selector++ def initialize(context = '#content')+ @context_selector = context+ end++ # Simulates start dragging a file into the window by sending a "dragenter" event.+ def drag_enter+ wait_until_visible # element must be visible before any drag and drop+ page.execute_script <<~JS+ const event = new DragEvent('dragenter');+ document.body.dispatchEvent(event);+ JS+ end++ # Drops a file into the attachments list drop box.+ def drop(file)+ path = file.to_s+ drop_box_element.drop(path)+ end++ def expect_empty+ expect(page).not_to have_selector("#{context_selector} [data-qa-selector='op-attachment-list-item']")+ end++ def expect_attached(name, count: 1)+ expect(page).to have_selector("#{context_selector} [data-qa-selector='op-attachment-list-item']", text: name, count:)+ end++ def wait_until_visible+ element.tap { scroll_to_element(_1) }+ end++ def element+ page.find("#{context_selector} [data-qa-selector='op-attachments']")+ end++ def drop_box_element+ find("#{context_selector} [data-qa-selector='op-attachments--drop-box']")+ end+ end+enddiff --git a/spec/support/components/wysiwyg/wysiwyg_editor.rb b/spec/support/components/wysiwyg/wysiwyg_editor.rbindex 4f9cd0eb0d6..802cbcc46e6 100644--- a/spec/support/components/wysiwyg/wysiwyg_editor.rb+++ b/spec/support/components/wysiwyg/wysiwyg_editor.rb@@ -3,11 +3,13 @@ module Componentsinclude Capybara::DSLinclude Capybara::RSpecMatchersinclude RSpec::Matchers- attr_reader :context_selector, :attachments++ attr_reader :context_selector, :attachments, :attachments_listdef initialize(context = '#content')@context_selector = context@attachments = ::Components::Attachments.new+ @attachments_list = ::Components::AttachmentsList.new("#{context} ckeditor-augmented-textarea")enddef container@@ -27,8 +29,7 @@ module Componentsenddef set_markdown(text)- # wait for element to be loaded- editor_element+ wait_until_loadedtextarea = container.find('.op-ckeditor-source-element', visible: :all)page.execute_script(@@ -73,7 +74,7 @@ module Componentsend##- # Create an image fixture with the optional caption+ # Create an image fixture with the optional caption from inside the ckeditordef drag_attachment(image_fixture, caption = 'Some caption')in_editor do |_container, editable|# Click the latest figure, if any@@ -94,7 +95,7 @@ module Componentsexpect(page).to have_selector('img[src^="/api/v3/attachments/"]', count: images.length + 1, wait: 10)- expect(page).not_to have_selector('op-toasters-upload-progress', wait: 5)+ wait_until_upload_progress_toaster_cleared# Get the image uploaded last. As there is no way to distinguish between# two uploaded images, from the perspective of the user, we do it by getting@@ -126,6 +127,14 @@ module Componentsendend+ def wait_until_upload_progress_toaster_cleared+ page.has_no_selector?('op-toasters-upload-progress')+ end++ def wait_until_loaded+ editor_element+ end+def refocuseditor_element.first('*').clickrescue StandardError => ediff --git a/spec/support/uploaded_file.rb b/spec/support/uploaded_file.rbindex 6865499fa38..75ddea8bda4 100644--- a/spec/support/uploaded_file.rb+++ b/spec/support/uploaded_file.rb@@ -21,7 +21,7 @@ class UploadedFilefull_path = Rails.root.join(path)shared_path = DownloadList::SHARED_PATH.join(File.basename(full_path))# with remote drivers, files to upload must be in the shared downloads folder- FileUtils.cp(full_path, shared_path, verbose: true)+ FileUtils.cp(full_path, shared_path)new(shared_path)endend