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

Add testid capybara helper for rspec tests

- allows easy use of testid without having
  to remember syntax or recreate the setup
  of it.
- mirrors the frontend helper concept
上级 b26b2ad9
No related branches found
No related tags found
无相关合并请求
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
return if helper.stable_branch? return if helper.stable_branch?
data_testids = /testid|data-testid/ data_testids = /testid|data-testid|find_by_testid|within_testid/
deprecated_qa_selectors = /(?=qa_selector|data-qa-selector)|(?!.*\bdata-qa-)(?=class=.*qa-.*|class: .*qa-.*)/ deprecated_qa_selectors = /(?=qa_selector|data-qa-selector)|(?!.*\bdata-qa-)(?=class=.*qa-.*|class: .*qa-.*)/
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
before do before do
visit user_path(abusive_user) visit user_path(abusive_user)
find('[data-testid="base-dropdown-toggle"').click find_by_testid('base-dropdown-toggle').click
end end
it_behaves_like 'reports the user with an abuse category' it_behaves_like 'reports the user with an abuse category'
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
it 'allows the reporter to report the same user for different abuse categories' do it 'allows the reporter to report the same user for different abuse categories' do
visit user_path(abusive_user) visit user_path(abusive_user)
find('[data-testid="base-dropdown-toggle"').click find_by_testid('base-dropdown-toggle').click
fill_and_submit_abuse_category_form fill_and_submit_abuse_category_form
fill_and_submit_report_abuse_form fill_and_submit_report_abuse_form
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
visit user_path(abusive_user) visit user_path(abusive_user)
find('[data-testid="base-dropdown-toggle"').click find_by_testid('base-dropdown-toggle').click
fill_and_submit_abuse_category_form("They're being offensive or abusive.") fill_and_submit_abuse_category_form("They're being offensive or abusive.")
fill_and_submit_report_abuse_form fill_and_submit_report_abuse_form
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
visit user_path(abusive_user) visit user_path(abusive_user)
find('[data-testid="base-dropdown-toggle"').click find_by_testid('base-dropdown-toggle').click
fill_and_submit_abuse_category_form fill_and_submit_abuse_category_form
fill_and_submit_report_abuse_form fill_and_submit_report_abuse_form
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
before do before do
visit project_merge_request_path(project, merge_request) visit project_merge_request_path(project, merge_request)
find('[data-testid="merge-request-actions"]').click find_by_testid('merge-request-actions').click
end end
it_behaves_like 'reports the user with an abuse category' it_behaves_like 'reports the user with an abuse category'
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
previous_token = '' previous_token = ''
within('[data-testid="feed-token-container"]') do within_testid('feed-token-container') do
previous_token = find_field('Feed token').value previous_token = find_field('Feed token').value
click_link('reset this token') click_link('reset this token')
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
accept_gl_confirm accept_gl_confirm
within('[data-testid="feed-token-container"]') do within_testid('feed-token-container') do
click_button('Click to reveal') click_button('Click to reveal')
expect(find_field('Feed token').value).not_to eq(previous_token) expect(find_field('Feed token').value).not_to eq(previous_token)
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
previous_token = '' previous_token = ''
within('[data-testid="incoming-email-token-container"]') do within_testid('incoming-email-token-container') do
previous_token = find_field('Incoming email token').value previous_token = find_field('Incoming email token').value
click_link('reset this token') click_link('reset this token')
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
accept_gl_confirm accept_gl_confirm
within('[data-testid="incoming-email-token-container"]') do within_testid('incoming-email-token-container') do
click_button('Click to reveal') click_button('Click to reveal')
expect(find_field('Incoming email token').value).not_to eq(previous_token) expect(find_field('Incoming email token').value).not_to eq(previous_token)
......
...@@ -181,6 +181,7 @@ ...@@ -181,6 +181,7 @@
config.include SearchHelpers, type: :feature config.include SearchHelpers, type: :feature
config.include WaitHelpers, type: :feature config.include WaitHelpers, type: :feature
config.include WaitForRequests, type: :feature config.include WaitForRequests, type: :feature
config.include Features::DomHelpers, type: :feature
config.include EmailHelpers, :mailer, type: :mailer config.include EmailHelpers, :mailer, type: :mailer
config.include Warden::Test::Helpers, type: :request config.include Warden::Test::Helpers, type: :request
config.include Gitlab::Routing, type: :routing config.include Gitlab::Routing, type: :routing
......
# frozen_string_literal: true
module Features
module DomHelpers
def find_by_testid(testid)
page.find("[data-testid='#{testid}']")
end
def within_testid(testid, &block)
page.within("[data-testid='#{testid}']", &block)
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册