diff --git a/ee/spec/features/projects/google_cloud_platform/artifact_registry_spec.rb b/ee/spec/features/projects/google_cloud_platform/artifact_registry_spec.rb index aa4d4369681a326b434d0f8113b612fd634d5f3f..fe46ad835ed7f44b5d050713ba802dcd6e09c6ca 100644 --- a/ee/spec/features/projects/google_cloud_platform/artifact_registry_spec.rb +++ b/ee/spec/features/projects/google_cloud_platform/artifact_registry_spec.rb @@ -21,9 +21,7 @@ wait_for_requests - # rubocop:disable Capybara/TestidFinders -- Helper within_testid doesn't cover use case - expect(page).to be_axe_clean.within('[data-testid="artifact-registry-list-page"]') - # rubocop:enable Capybara/TestidFinders + expect(page).to be_axe_clean.within('[data-testid="artifact-registry-list-page"]') # rubocop:todo Capybara/TestidFinders -- Doesn't cover use case, see https://gitlab.com/gitlab-org/gitlab/-/issues/442224 end it 'has a page title set' do diff --git a/ee/spec/features/projects/settings/packages_spec.rb b/ee/spec/features/projects/settings/packages_spec.rb index fa6c2052bdcd63b7cea71ae58d962fde0a08c9c0..bc344b590fd6e033971e0fc115070b5601a92910 100644 --- a/ee/spec/features/projects/settings/packages_spec.rb +++ b/ee/spec/features/projects/settings/packages_spec.rb @@ -22,10 +22,8 @@ wait_for_requests - # rubocop:disable Capybara/TestidFinders -- Helper within_testid doesn't cover use case - expect(page).to be_axe_clean.within('[data-testid="packages-and-registries-project-settings"]') + expect(page).to be_axe_clean.within('[data-testid="packages-and-registries-project-settings"]') # rubocop:todo Capybara/TestidFinders -- Doesn't cover use case, see https://gitlab.com/gitlab-org/gitlab/-/issues/442224 .skipping :'heading-order' - # rubocop:enable Capybara/TestidFinders end it 'shows available section' do diff --git a/spec/features/groups/settings/packages_and_registries_spec.rb b/spec/features/groups/settings/packages_and_registries_spec.rb index 934234aa171ec5221ba11487ef32dc0b2e09154e..83cc8af3b473830f91944fcf6e0b0c5d682ee7a7 100644 --- a/spec/features/groups/settings/packages_and_registries_spec.rb +++ b/spec/features/groups/settings/packages_and_registries_spec.rb @@ -65,10 +65,8 @@ wait_for_requests - # rubocop:disable Capybara/TestidFinders -- Helper within_testid doesn't cover use case - expect(page).to be_axe_clean.within('[data-testid="packages-and-registries-group-settings"]') + expect(page).to be_axe_clean.within('[data-testid="packages-and-registries-group-settings"]') # rubocop:todo Capybara/TestidFinders -- Doesn't cover use case, see https://gitlab.com/gitlab-org/gitlab/-/issues/442224 .skipping :'link-in-text-block', :'heading-order' - # rubocop:enable Capybara/TestidFinders end it 'has a Duplicate packages section', :js do diff --git a/spec/features/issues/discussion_lock_spec.rb b/spec/features/issues/discussion_lock_spec.rb index 6b955ced06e60cf3191c42c463d91a6c2d299ba2..7541d7658b38c8cdc0a4831ccdc3b21ba99dd355 100644 --- a/spec/features/issues/discussion_lock_spec.rb +++ b/spec/features/issues/discussion_lock_spec.rb @@ -110,12 +110,10 @@ visit project_issue_path(project, issue) wait_for_all_requests - # rubocop:disable Capybara/TestidFinders -- within_testid does not work here expect(page).to be_axe_clean.within(locked_badge) expect(page).to be_axe_clean.within(issuable_note_warning) more_dropdown.click - expect(page).to be_axe_clean.within('[data-testid="lock-issue-toggle"] button') - # rubocop:enable Capybara/TestidFinders + expect(page).to be_axe_clean.within('[data-testid="lock-issue-toggle"] button') # rubocop:todo Capybara/TestidFinders -- Doesn't cover use case, see https://gitlab.com/gitlab-org/gitlab/-/issues/442224 end end diff --git a/spec/features/nav/pinned_nav_items_spec.rb b/spec/features/nav/pinned_nav_items_spec.rb index 07958bf3d6646ff8dd9ac1efc80dbff61f74617c..74dfe572149467332dac7c4322502daba846bb9d 100644 --- a/spec/features/nav/pinned_nav_items_spec.rb +++ b/spec/features/nav/pinned_nav_items_spec.rb @@ -221,34 +221,28 @@ def add_pin(nav_item_title) nav_item = find_by_testid('nav-item', text: nav_item_title) scroll_to(nav_item) nav_item.hover - within(nav_item) do - pin_button = find_by_testid('nav-item-pin') - pin_button.click - wait_for_requests - end + find_by_testid('nav-item-pin', context: nav_item).click + + wait_for_requests end def remove_pin(nav_item_title) nav_item = find_by_testid('nav-item', text: nav_item_title) scroll_to(nav_item) nav_item.hover - within(nav_item) do - unpin_button = find_by_testid('nav-item-unpin') - unpin_button.click - wait_for_requests - end + find_by_testid('nav-item-unpin', context: nav_item).click + + wait_for_requests end def drag_item(item, to:) item.hover - within(item) do - drag_handle = find_by_testid('grip-icon') - - # Reduce delay to make it less likely for draggables to - # change position during drag operation, which reduces - # flakiness. - drag_handle.drag_to(to, delay: 0.01) - wait_for_requests - end + + # Reduce delay to make it less likely for draggables to + # change position during drag operation, which reduces + # flakiness. + find_by_testid('grip-icon', context: item).drag_to(to, delay: 0.01) + + wait_for_requests end end diff --git a/spec/support/helpers/features/dom_helpers.rb b/spec/support/helpers/features/dom_helpers.rb index 619f16f5e6d2d2cf0acdfa708621838483961650..96d02e8f03d4da0a935d75f03a3f4138235207ca 100644 --- a/spec/support/helpers/features/dom_helpers.rb +++ b/spec/support/helpers/features/dom_helpers.rb @@ -2,16 +2,16 @@ module Features module DomHelpers - def has_testid?(testid, **kwargs) - page.has_selector?("[data-testid='#{testid}']", **kwargs) + def has_testid?(testid, context: page, **kwargs) + context.has_selector?("[data-testid='#{testid}']", **kwargs) end - def find_by_testid(testid, **kwargs) - page.find("[data-testid='#{testid}']", **kwargs) + def find_by_testid(testid, context: page, **kwargs) + context.find("[data-testid='#{testid}']", **kwargs) end - def within_testid(testid, **kwargs, &block) - page.within("[data-testid='#{testid}']", **kwargs, &block) + def within_testid(testid, context: page, **kwargs, &block) + context.within("[data-testid='#{testid}']", **kwargs, &block) end end end