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 progress-related feature tests
Christophe Bliard5abd3ab80766
diff --git a/spec/features/work_packages/edit_work_package_spec.rb b/spec/features/work_packages/edit_work_package_spec.rbindex 457bf28d2c6..8e38c724787 100644--- a/spec/features/work_packages/edit_work_package_spec.rb+++ b/spec/features/work_packages/edit_work_package_spec.rb@@ -131,11 +131,11 @@ RSpec.describe "edit work package", :js docombinedDate: ["2013-03-04", "2013-03-20"],responsible: manager.name,assignee: manager.name,- estimatedTime: "5",+ estimatedTime: "10",+ remainingTime: "7",priority: priority2.name,version: version.name,category: category.name,- percentageDone: "30",status: status2.name,description: "a new description"@@ -143,7 +143,8 @@ RSpec.describe "edit work package", :js doresponsible: manager.name,assignee: manager.name,combinedDate: "03/04/2013 - 03/20/2013",- estimatedTime: "5",+ estimatedTime: "10 h",+ remainingTime: "7 h",percentageDone: "30%",subject: "a new subject",description: "a new description",diff --git a/spec/features/work_packages/table/group_by/group_by_spec.rb b/spec/features/work_packages/table/group_by/group_by_spec.rbindex 7eff288e4f8..4c86f35fb8b 100644--- a/spec/features/work_packages/table/group_by/group_by_spec.rb+++ b/spec/features/work_packages/table/group_by/group_by_spec.rb@@ -49,6 +49,6 @@ RSpec.describe "Work Package group by progress", :js do# Expect table to be grouped into 1 groupgroup_by.expect_number_of_groups 1- group_by.expect_grouped_by_value "0%", 3+ group_by.expect_grouped_by_value "-", 3endenddiff --git a/spec/features/work_packages/update_ancestors_spec.rb b/spec/features/work_packages/update_ancestors_spec.rbindex cbb4932a582..37e2b1d6627 100644--- a/spec/features/work_packages/update_ancestors_spec.rb+++ b/spec/features/work_packages/update_ancestors_spec.rb@@ -101,35 +101,27 @@ RSpec.describe "Update ancestors", :js, :with_cuprite dowp_table.visit_query queryend- context "when changing a child work and remaining work values", retry: 2 do+ context "when changing a child work and remaining work values" doit "updates the derived parent work, remaining work, and % complete values" doexpect dowp_table.update_work_package_attributes(child, estimatedTime: child.estimated_hours + 1)parent.reloadend.to change(parent, :derived_estimated_hours).by(1)- .and change(parent, :derived_done_ratio).to(35) # 7h at 50% and 3h at 0% => 35% complete for 10h+ .and change(parent, :derived_done_ratio).to(42) # 12h total work and 7h total remaining work => 42% completeexpect dowp_table.update_work_package_attributes(child, remainingTime: child.remaining_hours + 2)parent.reloadend.to change(parent, :derived_remaining_hours).by(2)- end- end-- context "when changing a child % complete value" do- it "updates the derived parent % complete value" do- expect do- wp_table.update_work_package_attributes(child, percentageDone: 100)- parent.reload- end.to change(parent, :derived_done_ratio).to(67) # 6h at 100% and 3h at 0% => 67% complete for 9h+ .and change(parent, :derived_done_ratio).to(25) # 12h total work and 9h total remaining work => 25% completeendendcontext "when setting a child status to closed" do- it "considers child % complete to be 100% and updates the derived parent % complete value accordingly" do+ it "does not consider child % complete to be 100% and so does not update the derived parent % complete value" doexpect dowp_table.update_work_package_attributes(child, status: "Closed")parent.reload- end.to change(parent, :derived_done_ratio).to(67) # 6h at 100% and 3h at 0% => 67% complete for 9h+ end.not_to change(parent, :derived_done_ratio)endend@@ -145,23 +137,29 @@ RSpec.describe "Update ancestors", :js, :with_cuprite doendend+ def expect_totals(parent, descendants)+ parent.reload+ work_packages_for_total = [parent] + descendants+ expected_total_work = work_packages_for_total.pluck(:estimated_hours).sum+ expected_total_remaining_work = work_packages_for_total.pluck(:remaining_hours).sum+ expected_done_ratio = 100.0 * (1.0 - (expected_total_remaining_work / expected_total_work))+ expect(parent.derived_estimated_hours).to eq(expected_total_work)+ expect(parent.derived_remaining_hours).to eq(expected_total_remaining_work)+ expect(parent.derived_done_ratio).to eq(expected_done_ratio.round)+ end+context "when adding a new child" doit "updates the derived parent work, remaining work, and % complete values" docontext_menu = wp_table.open_context_menu_for(parent)context_menu.choose(I18n.t("js.relation_buttons.add_new_child"))split_view_create = Pages::SplitWorkPackageCreate.new(project:)- split_view_create.set_attributes({ subject: "new child", estimatedTime: 1, remainingTime: 3 })+ split_view_create.set_attributes({ subject: "new child", estimatedTime: 3, remainingTime: 1 })split_view_create.save!split_view_create.expect_and_dismiss_toaster message: "Successful creation"- parent.reloadnew_child = WorkPackage.last- expect(parent.derived_estimated_hours).to eq([parent, child, second_child, new_child].pluck(:estimated_hours).sum)- expect(parent.derived_remaining_hours).to eq([parent, child, second_child, new_child].pluck(:remaining_hours).sum)- # child + second child + new child => parent- # 6h at 50% + 3h at 0% + 1h at 0% => 30% complete for 10h- expect(parent.derived_done_ratio).to eq(30)+ expect_totals(parent, [child, second_child, new_child])endend@@ -171,21 +169,13 @@ RSpec.describe "Update ancestors", :js, :with_cuprite docontext_menu.choose(I18n.t("js.relation_buttons.hierarchy_outdent"))wp_table.expect_and_dismiss_toaster message: "Successful update"- parent.reload- expect(parent.derived_estimated_hours).to eq([parent, child].pluck(:estimated_hours).sum)- expect(parent.derived_remaining_hours).to eq([parent, child].pluck(:remaining_hours).sum)- expect(parent.derived_done_ratio).to eq(child.done_ratio)+ expect_totals(parent, [child])context_menu = wp_table.open_context_menu_for(second_child)context_menu.choose(I18n.t("js.relation_buttons.hierarchy_indent"))wp_table.expect_and_dismiss_toaster message: "Successful update"- parent.reload- expect(parent.derived_estimated_hours).to eq([parent, child, second_child].pluck(:estimated_hours).sum)- expect(parent.derived_remaining_hours).to eq([parent, child, second_child].pluck(:remaining_hours).sum)- # child + second child => parent- # 6h at 50% + 3h at 0% => 33% complete for 9h- expect(parent.derived_done_ratio).to eq(33)+ expect_totals(parent, [child, second_child])endendend