Skip to content

Commit

Permalink
Merge pull request #17373 from opf/fix/stabilize-relations-spec
Browse files Browse the repository at this point in the history
Attempt to stabilize the `primerized_relations_spec`
  • Loading branch information
HDinger authored Dec 6, 2024
2 parents 4d7bff2 + af91a89 commit 1563dab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def label_for_relation_type(relation_type)
describe "rendering" do
it "renders the relations tab" do
scroll_to_element relations_panel

wait_for_network_idle

expect(page).to have_css(relations_panel_selector)

tabs.expect_counter("relations", 4)
Expand All @@ -120,6 +123,8 @@ def label_for_relation_type(relation_type)
it "can delete relations" do
scroll_to_element relations_panel

wait_for_network_idle

relations_tab.remove_relation(relation_follows)

expect { relation_follows.reload }.to raise_error(ActiveRecord::RecordNotFound)
Expand All @@ -130,6 +135,8 @@ def label_for_relation_type(relation_type)
it "can delete children" do
scroll_to_element relations_panel

wait_for_network_idle

relations_tab.remove_child(child_wp)
expect(child_wp.reload.parent).to be_nil

Expand All @@ -141,6 +148,8 @@ def label_for_relation_type(relation_type)
it "renders an edit form" do
scroll_to_element relations_panel

wait_for_network_idle

relation_row = relations_tab.expect_relation(relation_follows)

relations_tab.add_description_to_relation(relation_follows, "Discovered relations have descriptions!")
Expand All @@ -164,6 +173,8 @@ def label_for_relation_type(relation_type)
it "does not have an edit action for children" do
scroll_to_element relations_panel

wait_for_network_idle

child_row = relations_panel.find("[data-test-selector='op-relation-row-#{child_wp.id}']")

within(child_row) do
Expand All @@ -182,10 +193,18 @@ def label_for_relation_type(relation_type)
relation_type: Relation::TYPE_FOLLOWS)
end

before do
another_wp
relation_to
end

it "shows the correct related WorkPackage in the dialog (regression #59771)" do
scroll_to_element relations_panel

relations_tab.open_relation_dialog(relation_to)
wait_for_network_idle

relations_tab.expect_relation(another_wp)
relations_tab.open_relation_dialog(another_wp)

within "##{WorkPackageRelationsTab::WorkPackageRelationDialogComponent::DIALOG_ID}" do
expect(page).to have_field("Work package",
Expand All @@ -202,6 +221,8 @@ def label_for_relation_type(relation_type)
it "renders the new relation form for the selected type and creates the relation" do
scroll_to_element relations_panel

wait_for_network_idle

relations_tab.add_relation(type: :precedes, relatable: wp_successor,
description: "Discovered relations have descriptions!")
relations_tab.expect_relation(wp_successor)
Expand Down Expand Up @@ -238,6 +259,8 @@ def label_for_relation_type(relation_type)
it "renders the new child form and creates the child relationship" do
scroll_to_element relations_panel

wait_for_network_idle

tabs.expect_counter("relations", 4)

relations_tab.add_existing_child(not_yet_child_wp)
Expand Down Expand Up @@ -296,6 +319,8 @@ def label_for_relation_type(relation_type)
it "does not show options to add or edit relations" do
scroll_to_element relations_panel

wait_for_network_idle

tabs.expect_counter("relations", 4)

relations_tab.expect_no_add_relation_button
Expand All @@ -311,6 +336,8 @@ def label_for_relation_type(relation_type)
it "does not show the option to delete the child" do
scroll_to_element relations_panel

wait_for_network_idle

tabs.expect_counter("relations", 4)

# The menu is shown as the user can add a relation
Expand All @@ -332,6 +359,8 @@ def label_for_relation_type(relation_type)
it "does not show the option to edit the relation but only the child" do
scroll_to_element relations_panel

wait_for_network_idle

tabs.expect_counter("relations", 4)

# The menu is shown as the user can add a child
Expand Down
4 changes: 2 additions & 2 deletions spec/support/components/work_packages/relations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def expect_no_add_relation_button

def find_row(relatable)
actual_relatable = find_relatable(relatable)
page.find_test_selector("op-relation-row-#{actual_relatable.id}")
page.find_test_selector("op-relation-row-#{actual_relatable.id}", wait: 5)
end

def find_some_row(text:)
page.find("[data-test-selector^='op-relation-row']", text:)
page.find("[data-test-selector^='op-relation-row']", text:, wait: 5)
end

def expect_row(work_package)
Expand Down

0 comments on commit 1563dab

Please sign in to comment.