Commit d030a54e authored by Rémy Coutable's avatar Rémy Coutable

Fix a flaky spec for sorting projects in dashboard

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 6b2f4ea5
...@@ -151,34 +151,22 @@ describe 'Dashboard > User filters projects' do ...@@ -151,34 +151,22 @@ describe 'Dashboard > User filters projects' do
end end
describe 'Sorting' do describe 'Sorting' do
before do let(:desc_sorted_project_names) { %w[Treasure Victorialand] }
[
{ name: 'Red ribbon army', created_at: 2.days.ago },
{ name: 'Cell saga', created_at: Time.now },
{ name: 'Frieza saga', created_at: 10.days.ago }
].each do |item|
project = create(:project, name: item[:name], namespace: user.namespace, created_at: item[:created_at])
project.add_developer(user)
end
before do
user.toggle_star(project) user.toggle_star(project)
user.toggle_star(project2) user.toggle_star(project2)
user2.toggle_star(project2) user2.toggle_star(project2)
end end
it 'includes sorting direction' do it 'has all sorting options', :js do
sorting_dropdown = page.find('.filtered-search-block #filtered-search-sorting-dropdown') sorting_dropdown = page.find('.filtered-search-block #filtered-search-sorting-dropdown')
expect(sorting_dropdown).to have_css '.reverse-sort-btn' expect(sorting_dropdown).to have_css '.reverse-sort-btn'
end
it 'has all sorting options', :js do
sorting_dropdown = page.find('.filtered-search-block #filtered-search-sorting-dropdown')
sorting_option_labels = ['Last updated', 'Created date', 'Name', 'Stars']
sorting_dropdown.click sorting_dropdown.click
sorting_option_labels.each do |label| ['Last updated', 'Created date', 'Name', 'Stars'].each do |label|
expect(sorting_dropdown).to have_content(label) expect(sorting_dropdown).to have_content(label)
end end
end end
...@@ -194,16 +182,11 @@ describe 'Dashboard > User filters projects' do ...@@ -194,16 +182,11 @@ describe 'Dashboard > User filters projects' do
it 'sorts the project list' do it 'sorts the project list' do
select_dropdown_option '#filtered-search-sorting-dropdown', 'Name' select_dropdown_option '#filtered-search-sorting-dropdown', 'Name'
desc = ['Victorialand', 'Treasure', 'Red ribbon army', 'Frieza saga', 'Cell saga'] expect_to_see_projects(desc_sorted_project_names)
asc = ['Cell saga', 'Frieza saga', 'Red ribbon army', 'Treasure', 'Victorialand']
click_sort_direction
expect_to_see_projects(desc)
click_sort_direction click_sort_direction
expect_to_see_projects(asc) expect_to_see_projects(desc_sorted_project_names.reverse)
end end
end end
...@@ -211,16 +194,11 @@ describe 'Dashboard > User filters projects' do ...@@ -211,16 +194,11 @@ describe 'Dashboard > User filters projects' do
it 'sorts the project list' do it 'sorts the project list' do
select_dropdown_option '#filtered-search-sorting-dropdown', 'Last updated' select_dropdown_option '#filtered-search-sorting-dropdown', 'Last updated'
desc = ["Frieza saga", "Red ribbon army", "Victorialand", "Treasure", "Cell saga"] expect_to_see_projects(desc_sorted_project_names)
asc = ["Cell saga", "Treasure", "Victorialand", "Red ribbon army", "Frieza saga"]
click_sort_direction click_sort_direction
expect_to_see_projects(desc) expect_to_see_projects(desc_sorted_project_names.reverse)
click_sort_direction
expect_to_see_projects(asc)
end end
end end
...@@ -228,16 +206,11 @@ describe 'Dashboard > User filters projects' do ...@@ -228,16 +206,11 @@ describe 'Dashboard > User filters projects' do
it 'sorts the project list' do it 'sorts the project list' do
select_dropdown_option '#filtered-search-sorting-dropdown', 'Created date' select_dropdown_option '#filtered-search-sorting-dropdown', 'Created date'
desc = ["Frieza saga", "Red ribbon army", "Victorialand", "Treasure", "Cell saga"] expect_to_see_projects(desc_sorted_project_names)
asc = ["Cell saga", "Treasure", "Victorialand", "Red ribbon army", "Frieza saga"]
click_sort_direction
expect_to_see_projects(desc)
click_sort_direction click_sort_direction
expect_to_see_projects(asc) expect_to_see_projects(desc_sorted_project_names.reverse)
end end
end end
...@@ -245,16 +218,11 @@ describe 'Dashboard > User filters projects' do ...@@ -245,16 +218,11 @@ describe 'Dashboard > User filters projects' do
it 'sorts the project list' do it 'sorts the project list' do
select_dropdown_option '#filtered-search-sorting-dropdown', 'Stars' select_dropdown_option '#filtered-search-sorting-dropdown', 'Stars'
desc = ["Red ribbon army", "Cell saga", "Frieza saga", "Victorialand", "Treasure"] expect_to_see_projects(desc_sorted_project_names)
asc = ["Treasure", "Victorialand", "Red ribbon army", "Cell saga", "Frieza saga"]
click_sort_direction
expect_to_see_projects(desc)
click_sort_direction click_sort_direction
expect_to_see_projects(asc) expect_to_see_projects(desc_sorted_project_names.reverse)
end end
end end
end end
......
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