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 failing tests

Behrokh Satarnejad8d51ce9e91f5
diff --git a/app/components/work_package_relations_tab/index_component.rb b/app/components/work_package_relations_tab/index_component.rb
index 2b5fc7bd99f..b51006e48ae 100644
--- a/app/components/work_package_relations_tab/index_component.rb
+++ b/app/components/work_package_relations_tab/index_component.rb
@@ -131,7 +131,7 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
def render_items(border_box, items)
items.each do |relation, visibility|
border_box.with_row(
- test_selector: row_test_selector(relation),
+ test_selector: row_test_selector(relation, visibility),
data: data_attribute(relation)
) do
yield(relation, visibility)
@@ -169,9 +169,9 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
"op-new-relation-button-#{relation_type}"
end
- def row_test_selector(item)
+ def row_test_selector(item, visibility)
related_work_package_id = find_related_work_package_id(item)
- "op-relation-row-#{related_work_package_id}"
+ "op-relation-row-#{visibility}-#{related_work_package_id}"
end
def find_related_work_package_id(item)
diff --git a/app/components/work_package_relations_tab/relations_mediator.rb b/app/components/work_package_relations_tab/relations_mediator.rb
index c26e9beebad..64e8ce67eee 100644
--- a/app/components/work_package_relations_tab/relations_mediator.rb
+++ b/app/components/work_package_relations_tab/relations_mediator.rb
@@ -87,6 +87,5 @@ class WorkPackageRelationsTab::RelationsMediator
relations.select do |relation|
relation.relation_type_for(work_package) == type
end
-
end
end
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 cea8f2674ae..333d6b1583c 100644
--- a/spec/features/work_packages/details/relations/primerized_relations_spec.rb
+++ b/spec/features/work_packages/details/relations/primerized_relations_spec.rb
@@ -33,6 +33,7 @@ RSpec.describe "Primerized work package relations tab",
include Components::Autocompleter::NgSelectAutocompleteHelpers
shared_let(:project) { create(:project) }
+ shared_let(:admin) { create(:admin) }
shared_let(:user) do
create(:user,
member_with_permissions: {
@@ -152,8 +153,8 @@ RSpec.describe "Primerized work package relations tab",
relations_tab.expect_relation(relation_blocked)
# Relations not visible due to lack of permissions on the project
- relations_tab.expect_no_relation(restricted_relation_relates)
- relations_tab.expect_no_relation(restricted_child_work_package)
+ relations_tab.expect_ghost_relation(restricted_relation_relates)
+ relations_tab.expect_ghost_relation(restricted_child_work_package)
end
end
@@ -170,8 +171,8 @@ RSpec.describe "Primerized work package relations tab",
tabs.expect_counter("relations", 3)
# Relations not visible due to lack of permissions on the project
- relations_tab.expect_no_relation(restricted_relation_relates)
- relations_tab.expect_no_relation(restricted_child_work_package)
+ relations_tab.expect_ghost_relation(restricted_relation_relates)
+ relations_tab.expect_ghost_relation(restricted_child_work_package)
end
it "can delete children" do
@@ -185,8 +186,8 @@ RSpec.describe "Primerized work package relations tab",
tabs.expect_counter("relations", 3)
# Relations not visible due to lack of permissions on the project
- relations_tab.expect_no_relation(restricted_relation_relates)
- relations_tab.expect_no_relation(restricted_child_work_package)
+ relations_tab.expect_ghost_relation(restricted_relation_relates)
+ relations_tab.expect_ghost_relation(restricted_child_work_package)
end
end
@@ -208,8 +209,8 @@ RSpec.describe "Primerized work package relations tab",
# Unchanged
tabs.expect_counter("relations", 4)
- relations_tab.expect_no_relation(restricted_relation_relates)
- relations_tab.expect_no_relation(restricted_child_work_package)
+ relations_tab.expect_ghost_relation(restricted_relation_relates)
+ relations_tab.expect_ghost_relation(restricted_child_work_package)
# Edit again
relations_tab.edit_relation_description(relation_follows, "And they can be edited!")
@@ -221,8 +222,8 @@ RSpec.describe "Primerized work package relations tab",
tabs.expect_counter("relations", 4)
# Relations not visible due to lack of permissions on the project
- relations_tab.expect_no_relation(restricted_relation_relates)
- relations_tab.expect_no_relation(restricted_child_work_package)
+ relations_tab.expect_ghost_relation(restricted_relation_relates)
+ relations_tab.expect_ghost_relation(restricted_child_work_package)
end
it "does not have an edit action for children" do
@@ -230,7 +231,7 @@ RSpec.describe "Primerized work package relations tab",
wait_for_network_idle
- child_row = relations_panel.find("[data-test-selector='op-relation-row-#{child_wp.id}']")
+ child_row = relations_panel.find("[data-test-selector='op-relation-row-visible-#{child_wp.id}']")
within(child_row) do
page.find("[data-test-selector='op-relation-row-#{child_wp.id}-action-menu']").click
@@ -296,9 +297,9 @@ RSpec.describe "Primerized work package relations tab",
# Relation is created
expect(Relation.follows.where(from: wp_successor, to: work_package)).to exist
- # Relations not visible due to lack of permissions on the project
- relations_tab.expect_no_relation(restricted_relation_relates)
- relations_tab.expect_no_relation(restricted_child_work_package)
+ # Ghost relations are shown here due to lack of permissions on the project
+ relations_tab.expect_ghost_relation(restricted_relation_relates)
+ relations_tab.expect_ghost_relation(restricted_child_work_package)
end
it "does not autocomplete unrelatable work packages" do
@@ -340,9 +341,9 @@ RSpec.describe "Primerized work package relations tab",
# Child relation is created
expect(not_child_yet_wp.reload.parent).to eq work_package
- # Relations not visible due to lack of permissions on the project
- relations_tab.expect_no_relation(restricted_relation_relates)
- relations_tab.expect_no_relation(restricted_child_work_package)
+ # Ghost relations are shown here due to lack of permissions on the project
+ relations_tab.expect_ghost_relation(restricted_relation_relates)
+ relations_tab.expect_ghost_relation(restricted_child_work_package)
end
it "doesn't autocomplete parent, children, and WP itself" do
diff --git a/spec/support/components/work_packages/relations.rb b/spec/support/components/work_packages/relations.rb
index 0b61b2b0e18..75b04de4c40 100644
--- a/spec/support/components/work_packages/relations.rb
+++ b/spec/support/components/work_packages/relations.rb
@@ -64,7 +64,12 @@ module Components
def find_row(relatable)
actual_relatable = find_relatable(relatable)
- page.find_test_selector("op-relation-row-#{actual_relatable.id}", wait: 5)
+ page.find_test_selector("op-relation-row-visible-#{actual_relatable.id}", wait: 5)
+ end
+
+ def find_ghost_row(relatable)
+ actual_relatable = find_relatable(relatable)
+ page.find_test_selector("op-relation-row-ghost-#{actual_relatable.id}", wait: 5)
end
def find_some_row(text:)
@@ -77,7 +82,7 @@ module Components
def expect_no_row(relatable)
actual_relatable = find_relatable(relatable)
- expect(page).not_to have_test_selector("op-relation-row-#{actual_relatable.id}"),
+ expect(page).not_to have_test_selector("op-relation-row-visible-#{actual_relatable.id}"),
"expected no relation row for work package " \
"##{actual_relatable.id} #{actual_relatable.subject.inspect}"
end
@@ -247,6 +252,10 @@ module Components
find_row(relatable)
end
+ def expect_ghost_relation(relatable)
+ find_ghost_row(relatable)
+ end
+
def expect_relation_by_text(text)
find_some_row(text:)
end