Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1046a3ae
Commit
1046a3ae
authored
Jun 15, 2021
by
ddavison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add selector usage cop for QA and non-QA tests
Disable all existing selector usages within spec and ee/spec
parent
4fd356ba
Changes
48
Show whitespace changes
Inline
Side-by-side
Showing
48 changed files
with
221 additions
and
125 deletions
+221
-125
.rubocop.yml
.rubocop.yml
+8
-0
ee/spec/features/admin/admin_audit_logs_spec.rb
ee/spec/features/admin/admin_audit_logs_spec.rb
+1
-1
ee/spec/features/epics/delete_epic_spec.rb
ee/spec/features/epics/delete_epic_spec.rb
+1
-1
ee/spec/features/groups/billing/seat_usage_spec.rb
ee/spec/features/groups/billing/seat_usage_spec.rb
+5
-5
ee/spec/features/groups/navbar_spec.rb
ee/spec/features/groups/navbar_spec.rb
+1
-1
ee/spec/features/projects/custom_projects_template_spec.rb
ee/spec/features/projects/custom_projects_template_spec.rb
+4
-4
ee/spec/features/projects/mirror_spec.rb
ee/spec/features/projects/mirror_spec.rb
+2
-2
ee/spec/features/projects/new_project_spec.rb
ee/spec/features/projects/new_project_spec.rb
+10
-10
ee/spec/features/projects_spec.rb
ee/spec/features/projects_spec.rb
+2
-2
ee/spec/features/protected_branches_spec.rb
ee/spec/features/protected_branches_spec.rb
+1
-1
ee/spec/support/shared_examples/features/protected_branches_access_control_shared_examples.rb
...ures/protected_branches_access_control_shared_examples.rb
+2
-2
ee/spec/views/groups/settings/_transfer.html.haml_spec.rb
ee/spec/views/groups/settings/_transfer.html.haml_spec.rb
+5
-5
rubocop/cop/qa/selector_usage.rb
rubocop/cop/qa/selector_usage.rb
+39
-0
spec/features/admin/admin_appearance_spec.rb
spec/features/admin/admin_appearance_spec.rb
+1
-1
spec/features/admin/admin_groups_spec.rb
spec/features/admin/admin_groups_spec.rb
+2
-2
spec/features/admin/users/user_spec.rb
spec/features/admin/users/user_spec.rb
+2
-2
spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb
...ues/create_issue_for_discussions_in_merge_request_spec.rb
+1
-1
spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb
...eate_issue_for_single_discussion_in_merge_request_spec.rb
+1
-1
spec/features/issues/issue_sidebar_spec.rb
spec/features/issues/issue_sidebar_spec.rb
+2
-2
spec/features/issues/user_creates_issue_spec.rb
spec/features/issues/user_creates_issue_spec.rb
+3
-3
spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
.../user_resolves_diff_notes_and_discussions_resolve_spec.rb
+10
-10
spec/features/project_variables_spec.rb
spec/features/project_variables_spec.rb
+1
-1
spec/features/projects/blobs/blob_show_spec.rb
spec/features/projects/blobs/blob_show_spec.rb
+1
-1
spec/features/projects/environments/environment_metrics_spec.rb
...eatures/projects/environments/environment_metrics_spec.rb
+3
-3
spec/features/projects/environments/environments_spec.rb
spec/features/projects/environments/environments_spec.rb
+2
-2
spec/features/projects/environments_pod_logs_spec.rb
spec/features/projects/environments_pod_logs_spec.rb
+1
-1
spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb
...rojects/feature_flags/user_sees_feature_flag_list_spec.rb
+1
-1
spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
...sees_link_to_create_license_file_in_empty_project_spec.rb
+1
-1
spec/features/projects/fork_spec.rb
spec/features/projects/fork_spec.rb
+2
-2
spec/features/projects/import_export/import_file_spec.rb
spec/features/projects/import_export/import_file_spec.rb
+1
-1
spec/features/projects/members/invite_group_spec.rb
spec/features/projects/members/invite_group_spec.rb
+2
-2
spec/features/projects/new_project_spec.rb
spec/features/projects/new_project_spec.rb
+18
-18
spec/features/projects/show/user_sees_collaboration_links_spec.rb
...tures/projects/show/user_sees_collaboration_links_spec.rb
+2
-2
spec/features/projects/tree/create_directory_spec.rb
spec/features/projects/tree/create_directory_spec.rb
+2
-2
spec/features/projects/tree/create_file_spec.rb
spec/features/projects/tree/create_file_spec.rb
+2
-2
spec/features/projects/tree/tree_show_spec.rb
spec/features/projects/tree/tree_show_spec.rb
+3
-3
spec/features/projects/user_creates_project_spec.rb
spec/features/projects/user_creates_project_spec.rb
+3
-3
spec/features/projects_spec.rb
spec/features/projects_spec.rb
+2
-2
spec/rubocop/cop/qa/selector_usage_spec.rb
spec/rubocop/cop/qa/selector_usage_spec.rb
+49
-0
spec/support/shared_examples/features/discussion_comments_shared_example.rb
...d_examples/features/discussion_comments_shared_example.rb
+2
-2
spec/support/shared_examples/features/packages_shared_examples.rb
...port/shared_examples/features/packages_shared_examples.rb
+2
-2
spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb
.../features/protected_branches_with_deploy_keys_examples.rb
+3
-3
spec/support/shared_examples/features/rss_shared_examples.rb
spec/support/shared_examples/features/rss_shared_examples.rb
+2
-2
spec/support/shared_examples/features/variable_list_shared_examples.rb
...shared_examples/features/variable_list_shared_examples.rb
+4
-4
spec/support/shared_examples/features/wiki/user_views_asciidoc_page_with_includes_shared_examples.rb
...user_views_asciidoc_page_with_includes_shared_examples.rb
+1
-1
spec/views/admin/sessions/new.html.haml_spec.rb
spec/views/admin/sessions/new.html.haml_spec.rb
+4
-4
spec/views/devise/sessions/new.html.haml_spec.rb
spec/views/devise/sessions/new.html.haml_spec.rb
+2
-2
spec/views/groups/settings/_transfer.html.haml_spec.rb
spec/views/groups/settings/_transfer.html.haml_spec.rb
+2
-2
No files found.
.rubocop.yml
View file @
1046a3ae
...
...
@@ -701,3 +701,11 @@ RSpec/TopLevelDescribePath:
Exclude
:
-
'
spec/fixtures/**/*.rb'
-
'
ee/spec/fixtures/**/*.rb'
QA/SelectorUsage
:
Enabled
:
true
Include
:
-
'
spec/**/*.rb'
-
'
ee/spec/**/*.rb'
Exclude
:
-
'
spec/rubocop/**/*_spec.rb'
ee/spec/features/admin/admin_audit_logs_spec.rb
View file @
1046a3ae
...
...
@@ -190,7 +190,7 @@ RSpec.describe 'Admin::AuditLogs', :js do
click_link
'Impersonate'
visit
(
new_project_path
)
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
fill_in
(
:project_name
,
with:
'Gotham City'
)
...
...
ee/spec/features/epics/delete_epic_spec.rb
View file @
1046a3ae
...
...
@@ -31,7 +31,7 @@ RSpec.describe 'Delete Epic', :js do
end
it
'deletes the issue and redirect to epic list'
do
find
(
'.qa-delete-button'
).
click
find
(
'.qa-delete-button'
).
click
# rubocop:disable QA/SelectorUsage
wait_for_requests
find
(
'.js-modal-action-primary'
).
click
...
...
ee/spec/features/groups/billing/seat_usage_spec.rb
View file @
1046a3ae
...
...
@@ -75,13 +75,13 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do
end
it
'has disabled the remove button'
do
within
'[data-qa-selector="remove_billable_member_modal"]'
do
within
'[data-qa-selector="remove_billable_member_modal"]'
do
# rubocop:disable QA/SelectorUsage
expect
(
page
).
to
have_button
(
'Remove user'
,
disabled:
true
)
end
end
it
'enables the remove button when user enters valid username'
do
within
'[data-qa-selector="remove_billable_member_modal"]'
do
within
'[data-qa-selector="remove_billable_member_modal"]'
do
# rubocop:disable QA/SelectorUsage
find
(
'input'
).
fill_in
(
with:
maintainer
.
username
)
find
(
'input'
).
send_keys
(
:tab
)
...
...
@@ -90,7 +90,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do
end
it
'does not enable button when user enters invalid username'
do
within
'[data-qa-selector="remove_billable_member_modal"]'
do
within
'[data-qa-selector="remove_billable_member_modal"]'
do
# rubocop:disable QA/SelectorUsage
find
(
'input'
).
fill_in
(
with:
'invalid username'
)
find
(
'input'
).
send_keys
(
:tab
)
...
...
@@ -112,7 +112,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do
end
it
'shows a flash message'
do
within
'[data-qa-selector="remove_billable_member_modal"]'
do
within
'[data-qa-selector="remove_billable_member_modal"]'
do
# rubocop:disable QA/SelectorUsage
find
(
'input'
).
fill_in
(
with:
maintainer
.
username
)
find
(
'input'
).
send_keys
(
:tab
)
...
...
@@ -138,7 +138,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do
click_button
(
'Remove member'
)
within
'[data-qa-selector="remove_member_modal_content"]'
do
within
'[data-qa-selector="remove_member_modal_content"]'
do
# rubocop:disable QA/SelectorUsage
click_button
(
'Remove member'
)
end
...
...
ee/spec/features/groups/navbar_spec.rb
View file @
1046a3ae
...
...
@@ -70,7 +70,7 @@ RSpec.describe 'Group navbar' do
it
'redirects to value stream when Analytics item is clicked'
do
page
.
within
(
'.sidebar-top-level-items'
)
do
find
(
'[data-qa-selector=analytics_anchor]'
).
click
find
(
'[data-qa-selector=analytics_anchor]'
).
click
# rubocop:disable QA/SelectorUsage
end
wait_for_requests
...
...
ee/spec/features/projects/custom_projects_template_spec.rb
View file @
1046a3ae
...
...
@@ -43,7 +43,7 @@ RSpec.describe 'Project' do
new_path
=
'example-custom-project-template'
new_name
=
'Example Custom Project Template'
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
# rubocop:disable QA/SelectorUsage
find
(
'.project-template .custom-instance-project-templates-tab'
).
click
find
(
"label[for='
#{
projects
.
first
.
name
}
']"
).
click
...
...
@@ -68,7 +68,7 @@ RSpec.describe 'Project' do
new_path
=
'example-custom-project-template'
new_name
=
'Example Custom Project Template'
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
# rubocop:disable QA/SelectorUsage
find
(
'.project-template .custom-instance-project-templates-tab'
).
click
find
(
"label[for='
#{
projects
.
first
.
name
}
']"
).
click
...
...
@@ -90,7 +90,7 @@ RSpec.describe 'Project' do
new_path
=
'example-custom-project-template'
new_name
=
'Example Custom Project Template'
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
# rubocop:disable QA/SelectorUsage
find
(
'.project-template .custom-instance-project-templates-tab'
).
click
find
(
"label[for='
#{
projects
.
first
.
name
}
']"
).
click
...
...
@@ -111,7 +111,7 @@ RSpec.describe 'Project' do
it
'has a working pagination'
,
:js
do
last_project
=
"label[for='
#{
projects
.
last
.
name
}
']"
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
# rubocop:disable QA/SelectorUsage
find
(
'.project-template .custom-instance-project-templates-tab'
).
click
expect
(
page
).
to
have_css
(
'.custom-project-templates .gl-pagination'
)
...
...
ee/spec/features/projects/mirror_spec.rb
View file @
1046a3ae
...
...
@@ -69,7 +69,7 @@ RSpec.describe 'Project mirror', :js do
import_state
.
update!
(
next_execution_timestamp:
timestamp
-
1
.
minute
)
end
let
(
:disabled_updating_button
)
{
'[data-qa-selector="updating_button"].disabled'
}
let
(
:disabled_updating_button
)
{
'[data-qa-selector="updating_button"].disabled'
}
# rubocop:disable QA/SelectorUsage
it
'disables Update now button'
do
travel_to
(
timestamp
)
do
...
...
@@ -81,7 +81,7 @@ RSpec.describe 'Project mirror', :js do
end
context
'when the project is archived'
do
let
(
:disabled_update_now_button
)
{
'[data-qa-selector="update_now_button"].disabled'
}
let
(
:disabled_update_now_button
)
{
'[data-qa-selector="update_now_button"].disabled'
}
# rubocop:disable QA/SelectorUsage
before
do
project
.
update!
(
archived:
true
)
...
...
ee/spec/features/projects/new_project_spec.rb
View file @
1046a3ae
...
...
@@ -17,7 +17,7 @@ RSpec.describe 'New project', :js do
it
'shows mirror repository checkbox enabled'
,
:js
do
visit
new_project_path
find
(
'[data-qa-panel-name="import_project"]'
).
click
find
(
'[data-qa-panel-name="import_project"]'
).
click
# rubocop:disable QA/SelectorUsage
first
(
'.js-import-git-toggle-button'
).
click
expect
(
page
).
to
have_unchecked_field
(
'Mirror repository'
,
disabled:
false
)
...
...
@@ -31,7 +31,7 @@ RSpec.describe 'New project', :js do
it
'does not show mirror repository option'
do
visit
new_project_path
find
(
'[data-qa-panel-name="import_project"]'
).
click
find
(
'[data-qa-panel-name="import_project"]'
).
click
# rubocop:disable QA/SelectorUsage
first
(
'.js-import-git-toggle-button'
).
click
expect
(
page
).
not_to
have_content
(
'Mirror repository'
)
...
...
@@ -60,16 +60,16 @@ RSpec.describe 'New project', :js do
it
'shows CI/CD tab and pane'
do
visit
new_project_path
expect
(
page
).
to
have_css
(
'[data-qa-panel-name="cicd_for_external_repo"]'
)
expect
(
page
).
to
have_css
(
'[data-qa-panel-name="cicd_for_external_repo"]'
)
# rubocop:disable QA/SelectorUsage
find
(
'[data-qa-panel-name="cicd_for_external_repo"]'
).
click
find
(
'[data-qa-panel-name="cicd_for_external_repo"]'
).
click
# rubocop:disable QA/SelectorUsage
expect
(
page
).
to
have_css
(
'#ci-cd-project-pane'
)
end
it
'"Import project" tab creates projects with features enabled'
do
visit
new_project_path
find
(
'[data-qa-panel-name="import_project"]'
).
click
find
(
'[data-qa-panel-name="import_project"]'
).
click
# rubocop:disable QA/SelectorUsage
page
.
within
'#import-project-pane'
do
first
(
'.js-import-git-toggle-button'
).
click
...
...
@@ -89,7 +89,7 @@ RSpec.describe 'New project', :js do
it
'creates CI/CD project from repo URL'
,
:sidekiq_might_not_need_inline
do
visit
new_project_path
find
(
'[data-qa-panel-name="cicd_for_external_repo"]'
).
click
find
(
'[data-qa-panel-name="cicd_for_external_repo"]'
).
click
# rubocop:disable QA/SelectorUsage
page
.
within
'#ci-cd-project-pane'
do
find
(
'.js-import-git-toggle-button'
).
click
...
...
@@ -109,7 +109,7 @@ RSpec.describe 'New project', :js do
it
'creates CI/CD project from GitHub'
do
visit
new_project_path
find
(
'[data-qa-panel-name="cicd_for_external_repo"]'
).
click
find
(
'[data-qa-panel-name="cicd_for_external_repo"]'
).
click
# rubocop:disable QA/SelectorUsage
page
.
within
'#ci-cd-project-pane'
do
find
(
'.js-import-github'
).
click
...
...
@@ -146,7 +146,7 @@ RSpec.describe 'New project', :js do
it
'stays on GitHub import page after access token failure'
do
visit
new_project_path
find
(
'[data-qa-panel-name="cicd_for_external_repo"]'
).
click
find
(
'[data-qa-panel-name="cicd_for_external_repo"]'
).
click
# rubocop:disable QA/SelectorUsage
page
.
within
'#ci-cd-project-pane'
do
find
(
'.js-import-github'
).
click
...
...
@@ -170,7 +170,7 @@ RSpec.describe 'New project', :js do
it
'does not show CI/CD only tab'
do
visit
new_project_path
expect
(
page
).
not_to
have_css
(
'[data-qa-panel-name="cicd_for_external_repo"]'
)
expect
(
page
).
not_to
have_css
(
'[data-qa-panel-name="cicd_for_external_repo"]'
)
# rubocop:disable QA/SelectorUsage
end
end
end
...
...
@@ -458,7 +458,7 @@ RSpec.describe 'New project', :js do
def
visit_create_from_built_in_templates_tab
visit
new_project_path
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
# rubocop:disable QA/SelectorUsage
end
end
end
ee/spec/features/projects_spec.rb
View file @
1046a3ae
...
...
@@ -19,7 +19,7 @@ RSpec.describe 'Project', :js do
it
"defaults to correct namespace"
do
visit
new_project_path
find
(
'[data-qa-selector="create_from_template_link"]'
).
click
find
(
'[data-qa-selector="create_from_template_link"]'
).
click
# rubocop:disable QA/SelectorUsage
find
(
'.custom-group-project-templates-tab'
).
click
find
(
"label[for=
#{
template
.
name
}
]"
).
click
...
...
@@ -28,7 +28,7 @@ RSpec.describe 'Project', :js do
it
"uses supplied namespace"
do
visit
new_project_path
(
namespace_id:
other_subgroup
.
id
)
find
(
'[data-qa-selector="create_from_template_link"]'
).
click
find
(
'[data-qa-selector="create_from_template_link"]'
).
click
# rubocop:disable QA/SelectorUsage
find
(
'.custom-group-project-templates-tab'
).
click
find
(
"label[for=
#{
template
.
name
}
]"
).
click
...
...
ee/spec/features/protected_branches_spec.rb
View file @
1046a3ae
...
...
@@ -98,7 +98,7 @@ RSpec.describe 'Protected Branches', :js do
it
'displays toggle off'
do
visit
project_settings_repository_path
(
project
)
page
.
within
'.qa-protected-branches-list'
do
page
.
within
'.qa-protected-branches-list'
do
# rubocop:disable QA/SelectorUsage
expect
(
page
).
not_to
have_css
(
'.js-code-owner-toggle.is-checked'
)
end
end
...
...
ee/spec/support/shared_examples/features/protected_branches_access_control_shared_examples.rb
View file @
1046a3ae
...
...
@@ -179,9 +179,9 @@ RSpec.shared_examples "protected branches > access control > EE" do
it
'unprotect/delete can be performed by a maintainer'
do
visit
project_protected_branches_path
(
project
)
expect
(
page
).
to
have_selector
(
'.qa-protected-branch'
)
expect
(
page
).
to
have_selector
(
'.qa-protected-branch'
)
# rubocop:disable QA/SelectorUsage
accept_alert
{
click_on
'Unprotect'
}
expect
(
page
).
not_to
have_selector
(
'.qa-protected-branch'
)
expect
(
page
).
not_to
have_selector
(
'.qa-protected-branch'
)
# rubocop:disable QA/SelectorUsage
end
context
'with unprotect access levels'
do
...
...
ee/spec/views/groups/settings/_transfer.html.haml_spec.rb
View file @
1046a3ae
...
...
@@ -9,8 +9,8 @@ RSpec.describe 'groups/settings/_transfer.html.haml' do
it
'enables the Select parent group dropdown and does not show an alert for a group'
do
render
'groups/settings/transfer'
,
group:
group
expect
(
rendered
).
to
have_selector
'[data-qa-selector="select_group_dropdown"]'
expect
(
rendered
).
not_to
have_selector
'[data-qa-selector="select_group_dropdown"][disabled]'
expect
(
rendered
).
to
have_selector
'[data-qa-selector="select_group_dropdown"]'
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
not_to
have_selector
'[data-qa-selector="select_group_dropdown"][disabled]'
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
not_to
have_selector
'[data-testid="group-to-transfer-has-linked-subscription-alert"]'
end
...
...
@@ -19,7 +19,7 @@ RSpec.describe 'groups/settings/_transfer.html.haml' do
render
'groups/settings/transfer'
,
group:
group
expect
(
rendered
).
to
have_selector
'[data-qa-selector="select_group_dropdown"][disabled]'
expect
(
rendered
).
to
have_selector
'[data-qa-selector="select_group_dropdown"][disabled]'
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
to
have_selector
'[data-testid="group-to-transfer-has-linked-subscription-alert"]'
end
...
...
@@ -29,8 +29,8 @@ RSpec.describe 'groups/settings/_transfer.html.haml' do
render
'groups/settings/transfer'
,
group:
subgroup
expect
(
rendered
).
to
have_selector
'[data-qa-selector="select_group_dropdown"]'
expect
(
rendered
).
not_to
have_selector
'[data-qa-selector="select_group_dropdown"][disabled]'
expect
(
rendered
).
to
have_selector
'[data-qa-selector="select_group_dropdown"]'
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
not_to
have_selector
'[data-qa-selector="select_group_dropdown"][disabled]'
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
not_to
have_selector
'[data-testid="group-to-transfer-has-linked-subscription-alert"]'
end
end
...
...
rubocop/cop/qa/selector_usage.rb
0 → 100644
View file @
1046a3ae
# frozen_string_literal: true
require_relative
'../../qa_helpers'
require_relative
'../../code_reuse_helpers'
module
RuboCop
module
Cop
module
QA
# This cop checks for the usage of data-qa-selectors or .qa-* classes in non-QA files
#
# @example
# # bad
# find('[data-qa-selector="the_selector"]')
# find('.qa-selector')
#
# # good
# find('[data-testid="the_selector"]')
# find('#selector')
class
SelectorUsage
<
RuboCop
::
Cop
::
Cop
include
QAHelpers
include
CodeReuseHelpers
SELECTORS
=
/\.qa-\w+|data-qa-\w+/
.
freeze
MESSAGE
=
%(Do not use `%s` as this is reserved for the end-to-end specs. Use a different selector or a data-testid instead.)
def
on_str
(
node
)
return
if
in_qa_file?
(
node
)
return
unless
in_spec?
(
node
)
add_offense
(
node
,
message:
MESSAGE
%
node
.
value
)
if
SELECTORS
=~
node
.
value
rescue
StandardError
# catch all errors and ignore them.
# without this catch-all rescue, rubocop will fail
# because of non-UTF-8 characters in some Strings
end
end
end
end
end
spec/features/admin/admin_appearance_spec.rb
View file @
1046a3ae
...
...
@@ -90,7 +90,7 @@ RSpec.describe 'Admin Appearance' do
sign_in
(
admin
)
gitlab_enable_admin_mode_sign_in
(
admin
)
visit
new_project_path
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
expect_custom_new_project_appearance
(
appearance
)
end
...
...
spec/features/admin/admin_groups_spec.rb
View file @
1046a3ae
...
...
@@ -256,7 +256,7 @@ RSpec.describe 'Admin Groups' do
visit
group_group_members_path
(
group
)
page
.
within
'[data-qa-selector="members_list"]'
do
page
.
within
'[data-qa-selector="members_list"]'
do
# rubocop:disable QA/SelectorUsage
expect
(
page
).
to
have_content
(
current_user
.
name
)
expect
(
page
).
to
have_content
(
'Developer'
)
end
...
...
@@ -265,7 +265,7 @@ RSpec.describe 'Admin Groups' do
visit
group_group_members_path
(
group
)
page
.
within
'[data-qa-selector="members_list"]'
do
page
.
within
'[data-qa-selector="members_list"]'
do
# rubocop:disable QA/SelectorUsage
expect
(
page
).
not_to
have_content
(
current_user
.
name
)
expect
(
page
).
not_to
have_content
(
'Developer'
)
end
...
...
spec/features/admin/users/user_spec.rb
View file @
1046a3ae
...
...
@@ -184,7 +184,7 @@ RSpec.describe 'Admin::Users::User' do
it
'logs in as the user when impersonate is clicked'
do
subject
find
(
'[data-qa-selector="user_menu"]'
).
click
find
(
'[data-qa-selector="user_menu"]'
).
click
# rubocop:disable QA/SelectorUsage
expect
(
page
.
find
(
:css
,
'[data-testid="user-profile-link"]'
)[
'data-user'
]).
to
eql
(
another_user
.
username
)
end
...
...
@@ -220,7 +220,7 @@ RSpec.describe 'Admin::Users::User' do
it
'logs out of impersonated user back to original user'
do
subject
find
(
'[data-qa-selector="user_menu"]'
).
click
find
(
'[data-qa-selector="user_menu"]'
).
click
# rubocop:disable QA/SelectorUsage
expect
(
page
.
find
(
:css
,
'[data-testid="user-profile-link"]'
)[
'data-user'
]).
to
eq
(
current_user
.
username
)
end
...
...
spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb
View file @
1046a3ae
...
...
@@ -33,7 +33,7 @@ RSpec.describe 'Resolving all open threads in a merge request from an issue', :j
context
'resolving the thread'
do
before
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
end
it
'hides the link for creating a new issue'
do
...
...
spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb
View file @
1046a3ae
...
...
@@ -35,7 +35,7 @@ RSpec.describe 'Resolve an open thread in a merge request by creating an issue',
context
'resolving the thread'
do
before
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
end
it
'hides the link for creating a new issue'
do
...
...
spec/features/issues/issue_sidebar_spec.rb
View file @
1046a3ae
...
...
@@ -408,7 +408,7 @@ RSpec.describe 'Issue Sidebar' do
context
'sidebar'
,
:js
do
it
'finds issue copy forwarding email'
do
expect
(
find
(
'[data-qa-selector="copy-forward-email"]'
).
text
).
to
eq
"Issue email:
#{
issue
.
creatable_note_email_address
(
user
)
}
"
expect
(
find
(
'[data-qa-selector="copy-forward-email"]'
).
text
).
to
eq
"Issue email:
#{
issue
.
creatable_note_email_address
(
user
)
}
"
# rubocop:disable QA/SelectorUsage
end
end
...
...
@@ -444,7 +444,7 @@ RSpec.describe 'Issue Sidebar' do
end
it
'does not find issue email'
do
expect
(
page
).
not_to
have_selector
(
'[data-qa-selector="copy-forward-email"]'
)
expect
(
page
).
not_to
have_selector
(
'[data-qa-selector="copy-forward-email"]'
)
# rubocop:disable QA/SelectorUsage
end
end
end
...
...
spec/features/issues/user_creates_issue_spec.rb
View file @
1046a3ae
...
...
@@ -182,7 +182,7 @@ RSpec.describe "User creates issue" do
end
it
'does not hide the milestone select'
do
expect
(
page
).
to
have_selector
(
'.qa-issuable-milestone-dropdown'
)
expect
(
page
).
to
have_selector
(
'.qa-issuable-milestone-dropdown'
)
# rubocop:disable QA/SelectorUsage
end
end
...
...
@@ -202,11 +202,11 @@ RSpec.describe "User creates issue" do
end
it
'shows the milestone select'
do
expect
(
page
).
to
have_selector
(
'.qa-issuable-milestone-dropdown'
)
expect
(
page
).
to
have_selector
(
'.qa-issuable-milestone-dropdown'
)
# rubocop:disable QA/SelectorUsage
end
it
'hides the weight input'
do
expect
(
page
).
not_to
have_selector
(
'.qa-issuable-weight-input'
)
expect
(
page
).
not_to
have_selector
(
'.qa-issuable-weight-input'
)
# rubocop:disable QA/SelectorUsage
end
it
'shows the incident help text'
do
...
...
spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
View file @
1046a3ae
...
...
@@ -63,7 +63,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it
'allows user to mark thread as resolved'
do
page
.
within
'.diff-content'
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
end
expect
(
page
).
to
have_selector
(
'.discussion-body'
,
visible:
false
)
...
...
@@ -80,7 +80,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it
'allows user to unresolve thread'
do
page
.
within
'.diff-content'
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
click_button
'Unresolve thread'
end
...
...
@@ -92,7 +92,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
describe
'resolved thread'
do
before
do
page
.
within
'.diff-content'
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
end
visit_merge_request
...
...
@@ -193,7 +193,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it
'allows user to resolve from reply form without a comment'
do
page
.
within
'.diff-content'
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
end
page
.
within
'.line-resolve-all-container'
do
...
...
@@ -230,7 +230,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it
'hides jump to next button when all resolved'
do
page
.
within
'.diff-content'
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
end
expect
(
page
).
to
have_selector
(
'.discussion-next-btn'
,
visible:
false
)
...
...
@@ -326,7 +326,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it
'allows user to mark all threads as resolved'
do
page
.
all
(
'.discussion-reply-holder'
,
count:
2
).
each
do
|
reply_holder
|
page
.
within
reply_holder
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
end
end
...
...
@@ -338,7 +338,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it
'allows user to quickly scroll to next unresolved thread'
do
page
.
within
(
'.discussion-reply-holder'
,
match: :first
)
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
end
page
.
within
'.line-resolve-all-container'
do
...
...
@@ -410,7 +410,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it
'allows user to mark thread as resolved'
do
page
.
within
'.diff-content'
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
end
page
.
within
'.diff-content .note'
do
...
...
@@ -425,7 +425,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it
'allows user to unresolve thread'
do
page
.
within
'.diff-content'
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
click_button
'Unresolve thread'
end
...
...
@@ -453,7 +453,7 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
it
'allows user to comment & unresolve thread'
do
page
.
within
'.diff-content'
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
find_field
(
'Reply…'
).
click
...
...
spec/features/project_variables_spec.rb
View file @
1046a3ae
...
...
@@ -21,7 +21,7 @@ RSpec.describe 'Project variables', :js do
click_button
(
'Add variable'
)
page
.
within
(
'#add-ci-variable'
)
do
find
(
'[data-qa-selector="ci_variable_key_field"] input'
).
set
(
'akey'
)
find
(
'[data-qa-selector="ci_variable_key_field"] input'
).
set
(
'akey'
)
# rubocop:disable QA/SelectorUsage
find
(
'#ci-variable-value'
).
set
(
'akey_value'
)
find
(
'[data-testid="environment-scope"]'
).
click
find
(
'[data-testid="ci-environment-search"]'
).
set
(
'review/*'
)
...
...
spec/features/projects/blobs/blob_show_spec.rb
View file @
1046a3ae
...
...
@@ -137,7 +137,7 @@ RSpec.describe 'File blob', :js do
context
'when ref switch'
do
def
switch_ref_to
(
ref_name
)
first
(
'.qa-branches-select'
).
click
first
(
'.qa-branches-select'
).
click
# rubocop:disable QA/SelectorUsage
page
.
within
'.project-refs-form'
do
click_link
ref_name
...
...
spec/features/projects/environments/environment_metrics_spec.rb
View file @
1046a3ae
...
...
@@ -30,9 +30,9 @@ RSpec.describe 'Environment > Metrics' do
click_link
'Monitoring'
expect
(
page
).
to
have_current_path
(
project_metrics_dashboard_path
(
project
,
environment:
environment
.
id
))
expect
(
page
).
to
have_css
(
'[data-qa-selector="environments_dropdown"]'
)
expect
(
page
).
to
have_css
(
'[data-qa-selector="environments_dropdown"]'
)
# rubocop:disable QA/SelectorUsage
within
(
'[data-qa-selector="environments_dropdown"]'
)
do
within
(
'[data-qa-selector="environments_dropdown"]'
)
do
# rubocop:disable QA/SelectorUsage
# Click on the dropdown
click_on
(
environment
.
name
)
...
...
@@ -58,7 +58,7 @@ RSpec.describe 'Environment > Metrics' do
it
'shows metrics'
,
:js
do
click_link
'Monitoring'
expect
(
page
).
to
have_css
(
'[data-qa-selector="prometheus_graphs"]'
)
expect
(
page
).
to
have_css
(
'[data-qa-selector="prometheus_graphs"]'
)
# rubocop:disable QA/SelectorUsage
end
it_behaves_like
'has environment selector'
...
...
spec/features/projects/environments/environments_spec.rb
View file @
1046a3ae
...
...
@@ -455,10 +455,10 @@ RSpec.describe 'Environments page', :js do
expect
(
page
).
to
have_content
'review-1'
expect
(
page
).
to
have_content
'review-2'
within
(
'.ci-table'
)
do
within
(
'[data-qa-selector="environment_item"]'
,
text:
'review-1'
)
do
within
(
'[data-qa-selector="environment_item"]'
,
text:
'review-1'
)
do
# rubocop:disable QA/SelectorUsage
expect
(
find
(
'.js-auto-stop'
).
text
).
not_to
be_empty
end
within
(
'[data-qa-selector="environment_item"]'
,
text:
'review-2'
)
do
within
(
'[data-qa-selector="environment_item"]'
,
text:
'review-2'
)
do
# rubocop:disable QA/SelectorUsage
expect
(
find
(
'.js-auto-stop'
).
text
).
not_to
be_empty
end
end
...
...
spec/features/projects/environments_pod_logs_spec.rb
View file @
1046a3ae
...
...
@@ -50,7 +50,7 @@ RSpec.describe 'Environment > Pod Logs', :js, :kubeclient do
wait_for_requests
page
.
within
(
'.qa-pods-dropdown'
)
do
page
.
within
(
'.qa-pods-dropdown'
)
do
# rubocop:disable QA/SelectorUsage
find
(
".dropdown-toggle:not([disabled])"
).
click
dropdown_items
=
find
(
".dropdown-menu"
).
all
(
".dropdown-item:not([disabled])"
)
...
...
spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb
View file @
1046a3ae
...
...
@@ -91,7 +91,7 @@ RSpec.describe 'User sees feature flag list', :js do
it
'shows the empty page'
do
expect
(
page
).
to
have_text
'Get started with feature flags'
expect
(
page
).
to
have_selector
(
'.btn-confirm'
,
text:
'New feature flag'
)
expect
(
page
).
to
have_selector
(
'[data-qa-selector="configure_feature_flags_button"]'
,
text:
'Configure'
)
expect
(
page
).
to
have_selector
(
'[data-qa-selector="configure_feature_flags_button"]'
,
text:
'Configure'
)
# rubocop:disable QA/SelectorUsage
end
end
end
spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
View file @
1046a3ae
...
...
@@ -18,7 +18,7 @@ RSpec.describe 'Projects > Files > Project owner sees a link to create a license
expect
(
current_path
).
to
eq
(
"/-/ide/project/
#{
project
.
full_path
}
/edit/master/-/LICENSE"
)
expect
(
page
).
to
have_selector
(
'.qa-file-templates-bar'
)
expect
(
page
).
to
have_selector
(
'.qa-file-templates-bar'
)
# rubocop:disable QA/SelectorUsage
select_template
(
'MIT License'
)
...
...
spec/features/projects/fork_spec.rb
View file @
1046a3ae
...
...
@@ -181,8 +181,8 @@ RSpec.describe 'Project fork' do
it
'allows user to fork only to the group on fork page'
,
:js
do
visit
new_project_fork_path
(
project
)
to_personal_namespace
=
find
(
'[data-qa-selector=fork_namespace_button].disabled'
)
to_group
=
find
(
".fork-groups button[data-qa-name=
#{
group
.
name
}
]"
)
to_personal_namespace
=
find
(
'[data-qa-selector=fork_namespace_button].disabled'
)
# rubocop:disable QA/SelectorUsage
to_group
=
find
(
".fork-groups button[data-qa-name=
#{
group
.
name
}
]"
)
# rubocop:disable QA/SelectorUsage
expect
(
to_personal_namespace
).
not_to
be_nil
expect
(
to_group
).
not_to
be_disabled
...
...
spec/features/projects/import_export/import_file_spec.rb
View file @
1046a3ae
...
...
@@ -62,6 +62,6 @@ RSpec.describe 'Import/Export - project import integration test', :js do
end
def
click_import_project
find
(
'[data-qa-panel-name="import_project"]'
).
click
find
(
'[data-qa-panel-name="import_project"]'
).
click
# rubocop:disable QA/SelectorUsage
end
end
spec/features/projects/members/invite_group_spec.rb
View file @
1046a3ae
...
...
@@ -13,7 +13,7 @@ RSpec.describe 'Project > Members > Invite group', :js do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:invite_members_group_modal_enabled
,
:expected_invite_group_selector
)
do
true
|
'button[data-qa-selector="invite_a_group_button"]'
true
|
'button[data-qa-selector="invite_a_group_button"]'
# rubocop:disable QA/SelectorUsage
false
|
'#invite-group-tab'
end
...
...
@@ -43,7 +43,7 @@ RSpec.describe 'Project > Members > Invite group', :js do
end
describe
'Share with group lock'
do
let
(
:invite_group_selector
)
{
'button[data-qa-selector="invite_a_group_button"]'
}
let
(
:invite_group_selector
)
{
'button[data-qa-selector="invite_a_group_button"]'
}
# rubocop:disable QA/SelectorUsage
shared_examples
'the project can be shared with groups'
do
it
'the "Invite a group" button exists'
do
...
...
spec/features/projects/new_project_spec.rb
View file @
1046a3ae
...
...
@@ -19,7 +19,7 @@ RSpec.describe 'New project', :js do
)
visit
new_project_path
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
expect
(
page
).
to
have_content
'Other visibility settings have been disabled by the administrator.'
end
...
...
@@ -30,7 +30,7 @@ RSpec.describe 'New project', :js do
)
visit
new_project_path
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
expect
(
page
).
to
have_content
'Visibility settings have been disabled by the administrator.'
end
...
...
@@ -45,14 +45,14 @@ RSpec.describe 'New project', :js do
it
'shows "New project" page'
,
:js
do
visit
new_project_path
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
expect
(
page
).
to
have_content
(
'Project name'
)
expect
(
page
).
to
have_content
(
'Project URL'
)
expect
(
page
).
to
have_content
(
'Project slug'
)
click_link
(
'New project'
)
find
(
'[data-qa-panel-name="import_project"]'
).
click
find
(
'[data-qa-panel-name="import_project"]'
).
click
# rubocop:disable QA/SelectorUsage
expect
(
page
).
to
have_link
(
'GitHub'
)
expect
(
page
).
to
have_link
(
'Bitbucket'
)
...
...
@@ -65,7 +65,7 @@ RSpec.describe 'New project', :js do
before
do
visit
new_project_path
find
(
'[data-qa-panel-name="import_project"]'
).
click
find
(
'[data-qa-panel-name="import_project"]'
).
click
# rubocop:disable QA/SelectorUsage
end
it
'has Manifest file'
do
...
...
@@ -79,7 +79,7 @@ RSpec.describe 'New project', :js do
stub_application_setting
(
default_project_visibility:
level
)
visit
new_project_path
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
page
.
within
(
'#blank-project-pane'
)
do
expect
(
find_field
(
"project_visibility_level_
#{
level
}
"
)).
to
be_checked
end
...
...
@@ -87,7 +87,7 @@ RSpec.describe 'New project', :js do
it
"saves visibility level
#{
level
}
on validation error"
do
visit
new_project_path
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
choose
(
key
)
click_button
(
'Create project'
)
...
...
@@ -107,7 +107,7 @@ RSpec.describe 'New project', :js do
context
'when admin mode is enabled'
,
:enable_admin_mode
do
it
'has private selected'
do
visit
new_project_path
(
namespace_id:
group
.
id
)
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
page
.
within
(
'#blank-project-pane'
)
do
expect
(
find_field
(
"project_visibility_level_
#{
Gitlab
::
VisibilityLevel
::
PRIVATE
}
"
)).
to
be_checked
...
...
@@ -134,7 +134,7 @@ RSpec.describe 'New project', :js do
context
'when admin mode is enabled'
,
:enable_admin_mode
do
it
'has private selected'
do
visit
new_project_path
(
namespace_id:
group
.
id
,
project:
{
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
})
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
page
.
within
(
'#blank-project-pane'
)
do
expect
(
find_field
(
"project_visibility_level_
#{
Gitlab
::
VisibilityLevel
::
PRIVATE
}
"
)).
to
be_checked
...
...
@@ -155,7 +155,7 @@ RSpec.describe 'New project', :js do
context
'Readme selector'
do
it
'shows the initialize with Readme checkbox on "Blank project" tab'
do
visit
new_project_path
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
expect
(
page
).
to
have_css
(
'input#project_initialize_with_readme'
)
expect
(
page
).
to
have_content
(
'Initialize repository with a README'
)
...
...
@@ -163,7 +163,7 @@ RSpec.describe 'New project', :js do
it
'does not show the initialize with Readme checkbox on "Create from template" tab'
do
visit
new_project_path
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
# rubocop:disable QA/SelectorUsage
first
(
'.choose-template'
).
click
page
.
within
'.project-fields-form'
do
...
...
@@ -174,7 +174,7 @@ RSpec.describe 'New project', :js do
it
'does not show the initialize with Readme checkbox on "Import project" tab'
do
visit
new_project_path
find
(
'[data-qa-panel-name="import_project"]'
).
click
find
(
'[data-qa-panel-name="import_project"]'
).
click
# rubocop:disable QA/SelectorUsage
first
(
'.js-import-git-toggle-button'
).
click
page
.
within
'#import-project-pane'
do
...
...
@@ -188,7 +188,7 @@ RSpec.describe 'New project', :js do
context
'with user namespace'
do
before
do
visit
new_project_path
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
end
it
'selects the user namespace'
do
...
...
@@ -204,7 +204,7 @@ RSpec.describe 'New project', :js do
before
do
group
.
add_owner
(
user
)
visit
new_project_path
(
namespace_id:
group
.
id
)
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
end
it
'selects the group namespace'
do
...
...
@@ -221,7 +221,7 @@ RSpec.describe 'New project', :js do
before
do
group
.
add_maintainer
(
user
)
visit
new_project_path
(
namespace_id:
subgroup
.
id
)
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
end
it
'selects the group namespace'
do
...
...
@@ -241,7 +241,7 @@ RSpec.describe 'New project', :js do
internal_group
.
add_owner
(
user
)
private_group
.
add_owner
(
user
)
visit
new_project_path
(
namespace_id:
public_group
.
id
)
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
end
it
'enables the correct visibility options'
do
...
...
@@ -271,7 +271,7 @@ RSpec.describe 'New project', :js do
context
'Import project options'
,
:js
do
before
do
visit
new_project_path
find
(
'[data-qa-panel-name="import_project"]'
).
click
find
(
'[data-qa-panel-name="import_project"]'
).
click
# rubocop:disable QA/SelectorUsage
end
context
'from git repository url, "Repo by URL"'
do
...
...
@@ -343,7 +343,7 @@ RSpec.describe 'New project', :js do
before
do
group
.
add_developer
(
user
)
visit
new_project_path
(
namespace_id:
group
.
id
)
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
end
it
'selects the group namespace'
do
...
...
spec/features/projects/show/user_sees_collaboration_links_spec.rb
View file @
1046a3ae
...
...
@@ -39,7 +39,7 @@ RSpec.describe 'Projects > Show > Collaboration links', :js do
# The dropdown above the tree
page
.
within
(
'.repo-breadcrumb'
)
do
find
(
'.qa-add-to-tree'
).
click
find
(
'.qa-add-to-tree'
).
click
# rubocop:disable QA/SelectorUsage
aggregate_failures
'dropdown links above the repo tree'
do
expect
(
page
).
to
have_link
(
'New file'
)
...
...
@@ -71,7 +71,7 @@ RSpec.describe 'Projects > Show > Collaboration links', :js do
find_new_menu_toggle
.
click
end
expect
(
page
).
not_to
have_selector
(
'.qa-add-to-tree'
)
expect
(
page
).
not_to
have_selector
(
'.qa-add-to-tree'
)
# rubocop:disable QA/SelectorUsage
expect
(
page
).
not_to
have_link
(
'Web IDE'
)
end
...
...
spec/features/projects/tree/create_directory_spec.rb
View file @
1046a3ae
...
...
@@ -49,8 +49,8 @@ RSpec.describe 'Multi-file editor new directory', :js do
# Compact mode depends on the size of window. If it is shorter than MAX_WINDOW_HEIGHT_COMPACT,
# (as it is with WEBDRIVER_HEADLESS=0), this initial commit button will exist. Otherwise, if it is
# taller (as it is by default with chrome headless) then the button will not exist.
if
page
.
has_css?
(
'.qa-begin-commit-button'
)
find
(
'.qa-begin-commit-button'
).
click
if
page
.
has_css?
(
'.qa-begin-commit-button'
)
# rubocop:disable QA/SelectorUsage
find
(
'.qa-begin-commit-button'
).
click
# rubocop:disable QA/SelectorUsage
end
fill_in
(
'commit-message'
,
with:
'commit message ide'
)
...
...
spec/features/projects/tree/create_file_spec.rb
View file @
1046a3ae
...
...
@@ -39,8 +39,8 @@ RSpec.describe 'Multi-file editor new file', :js do
# Compact mode depends on the size of window. If it is shorter than MAX_WINDOW_HEIGHT_COMPACT,
# (as it is with WEBDRIVER_HEADLESS=0), this initial commit button will exist. Otherwise, if it is
# taller (as it is by default with chrome headless) then the button will not exist.
if
page
.
has_css?
(
'.qa-begin-commit-button'
)
find
(
'.qa-begin-commit-button'
).
click
if
page
.
has_css?
(
'.qa-begin-commit-button'
)
# rubocop:disable QA/SelectorUsage
find
(
'.qa-begin-commit-button'
).
click
# rubocop:disable QA/SelectorUsage
end
fill_in
(
'commit-message'
,
with:
'commit message ide'
)
...
...
spec/features/projects/tree/tree_show_spec.rb
View file @
1046a3ae
...
...
@@ -26,7 +26,7 @@ RSpec.describe 'Projects tree', :js do
expect
(
page
).
to
have_selector
(
'.tree-item'
)
expect
(
page
).
to
have_content
(
'add tests for .gitattributes custom highlighting'
)
expect
(
page
).
not_to
have_selector
(
'.flash-alert'
)
expect
(
page
).
not_to
have_selector
(
'[data-qa-selector="label-lfs"]'
,
text:
'LFS'
)
expect
(
page
).
not_to
have_selector
(
'[data-qa-selector="label-lfs"]'
,
text:
'LFS'
)
# rubocop:disable QA/SelectorUsage
end
it
'renders tree table for a subtree without errors'
do
...
...
@@ -35,7 +35,7 @@ RSpec.describe 'Projects tree', :js do
expect
(
page
).
to
have_selector
(
'.tree-item'
)
expect
(
page
).
to
have_content
(
'add spaces in whitespace file'
)
expect
(
page
).
not_to
have_selector
(
'[data-qa-selector="label-lfs"]'
,
text:
'LFS'
)
expect
(
page
).
not_to
have_selector
(
'[data-qa-selector="label-lfs"]'
,
text:
'LFS'
)
# rubocop:disable QA/SelectorUsage
expect
(
page
).
not_to
have_selector
(
'.flash-alert'
)
end
...
...
@@ -112,7 +112,7 @@ RSpec.describe 'Projects tree', :js do
it
'renders LFS badge on blob item'
do
visit
project_tree_path
(
project
,
File
.
join
(
'master'
,
'files/lfs'
))
expect
(
page
).
to
have_selector
(
'[data-qa-selector="label-lfs"]'
,
text:
'LFS'
)
expect
(
page
).
to
have_selector
(
'[data-qa-selector="label-lfs"]'
,
text:
'LFS'
)
# rubocop:disable QA/SelectorUsage
end
end
...
...
spec/features/projects/user_creates_project_spec.rb
View file @
1046a3ae
...
...
@@ -13,7 +13,7 @@ RSpec.describe 'User creates a project', :js do
it
'creates a new project'
do
visit
(
new_project_path
)
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
fill_in
(
:project_name
,
with:
'Empty'
)
expect
(
page
).
to
have_checked_field
'Initialize repository with a README'
...
...
@@ -43,7 +43,7 @@ RSpec.describe 'User creates a project', :js do
it
'creates a new project'
do
visit
(
new_project_path
)
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
fill_in
:project_name
,
with:
'A Subgroup Project'
fill_in
:project_path
,
with:
'a-subgroup-project'
...
...
@@ -72,7 +72,7 @@ RSpec.describe 'User creates a project', :js do
it
'creates a new project'
do
visit
(
new_project_path
)
find
(
'[data-qa-panel-name="blank_project"]'
).
click
find
(
'[data-qa-panel-name="blank_project"]'
).
click
# rubocop:disable QA/SelectorUsage
fill_in
:project_name
,
with:
'a-new-project'
fill_in
:project_path
,
with:
'a-new-project'
...
...
spec/features/projects_spec.rb
View file @
1046a3ae
...
...
@@ -16,7 +16,7 @@ RSpec.describe 'Project' do
shared_examples
'creates from template'
do
|
template
,
sub_template_tab
=
nil
|
it
"is created from template"
,
:js
do
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
find
(
'[data-qa-panel-name="create_from_template"]'
).
click
# rubocop:disable QA/SelectorUsage
find
(
".project-template
#{
sub_template_tab
}
"
).
click
if
sub_template_tab
find
(
"label[for=
#{
template
.
name
}
]"
).
click
fill_in
(
"project_name"
,
with:
template
.
name
)
...
...
@@ -290,7 +290,7 @@ RSpec.describe 'Project' do
it
'has working links to submodules'
do
click_link
(
'645f6c4c'
)
expect
(
page
).
to
have_selector
(
'.qa-branches-select'
,
text:
'645f6c4c82fd3f5e06f67134450a570b795e55a6'
)
expect
(
page
).
to
have_selector
(
'.qa-branches-select'
,
text:
'645f6c4c82fd3f5e06f67134450a570b795e55a6'
)
# rubocop:disable QA/SelectorUsage
end
context
'for signed commit on default branch'
,
:js
do
...
...
spec/rubocop/cop/qa/selector_usage_spec.rb
0 → 100644
View file @
1046a3ae
# frozen_string_literal: true
require
'fast_spec_helper'
require_relative
'../../../../rubocop/cop/qa/selector_usage'
RSpec
.
describe
RuboCop
::
Cop
::
QA
::
SelectorUsage
do
subject
(
:cop
)
{
described_class
.
new
}
shared_examples
'non-qa file usage'
do
it
'reports an offense'
do
expect_offense
(
<<-
RUBY
)
find('
#{
selector
}
').click
#{
'^'
*
(
selector
.
size
+
2
)
}
Do not use `
#{
selector
}
` as this is reserved for the end-to-end specs. Use a different selector or a data-testid instead.
RUBY
end
end
context
'in a QA file'
do
before
do
allow
(
cop
).
to
receive
(
:in_qa_file?
).
and_return
(
true
)
end
it
'has no error'
do
expect_no_offenses
(
<<-
RUBY
)
has_element?('[data-qa-selector="my_selector"]')
RUBY
end
end
context
'outside of QA'
do
before
do
allow
(
cop
).
to
receive
(
:in_qa_file?
).
and_return
(
false
)
allow
(
cop
).
to
receive
(
:in_spec?
).
and_return
(
true
)
end
context
'data-qa-selector'
do
let
(
:selector
)
{
'[data-qa-selector="my_selector"]'
}
it_behaves_like
'non-qa file usage'
end
context
'qa class'
do
let
(
:selector
)
{
'.qa-selector'
}
it_behaves_like
'non-qa file usage'
end
end
end
spec/support/shared_examples/features/discussion_comments_shared_example.rb
View file @
1046a3ae
...
...
@@ -308,7 +308,7 @@ RSpec.shared_examples 'thread comments for issue, epic and merge request' do |re
let
(
:reply_id
)
{
find
(
"
#{
comments_selector
}
.note:last-of-type"
,
match: :first
)[
'data-note-id'
]
}
it
'can be replied to after resolving'
do
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
wait_for_requests
refresh
...
...
@@ -320,7 +320,7 @@ RSpec.shared_examples 'thread comments for issue, epic and merge request' do |re
it
'shows resolved thread when toggled'
do
submit_reply
(
'a'
)
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
find
(
'button[data-qa-selector="resolve_discussion_button"]'
).
click
# rubocop:disable QA/SelectorUsage
wait_for_requests
expect
(
page
).
to
have_selector
(
".note-row-
#{
note_id
}
"
,
visible:
true
)
...
...
spec/support/shared_examples/features/packages_shared_examples.rb
View file @
1046a3ae
...
...
@@ -14,7 +14,7 @@ RSpec.shared_examples 'packages list' do |check_project_name: false|
end
def
package_table_row
(
index
)
page
.
all
(
"
#{
packages_table_selector
}
> [data-qa-selector=
\"
package_row
\"
]"
)[
index
].
text
page
.
all
(
"
#{
packages_table_selector
}
> [data-qa-selector=
\"
package_row
\"
]"
)[
index
].
text
# rubocop:disable QA/SelectorUsage
end
end
...
...
@@ -92,7 +92,7 @@ RSpec.shared_examples 'shared package sorting' do
end
def
packages_table_selector
'[data-qa-selector="packages-table"]'
'[data-qa-selector="packages-table"]'
# rubocop:disable QA/SelectorUsage
end
def
click_sort_option
(
option
,
ascending
)
...
...
spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb
View file @
1046a3ae
...
...
@@ -23,7 +23,7 @@ RSpec.shared_examples 'Deploy keys with protected branches' do
find
(
".js-allowed-to-push"
).
click
wait_for_requests
within
(
'.qa-allowed-to-push-dropdown'
)
do
within
(
'.qa-allowed-to-push-dropdown'
)
do
# rubocop:disable QA/SelectorUsage
dropdown_headers
=
page
.
all
(
'.dropdown-header'
).
map
(
&
:text
)
expect
(
dropdown_headers
).
to
contain_exactly
(
*
all_dropdown_sections
)
...
...
@@ -38,7 +38,7 @@ RSpec.shared_examples 'Deploy keys with protected branches' do
find
(
".js-allowed-to-merge"
).
click
wait_for_requests
within
(
'.qa-allowed-to-merge-dropdown'
)
do
within
(
'.qa-allowed-to-merge-dropdown'
)
do
# rubocop:disable QA/SelectorUsage
dropdown_headers
=
page
.
all
(
'.dropdown-header'
).
map
(
&
:text
)
expect
(
dropdown_headers
).
to
contain_exactly
(
*
dropdown_sections_minus_deploy_keys
)
...
...
@@ -68,7 +68,7 @@ RSpec.shared_examples 'Deploy keys with protected branches' do
find
(
".js-allowed-to-push"
).
click
wait_for_requests
within
(
'.qa-allowed-to-push-dropdown'
)
do
within
(
'.qa-allowed-to-push-dropdown'
)
do
# rubocop:disable QA/SelectorUsage
dropdown_headers
=
page
.
all
(
'.dropdown-header'
).
map
(
&
:text
)
expect
(
dropdown_headers
).
to
contain_exactly
(
*
dropdown_sections_minus_deploy_keys
)
...
...
spec/support/shared_examples/features/rss_shared_examples.rb
View file @
1046a3ae
...
...
@@ -9,7 +9,7 @@ end
RSpec
.
shared_examples
"it has an RSS button with current_user's feed token"
do
it
"shows the RSS button with current_user's feed token"
do
expect
(
page
)
.
to
have_css
(
"a:has(.qa-rss-icon)[href*='feed_token=
#{
user
.
feed_token
}
']"
)
.
to
have_css
(
"a:has(.qa-rss-icon)[href*='feed_token=
#{
user
.
feed_token
}
']"
)
# rubocop:disable QA/SelectorUsage
end
end
...
...
@@ -22,6 +22,6 @@ end
RSpec
.
shared_examples
"it has an RSS button without a feed token"
do
it
"shows the RSS button without a feed token"
do
expect
(
page
)
.
to
have_css
(
"a:has(.qa-rss-icon):not([href*='feed_token'])"
)
.
to
have_css
(
"a:has(.qa-rss-icon):not([href*='feed_token'])"
)
# rubocop:disable QA/SelectorUsage
end
end
spec/support/shared_examples/features/variable_list_shared_examples.rb
View file @
1046a3ae
...
...
@@ -91,7 +91,7 @@ RSpec.shared_examples 'variable list' do
end
page
.
within
(
'#add-ci-variable'
)
do
find
(
'[data-qa-selector="ci_variable_key_field"] input'
).
set
(
'new_key'
)
find
(
'[data-qa-selector="ci_variable_key_field"] input'
).
set
(
'new_key'
)
# rubocop:disable QA/SelectorUsage
click_button
(
'Update variable'
)
end
...
...
@@ -173,7 +173,7 @@ RSpec.shared_examples 'variable list' do
click_button
(
'Add variable'
)
page
.
within
(
'#add-ci-variable'
)
do
find
(
'[data-qa-selector="ci_variable_key_field"] input'
).
set
(
'empty_mask_key'
)
find
(
'[data-qa-selector="ci_variable_key_field"] input'
).
set
(
'empty_mask_key'
)
# rubocop:disable QA/SelectorUsage
find
(
'[data-testid="ci-variable-protected-checkbox"]'
).
click
find
(
'[data-testid="ci-variable-masked-checkbox"]'
).
click
...
...
@@ -286,8 +286,8 @@ RSpec.shared_examples 'variable list' do
wait_for_requests
page
.
within
(
'#add-ci-variable'
)
do
find
(
'[data-qa-selector="ci_variable_key_field"] input'
).
set
(
key
)
find
(
'[data-qa-selector="ci_variable_value_field"]'
).
set
(
value
)
if
value
.
present?
find
(
'[data-qa-selector="ci_variable_key_field"] input'
).
set
(
key
)
# rubocop:disable QA/SelectorUsage
find
(
'[data-qa-selector="ci_variable_value_field"]'
).
set
(
value
)
if
value
.
present?
# rubocop:disable QA/SelectorUsage
find
(
'[data-testid="ci-variable-protected-checkbox"]'
).
click
if
protected
find
(
'[data-testid="ci-variable-masked-checkbox"]'
).
click
if
masked
...
...
spec/support/shared_examples/features/wiki/user_views_asciidoc_page_with_includes_shared_examples.rb
View file @
1046a3ae
# frozen_string_literal: true
RSpec
.
shared_examples
'User views AsciiDoc page with includes'
do
let_it_be
(
:wiki_content_selector
)
{
'[data-qa-selector=wiki_page_content]'
}
let_it_be
(
:wiki_content_selector
)
{
'[data-qa-selector=wiki_page_content]'
}
# rubocop:disable QA/SelectorUsage
let!
(
:included_wiki_page
)
{
create_wiki_page
(
'included_page'
,
content:
'Content from the included page'
)}
let!
(
:wiki_page
)
{
create_wiki_page
(
'home'
,
content:
"Content from the main page.
\n
include::included_page.asciidoc[]"
)
}
...
...
spec/views/admin/sessions/new.html.haml_spec.rb
View file @
1046a3ae
...
...
@@ -19,9 +19,9 @@ RSpec.describe 'admin/sessions/new.html.haml' do
it
'shows enter password form'
do
render
expect
(
rendered
).
to
have_selector
(
'[data-qa-selector="sign_in_tab"]'
)
expect
(
rendered
).
to
have_selector
(
'[data-qa-selector="sign_in_tab"]'
)
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
to
have_css
(
'#login-pane.active'
)
expect
(
rendered
).
to
have_selector
(
'[data-qa-selector="password_field"]'
)
expect
(
rendered
).
to
have_selector
(
'[data-qa-selector="password_field"]'
)
# rubocop:disable QA/SelectorUsage
end
it
'warns authentication not possible if password not set'
do
...
...
@@ -60,7 +60,7 @@ RSpec.describe 'admin/sessions/new.html.haml' do
it
'is shown when enabled'
do
render
expect
(
rendered
).
to
have_selector
(
'[data-qa-selector="ldap_tab"]'
)
expect
(
rendered
).
to
have_selector
(
'[data-qa-selector="ldap_tab"]'
)
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
to
have_css
(
'.login-box#ldapmain'
)
expect
(
rendered
).
to
have_field
(
'LDAP Username'
)
expect
(
rendered
).
not_to
have_content
(
'No authentication methods configured'
)
...
...
@@ -71,7 +71,7 @@ RSpec.describe 'admin/sessions/new.html.haml' do
render
expect
(
rendered
).
not_to
have_selector
(
'[data-qa-selector="ldap_tab"]'
)
expect
(
rendered
).
not_to
have_selector
(
'[data-qa-selector="ldap_tab"]'
)
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
not_to
have_field
(
'LDAP Username'
)
expect
(
rendered
).
to
have_content
(
'No authentication methods configured'
)
end
...
...
spec/views/devise/sessions/new.html.haml_spec.rb
View file @
1046a3ae
...
...
@@ -48,7 +48,7 @@ RSpec.describe 'devise/sessions/new' do
render
expect
(
rendered
).
to
have_selector
(
'.new-session-tabs'
)
expect
(
rendered
).
to
have_selector
(
'[data-qa-selector="ldap_tab"]'
)
expect
(
rendered
).
to
have_selector
(
'[data-qa-selector="ldap_tab"]'
)
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
to
have_field
(
'LDAP Username'
)
end
...
...
@@ -58,7 +58,7 @@ RSpec.describe 'devise/sessions/new' do
render
expect
(
rendered
).
to
have_content
(
'No authentication methods configured'
)
expect
(
rendered
).
not_to
have_selector
(
'[data-qa-selector="ldap_tab"]'
)
expect
(
rendered
).
not_to
have_selector
(
'[data-qa-selector="ldap_tab"]'
)
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
not_to
have_field
(
'LDAP Username'
)
end
end
...
...
spec/views/groups/settings/_transfer.html.haml_spec.rb
View file @
1046a3ae
...
...
@@ -9,8 +9,8 @@ RSpec.describe 'groups/settings/_transfer.html.haml' do
render
'groups/settings/transfer'
,
group:
group
expect
(
rendered
).
to
have_selector
'[data-qa-selector="select_group_dropdown"]'
expect
(
rendered
).
not_to
have_selector
'[data-qa-selector="select_group_dropdown"][disabled]'
expect
(
rendered
).
to
have_selector
'[data-qa-selector="select_group_dropdown"]'
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
not_to
have_selector
'[data-qa-selector="select_group_dropdown"][disabled]'
# rubocop:disable QA/SelectorUsage
expect
(
rendered
).
not_to
have_selector
'[data-testid="group-to-transfer-has-linked-subscription-alert"]'
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment