Commit 37854191 authored by Micael Bergeron's avatar Micael Bergeron

Update the tests to use a testid instead of a class

This commit removes the `.project-filter` class that was only used for
testing purposes, and replaced it with a proper `data-testid` attribute.
parent ecf8d59f
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
= dropdown_content = dropdown_content
= dropdown_loading = dropdown_loading
.dropdown.project-filter.form-group.mb-lg-0.mx-lg-1 .dropdown.form-group.mb-lg-0.mx-lg-1{ data: { testid: "project-filter" } }
%label.d-block{ for: "dashboard_search_project" } %label.d-block{ for: "dashboard_search_project" }
= _("Project") = _("Project")
%button.dropdown-menu-toggle.gl-display-inline-flex.js-search-project-dropdown.gl-mt-0{ type: "button", id: "dashboard_search_project", data: { toggle: "dropdown", target: '.project-filter' } } %button.dropdown-menu-toggle.gl-display-inline-flex.js-search-project-dropdown.gl-mt-0{ type: "button", id: "dashboard_search_project", data: { toggle: "dropdown" } }
%span.dropdown-toggle-text.gl-flex-grow-1.str-truncated-100 %span.dropdown-toggle-text.gl-flex-grow-1.str-truncated-100
= @project&.full_name || _("Any") = @project&.full_name || _("Any")
- if @project.present? - if @project.present?
......
...@@ -28,10 +28,7 @@ RSpec.describe 'User searches for code' do ...@@ -28,10 +28,7 @@ RSpec.describe 'User searches for code' do
before do before do
visit(search_path) visit(search_path)
find('.js-search-project-dropdown').click find('.js-search-project-dropdown').click
find('[data-testid="project-filter"]').click_link(project.full_name)
page.within('.project-filter') do
click_link(project.full_name)
end
end end
include_examples 'top right search form' include_examples 'top right search form'
......
...@@ -86,10 +86,7 @@ RSpec.describe 'User searches for issues', :js do ...@@ -86,10 +86,7 @@ RSpec.describe 'User searches for issues', :js do
context 'when on a project page' do context 'when on a project page' do
it 'finds an issue' do it 'finds an issue' do
find('.js-search-project-dropdown').click find('.js-search-project-dropdown').click
find('[data-testid="project-filter"]').click_link(project.full_name)
page.within('.project-filter') do
click_link(project.full_name)
end
search_for_issue(issue1.title) search_for_issue(issue1.title)
......
...@@ -31,10 +31,7 @@ RSpec.describe 'User searches for merge requests', :js do ...@@ -31,10 +31,7 @@ RSpec.describe 'User searches for merge requests', :js do
context 'when on a project page' do context 'when on a project page' do
it 'finds a merge request' do it 'finds a merge request' do
find('.js-search-project-dropdown').click find('.js-search-project-dropdown').click
find('[data-testid="project-filter"]').click_link(project.full_name)
page.within('.project-filter') do
click_link(project.full_name)
end
fill_in('dashboard_search', with: merge_request1.title) fill_in('dashboard_search', with: merge_request1.title)
find('.btn-search').click find('.btn-search').click
......
...@@ -31,10 +31,7 @@ RSpec.describe 'User searches for milestones', :js do ...@@ -31,10 +31,7 @@ RSpec.describe 'User searches for milestones', :js do
context 'when on a project page' do context 'when on a project page' do
it 'finds a milestone' do it 'finds a milestone' do
find('.js-search-project-dropdown').click find('.js-search-project-dropdown').click
find('[data-testid="project-filter"]').click_link(project.full_name)
page.within('.project-filter') do
click_link(project.full_name)
end
fill_in('dashboard_search', with: milestone1.title) fill_in('dashboard_search', with: milestone1.title)
find('.btn-search').click find('.btn-search').click
......
...@@ -19,10 +19,7 @@ RSpec.describe 'User searches for wiki pages', :js do ...@@ -19,10 +19,7 @@ RSpec.describe 'User searches for wiki pages', :js do
shared_examples 'search wiki blobs' do shared_examples 'search wiki blobs' do
it 'finds a page' do it 'finds a page' do
find('.js-search-project-dropdown').click find('.js-search-project-dropdown').click
find('[data-testid="project-filter"]').click_link(project.full_name)
page.within('.project-filter') do
click_link(project.full_name)
end
fill_in('dashboard_search', with: search_term) fill_in('dashboard_search', with: search_term)
find('.btn-search').click find('.btn-search').click
......
...@@ -28,7 +28,7 @@ RSpec.describe 'User uses search filters', :js do ...@@ -28,7 +28,7 @@ RSpec.describe 'User uses search filters', :js do
expect(find('.js-search-group-dropdown')).to have_content(group.name) expect(find('.js-search-group-dropdown')).to have_content(group.name)
page.within('.project-filter') do page.within('[data-testid="project-filter"]') do
find('.js-search-project-dropdown').click find('.js-search-project-dropdown').click
wait_for_requests wait_for_requests
...@@ -57,7 +57,7 @@ RSpec.describe 'User uses search filters', :js do ...@@ -57,7 +57,7 @@ RSpec.describe 'User uses search filters', :js do
it 'shows a project' do it 'shows a project' do
visit search_path visit search_path
page.within('.project-filter') do page.within('[data-testid="project-filter"]') do
find('.js-search-project-dropdown').click find('.js-search-project-dropdown').click
wait_for_requests wait_for_requests
...@@ -77,7 +77,7 @@ RSpec.describe 'User uses search filters', :js do ...@@ -77,7 +77,7 @@ RSpec.describe 'User uses search filters', :js do
describe 'clear filter button' do describe 'clear filter button' do
it 'removes Project filters' do it 'removes Project filters' do
link = find('.project-filter .js-search-clear') link = find('[data-testid="project-filter"] .js-search-clear')
params = CGI.parse(URI.parse(link[:href]).query) params = CGI.parse(URI.parse(link[:href]).query)
expect(params).not_to include(:project_id) expect(params).not_to include(:project_id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment