Skip to content
代码片段 群组 项目
未验证 提交 e748c7ea 编辑于 作者: Roy Liu's avatar Roy Liu 提交者: GitLab
浏览文件

Update within_testid and find_by_testid helper to include context

上级 84310f72
No related branches found
No related tags found
无相关合并请求
...@@ -21,9 +21,7 @@ ...@@ -21,9 +21,7 @@
wait_for_requests 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:todo Capybara/TestidFinders -- Doesn't cover use case, see https://gitlab.com/gitlab-org/gitlab/-/issues/442224
expect(page).to be_axe_clean.within('[data-testid="artifact-registry-list-page"]')
# rubocop:enable Capybara/TestidFinders
end end
it 'has a page title set' do it 'has a page title set' do
......
...@@ -22,10 +22,8 @@ ...@@ -22,10 +22,8 @@
wait_for_requests 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"]') # rubocop:todo Capybara/TestidFinders -- Doesn't cover use case, see https://gitlab.com/gitlab-org/gitlab/-/issues/442224
expect(page).to be_axe_clean.within('[data-testid="packages-and-registries-project-settings"]')
.skipping :'heading-order' .skipping :'heading-order'
# rubocop:enable Capybara/TestidFinders
end end
it 'shows available section' do it 'shows available section' do
......
...@@ -65,10 +65,8 @@ ...@@ -65,10 +65,8 @@
wait_for_requests 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"]') # rubocop:todo Capybara/TestidFinders -- Doesn't cover use case, see https://gitlab.com/gitlab-org/gitlab/-/issues/442224
expect(page).to be_axe_clean.within('[data-testid="packages-and-registries-group-settings"]')
.skipping :'link-in-text-block', :'heading-order' .skipping :'link-in-text-block', :'heading-order'
# rubocop:enable Capybara/TestidFinders
end end
it 'has a Duplicate packages section', :js do it 'has a Duplicate packages section', :js do
......
...@@ -110,12 +110,10 @@ ...@@ -110,12 +110,10 @@
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
wait_for_all_requests 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(locked_badge)
expect(page).to be_axe_clean.within(issuable_note_warning) expect(page).to be_axe_clean.within(issuable_note_warning)
more_dropdown.click more_dropdown.click
expect(page).to be_axe_clean.within('[data-testid="lock-issue-toggle"] button') 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
# rubocop:enable Capybara/TestidFinders
end end
end end
...@@ -221,34 +221,28 @@ def add_pin(nav_item_title) ...@@ -221,34 +221,28 @@ def add_pin(nav_item_title)
nav_item = find_by_testid('nav-item', text: nav_item_title) nav_item = find_by_testid('nav-item', text: nav_item_title)
scroll_to(nav_item) scroll_to(nav_item)
nav_item.hover nav_item.hover
within(nav_item) do find_by_testid('nav-item-pin', context: nav_item).click
pin_button = find_by_testid('nav-item-pin')
pin_button.click wait_for_requests
wait_for_requests
end
end end
def remove_pin(nav_item_title) def remove_pin(nav_item_title)
nav_item = find_by_testid('nav-item', text: nav_item_title) nav_item = find_by_testid('nav-item', text: nav_item_title)
scroll_to(nav_item) scroll_to(nav_item)
nav_item.hover nav_item.hover
within(nav_item) do find_by_testid('nav-item-unpin', context: nav_item).click
unpin_button = find_by_testid('nav-item-unpin')
unpin_button.click wait_for_requests
wait_for_requests
end
end end
def drag_item(item, to:) def drag_item(item, to:)
item.hover 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
# Reduce delay to make it less likely for draggables to # flakiness.
# change position during drag operation, which reduces find_by_testid('grip-icon', context: item).drag_to(to, delay: 0.01)
# flakiness.
drag_handle.drag_to(to, delay: 0.01) wait_for_requests
wait_for_requests
end
end end
end end
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
module Features module Features
module DomHelpers module DomHelpers
def has_testid?(testid, **kwargs) def has_testid?(testid, context: page, **kwargs)
page.has_selector?("[data-testid='#{testid}']", **kwargs) context.has_selector?("[data-testid='#{testid}']", **kwargs)
end end
def find_by_testid(testid, **kwargs) def find_by_testid(testid, context: page, **kwargs)
page.find("[data-testid='#{testid}']", **kwargs) context.find("[data-testid='#{testid}']", **kwargs)
end end
def within_testid(testid, **kwargs, &block) def within_testid(testid, context: page, **kwargs, &block)
page.within("[data-testid='#{testid}']", **kwargs, &block) context.within("[data-testid='#{testid}']", **kwargs, &block)
end end
end end
end end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册