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

Add spec for attaching a child to a work package

Aaron Contrerasd7d5c2489032
diff --git a/spec/features/work_packages/details/relations/primerized_relations_spec.rb b/spec/features/work_packages/details/relations/primerized_relations_spec.rb
index 1c6a93ca95f..c77a6b2825b 100644
--- a/spec/features/work_packages/details/relations/primerized_relations_spec.rb
+++ b/spec/features/work_packages/details/relations/primerized_relations_spec.rb
@@ -80,6 +80,11 @@ RSpec.describe "Primerized work package relations tab",
type: type1,
project: project)
end
+ let!(:not_yet_child_wp) do
+ create(:work_package,
+ type: type1,
+ project:)
+ end
current_user { user }
@@ -284,4 +289,39 @@ RSpec.describe "Primerized work package relations tab",
end
end
end
+
+ describe "attaching a child" do
+ it "renders the new child form and creates the child relationship" do
+ scroll_to_element relations_panel
+
+ relations_panel.find("[data-test-selector='new-relation-action-menu']").click
+
+ within page.find_by_id("new-relation-action-menu-list") do # Primer appends "list" to the menu id automatically
+ click_link_or_button "Child"
+ end
+
+ wait_for_reload
+
+ within "##{WorkPackageRelationsTab::AddWorkPackageChildFormComponent::DIALOG_ID}" do
+ expect(page).to have_text("Add child")
+
+ autocomplete_field = page.find("[data-test-selector='work-package-child-form-id']")
+ select_autocomplete(autocomplete_field,
+ query: not_yet_child_wp.subject,
+ results_selector: "body")
+
+ click_link_or_button "Save"
+ end
+
+ wait_for_reload
+
+ within relations_panel do
+ not_yet_child_wp.reload
+ expect(not_yet_child_wp.parent).to eq(work_package)
+
+ child_row = page.find("[data-test-selector='op-relation-row-#{not_yet_child_wp.id}']")
+ expect(child_row).to have_text(not_yet_child_wp.subject)
+ end
+ end
+ end
end