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

fixing attachement and edit_work_package specs, cleanup abstract_work_package page util

Jonas Jabarie6c4eee65f38
diff --git a/spec/features/work_packages/attachments/attachment_upload_spec.rb b/spec/features/work_packages/attachments/attachment_upload_spec.rb
index aabfdb0703c..fa1c220cb93 100644
--- a/spec/features/work_packages/attachments/attachment_upload_spec.rb
+++ b/spec/features/work_packages/attachments/attachment_upload_spec.rb
@@ -43,6 +43,7 @@ RSpec.describe "Upload attachment to work package", :js, :selenium do
let(:project) { create(:project) }
let(:work_package) { create(:work_package, project:, description: "Initial description") }
let(:wp_page) { Pages::FullWorkPackage.new(work_package, project) }
+ let(:activity_tab) { Components::WorkPackages::Activities.new(work_package) }
let(:attachments) { Components::Attachments.new }
let(:field) { TextEditorField.new wp_page, "description" }
let(:image_fixture) { UploadedFile.load_from("spec/fixtures/files/image.png") }
@@ -59,6 +60,8 @@ RSpec.describe "Upload attachment to work package", :js, :selenium do
before do
wp_page.visit!
wp_page.ensure_page_loaded
+ wp_page.switch_to_tab(tab: "Activity")
+ wp_page.wait_for_activity_tab
end
it "can upload an image via drag & drop" do
@@ -76,14 +79,6 @@ RSpec.describe "Upload attachment to work package", :js, :selenium do
end
context "when editing comment" do
- let(:selector) { ".work-packages--activity--add-comment" }
- let(:comment_field) do
- TextEditorField.new wp_page,
- "comment",
- selector:
- end
- let(:editor) { Components::WysiwygEditor.new ".work-packages--activity--add-comment" }
-
context "with a user that is not allowed to add images (Regression #28541)" do
let(:role) do
create(:project_role,
@@ -92,15 +87,15 @@ RSpec.describe "Upload attachment to work package", :js, :selenium do
it "can open the editor to add an image, but image upload is not shown" do
# Add comment
- comment_field.activate!
+ activity_tab.open_new_comment_editor
# Button should be hidden
- editor.expect_no_button "Upload image from computer"
+ activity_tab.ckeditor.expect_no_button "Upload image from computer"
- editor.click_and_type_slowly "this is a comment!1"
- comment_field.submit_by_click
+ activity_tab.ckeditor.click_and_type_slowly "this is a comment!1"
+ activity_tab.submit_comment
- wp_page.expect_comment text: "this is a comment!1"
+ activity_tab.expect_journal_notes text: "this is a comment!1"
end
end
@@ -111,15 +106,15 @@ RSpec.describe "Upload attachment to work package", :js, :selenium do
end
it "can open the editor and image upload is shown" do
- comment_field.activate!
+ activity_tab.open_new_comment_editor
- editor.expect_button "Upload image from computer"
+ activity_tab.ckeditor.expect_button "Upload image from computer"
- editor.click_and_type_slowly "this is a comment!2"
- editor.drag_attachment image_fixture.path, "Some image caption"
- comment_field.submit_by_click
+ activity_tab.ckeditor.click_and_type_slowly "this is a comment!2"
+ activity_tab.ckeditor.drag_attachment image_fixture.path, "Some image caption"
+ activity_tab.submit_comment
- wp_page.expect_comment text: "this is a comment!2"
+ activity_tab.expect_journal_notes text: "this is a comment!2"
end
end
end
@@ -270,6 +265,9 @@ RSpec.describe "Upload attachment to work package", :js, :selenium do
describe "attachment dropzone" do
shared_examples "attachment dropzone common" do
it "can drag something to the files tab and have it open" do
+ wp_page.switch_to_tab(tab: "Activity")
+ wp_page.wait_for_activity_tab
+
wp_page.expect_tab "Activity"
attachments.drag_and_drop_file test_selector("op-attachments--drop-box"),
image_fixture.path,
diff --git a/spec/features/work_packages/edit_work_package_spec.rb b/spec/features/work_packages/edit_work_package_spec.rb
index e88cecee8f3..7893e28cccd 100644
--- a/spec/features/work_packages/edit_work_package_spec.rb
+++ b/spec/features/work_packages/edit_work_package_spec.rb
@@ -217,18 +217,6 @@ RSpec.describe "edit work package", :js do
end
end
- it "allows the user to add a comment to a work package" do
- wp_page.ensure_page_loaded
-
- wp_page.trigger_edit_comment
- wp_page.update_comment "hallo welt"
-
- wp_page.save_comment
-
- wp_page.expect_toast(message: "The comment was successfully added.")
- wp_page.expect_comment text: "hallo welt"
- end
-
it "updates the presented custom fields based on the selected type" do
wp_page.ensure_page_loaded
diff --git a/spec/support/pages/work_packages/abstract_work_package.rb b/spec/support/pages/work_packages/abstract_work_package.rb
index 99b0dac9d4a..1acafdd7f55 100644
--- a/spec/support/pages/work_packages/abstract_work_package.rb
+++ b/spec/support/pages/work_packages/abstract_work_package.rb
@@ -85,16 +85,6 @@ module Pages
expect(page).to have_css('[data-test-selector="op-wp-activity-tab"][data-stimulus-controller-connected="true"]')
end
- def expect_comment(**args)
- subselector = args.delete(:subselector)
-
- retry_block do
- unless page.has_selector?(".user-comment .message #{subselector}".strip, **args)
- raise "Failed to find comment with #{args.inspect}. Retrying."
- end
- end
- end
-
def expect_any_active_inline_edit_field
expect(page).to have_css(".inline-edit--active-field")
end
@@ -285,28 +275,10 @@ module Pages
page.click_button(I18n.t("js.button_edit"))
end
- def trigger_edit_comment
- add_comment_container.find(".work-package-comment").click
- end
-
- def update_comment(comment)
- editor = ::Components::WysiwygEditor.new ".work-packages--activity--add-comment"
- editor.click_and_type_slowly comment
- end
-
- def save_comment
- label = "Comment: Save"
- add_comment_container.find(:xpath, "//button[@title='#{label}']").click
- end
-
def save!
page.click_button(I18n.t("js.button_save"))
end
- def add_comment_container
- find(".work-packages--activity--add-comment")
- end
-
def click_add_wp_button
find(".add-work-package:not([disabled])", text: "Work package").click
end