Skip to content

Commit

Permalink
create a separate method for selecting relation type
Browse files Browse the repository at this point in the history
  • Loading branch information
bsatarnejad committed Dec 3, 2024
1 parent 627cc47 commit 4a12fcc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,7 @@ def label_for_relation_type(relation_type)
# wp_predecessor is already related to work_package as relation_follows
# in a predecessor relation, so it should not be autocompleteable anymore
# under the "Predecessor (before)" type
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 "Predecessor (before)"
end
relations_tab.select_relation_type "Predecessor (before)"

wait_for_reload

Expand Down Expand Up @@ -254,13 +248,7 @@ def label_for_relation_type(relation_type)
end

it "doesn't autocomplete parent, children, and WP itself" 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
click_link_or_button "Child"
end
relations_tab.select_relation_type "Child"

wait_for_reload

Expand Down
20 changes: 11 additions & 9 deletions spec/support/components/work_packages/relations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ def expect_no_row(relatable)
expect(page).not_to have_test_selector("op-relation-row-#{actual_relatable.id}")
end

def select_relation_type(relation_type)
page.find_test_selector("new-relation-action-menu").click

within page.find_by_id("new-relation-action-menu-list") do
click_link_or_button relation_type
end
end

def remove_relation(relatable)
actual_relatable = find_relatable(relatable)
relatable_row = find_row(actual_relatable)
Expand Down Expand Up @@ -131,12 +139,10 @@ def add_relation(type:, relatable:, description: nil)
# Open create form

SeleniumHubWaiter.wait
page.find_test_selector("new-relation-action-menu").click

label_text_for_relation_type = I18n.t("#{i18n_namespace}.label_#{type}_singular")
within page.find_by_id("new-relation-action-menu-list") do # Primer appends "list" to the menu id automatically
click_link_or_button label_text_for_relation_type.capitalize
end

select_relation_type label_text_for_relation_type.capitalize

wait_for_reload if using_cuprite?

Expand Down Expand Up @@ -272,11 +278,7 @@ def add_existing_child(work_package)
SeleniumHubWaiter.wait

retry_block do
page.find_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
select_relation_type "Child"
end

within "##{WorkPackageRelationsTab::AddWorkPackageChildFormComponent::DIALOG_ID}" do
Expand Down

0 comments on commit 4a12fcc

Please sign in to comment.