Skip to content

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

Fix attachment spec

Oliver Günther6bb893c9b0e6
diff --git a/spec/features/wiki/attachment_upload_spec.rb b/spec/features/wiki/attachment_upload_spec.rb
index 28eb745eba1..a06fea27e76 100644
--- a/spec/features/wiki/attachment_upload_spec.rb
+++ b/spec/features/wiki/attachment_upload_spec.rb
@@ -89,7 +89,7 @@ describe 'Upload attachment to wiki page', js: true do
end
editor.click_hover_toolbar_button 'Resize image to 50%'
- expect(page).to have_selector('.op-uc-figure[style="width:50%;"')
+ expect(page).to have_selector('.op-uc-figure[style="width:50%;"]')
click_on 'Save'
diff --git a/spec/support/components/wysiwyg/wysiwyg_editor.rb b/spec/support/components/wysiwyg/wysiwyg_editor.rb
index 19c2f56ecfe..63c60dc5c1b 100644
--- a/spec/support/components/wysiwyg/wysiwyg_editor.rb
+++ b/spec/support/components/wysiwyg/wysiwyg_editor.rb
@@ -72,7 +72,13 @@ module Components
# Create an image fixture with the optional caption
def drag_attachment(image_fixture, caption = 'Some caption')
in_editor do |_container, editable|
- sleep 0.5
+ sleep 1
+
+ # Click the latest figure, if any
+ images = editable.all('figure.image')
+ if images.count > 0
+ images.last.click
+ end
# Click the "move below figure" button if selected
selected = page.all('.ck-widget_selected .ck-widget__type-around__button_after')
@@ -84,7 +90,6 @@ module Components
sleep 1
- images = editable.all('figure.image')
attachments.drag_and_drop_file(editable, image_fixture, :bottom)
expect(page)
@@ -108,7 +113,7 @@ module Components
sleep(0.2)
# Toggle caption with button since newer version of ckeditor
- click_toolbar_button 'Toggle caption on'
+ click_hover_toolbar_button 'Toggle caption on'
# Locate figcaption to create comment
figcaption = figure.find('figcaption')