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
Fix forum upload spec
Oliver Günthere8b26edbd3b1
diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erbindex cf7cc4615d4..576da3808a9 100644--- a/app/views/forums/show.html.erb+++ b/app/views/forums/show.html.erb@@ -32,10 +32,13 @@ See COPYRIGHT and LICENSE files for more details.<h2><%= link_to h(@forum.name), project_forum_path(@project, @forum) %> » <%= t(:label_message_new) %></h2><%= labelled_tabular_form_for Message.new(project: @project),url: forum_topics_path(@forum),- html: {multipart: true,- id: 'message-form',- class: 'form'} do |f| %>- <%= render partial: 'messages/form', locals: {f: f} %>+ html: {+ multipart: true,+ id: 'message-form',+ class: 'form',+ data: { turbo: false }+ } do |f| %>+ <%= render partial: 'messages/form', locals: { f: f } %><hr class="form--separator"/><%= styled_button_tag t(:button_create), class: '-primary -with-icon icon-checkmark' %>@@ -49,10 +52,10 @@ See COPYRIGHT and LICENSE files for more details.<%= toolbar title: @forum.name, subtitle: format_text(@forum.description) do %><% if authorize_for(:messages, :new) %><li class="toolbar-item">- <%= link_to({controller: '/messages', action: 'new', forum_id: @forum},- {class: 'add-message-button button -primary',- aria: {label: t(:label_message_new)},- title: t(:label_message_new)}) do %>+ <%= link_to({ controller: '/messages', action: 'new', forum_id: @forum },+ { class: 'add-message-button button -primary',+ aria: { label: t(:label_message_new) },+ title: t(:label_message_new) }) do %><%= op_icon('button--icon icon-add') %><span class="button--text"><%= t(:label_message) %></span><% end %>@@ -142,9 +145,9 @@ See COPYRIGHT and LICENSE files for more details.<% end %><%= other_formats_links do |f| %>- <%= f.link_to 'Atom', url: {key: User.current.rss_key} %>+ <%= f.link_to 'Atom', url: { key: User.current.rss_key } %><% end %><% html_title h(@forum.name) %><% content_for :header_tags do %>- <%= auto_discovery_link_tag(:atom, {format: 'atom', key: User.current.rss_key}, title: "#{@project}: #{@forum}") %>+ <%= auto_discovery_link_tag(:atom, { format: 'atom', key: User.current.rss_key }, title: "#{@project}: #{@forum}") %><% end %>diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erbindex 7f69e748fb8..503d85c27e5 100644--- a/app/views/messages/edit.html.erb+++ b/app/views/messages/edit.html.erb@@ -27,17 +27,20 @@ See COPYRIGHT and LICENSE files for more details.++#%>-<h2><%= link_to h(@forum.name), controller: '/forums', action: 'show', project_id: @project, id: @forum %> » <%=h @message.subject %></h2>+<h2><%= link_to h(@forum.name), controller: '/forums', action: 'show', project_id: @project, id: @forum %> » <%= h @message.subject %></h2><%= labelled_tabular_form_for @message,url: topic_path(@message),method: :put,- html: { multipart: true,- id: 'message-form',- class: 'form' } do |f| %>+ html: {+ multipart: true,+ id: 'message-form',+ class: 'form',+ data: { turbo: false }+ } do |f| %><%= render partial: 'form', locals: { f: f, replying: [email protected]? } %>- <hr class="form--separator" />+ <hr class="form--separator"/><%= f.button t(:button_save), class: 'button -primary -with-icon icon-checkmark' %><%= link_to t(:button_cancel), topic_path(@message), class: 'button -with-icon icon-cancel' %>diff --git a/app/views/messages/new.html.erb b/app/views/messages/new.html.erbindex 7efd05da3ea..58fed5b4008 100644--- a/app/views/messages/new.html.erb+++ b/app/views/messages/new.html.erb@@ -31,12 +31,15 @@ See COPYRIGHT and LICENSE files for more details.<%= labelled_tabular_form_for @message,url: forum_topics_path(@forum),- html: { multipart: true,- id: 'message-form',- class: 'form' } do |f| %>+ html: {+ multipart: true,+ id: 'message-form',+ class: 'form',+ data: { turbo: false }+ } do |f| %><%= render partial: 'messages/form', locals: { f: f } %>- <hr class="form--separator" />+ <hr class="form--separator"/><%= f.button t(:button_create), class: 'button -primary -with-icon icon-checkmark' %><%= link_to t(:button_cancel), project_forum_path(@project, @forum), class: 'button -with-icon icon-cancel' %>diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erbindex 5df6a85b5f8..f294bd74e14 100644--- a/app/views/messages/show.html.erb+++ b/app/views/messages/show.html.erb@@ -138,9 +138,12 @@ See COPYRIGHT and LICENSE files for more details.<%= labelled_tabular_form_for @reply,as: :reply,url: reply_to_topic_path(@topic),- html: { multipart: true,- id: 'message-form',- class: 'form' } do |f| %>+ html: {+ multipart: true,+ id: 'message-form',+ class: 'form',+ data: { turbo: false }+ } do |f| %><%= render partial: 'form', locals: { f: f, replying: true } %><hr class="form--separator"/>diff --git a/spec/features/forums/attachment_upload_spec.rb b/spec/features/forums/attachment_upload_spec.rbindex 70d396cb868..0fb0fe9b947 100644--- a/spec/features/forums/attachment_upload_spec.rb+++ b/spec/features/forums/attachment_upload_spec.rb@@ -49,19 +49,20 @@ RSpec.describe "Upload attachment to forum message", :js doit "can upload an image to new and existing messages via drag & drop" doindex_page.visit!- click_link forum.name+ click_link_or_button forum.namecreate_page = index_page.click_create_messagecreate_page.set_subject "A new message"# adding an image- sleep 20+ sleep 1editor.drag_attachment image_fixture.path, "Image uploaded on creation"editor.attachments_list.expect_attached("image.png")editor.wait_until_upload_progress_toaster_cleared- click_button "Create"+ click_link_or_button "Create"+ wait_for_network_idleexpect(page).to have_css("#content .wiki img", count: 1)expect(page).to have_content("Image uploaded on creation")@@ -71,8 +72,10 @@ RSpec.describe "Upload attachment to forum message", :js doclick_on "Edit"end- find(".op-uc-figure").click- find(".ck-widget__type-around__button_after").click+ retry_block do+ find(".op-uc-figure").click+ find(".ck-widget__type-around__button_after").click+ endeditor.type_slowly("A spacer text")@@ -81,7 +84,8 @@ RSpec.describe "Upload attachment to forum message", :js doeditor.attachments_list.expect_attached("image.png", count: 2)editor.wait_until_upload_progress_toaster_cleared- click_button "Save"+ click_link_or_button "Save"+ wait_for_network_idleexpect(page).to have_css("#content .wiki img", count: 2)expect(page).to have_content("Image uploaded on creation")@@ -92,7 +96,7 @@ RSpec.describe "Upload attachment to forum message", :js doit "can upload an image to new and existing messages via drag & drop on attachments" doindex_page.visit!- click_link forum.name+ click_link_or_button forum.namecreate_page = index_page.click_create_messagecreate_page.set_subject "A new message"@@ -107,20 +111,24 @@ RSpec.describe "Upload attachment to forum message", :js doeditor.attachments_list.expect_attached("image.png")editor.wait_until_upload_progress_toaster_cleared- click_button "Create"+ click_link_or_button "Create"+ wait_for_network_idleattachments_list.expect_attached("image.png")within ".toolbar-items" doclick_on "Edit"end+ wait_for_network_idle- editor.attachments_list.drag_enter- editor.attachments_list.drop(image_fixture)-- editor.attachments_list.expect_attached("image.png", count: 2)- editor.wait_until_upload_progress_toaster_cleared+ retry_block do+ 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)+ end- click_button "Save"+ click_link_or_button "Save"+ wait_for_network_idleattachments_list.expect_attached("image.png", count: 2)enddiff --git a/spec/support/components/attachments_list.rb b/spec/support/components/attachments_list.rbindex 84653a9afeb..ddacaf5eeeb 100644--- a/spec/support/components/attachments_list.rb+++ b/spec/support/components/attachments_list.rb@@ -34,6 +34,12 @@ module Componentsexpect(page).to have_css("#{context_selector} [data-test-selector='op-attachment-list-item']", text: name, count:)end+ def expect_attached!(name, count: 1)+ unless page.has_css?("#{context_selector} [data-test-selector='op-attachment-list-item']", text: name, count:)+ raise "Expected to have #{name} attached with a count of #{count}"+ end+ end+def wait_until_visibleelement.tap { scroll_to_element(_1) }end