1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User sorts projects and order persists' do
include CookieHelper
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:group_member) { create(:group_member, :maintainer, user: user, group: group) }
let_it_be(:project) { create(:project, :public, group: group) }
shared_examples_for "sort order persists across all views" do |project_paths_label, group_paths_label|
it "is set on the dashboard_projects_path" do
visit(dashboard_projects_path)
expect(find('#sort-projects-dropdown')).to have_content(project_paths_label)
end
it "is set on the explore_projects_path" do
visit(explore_projects_path)
expect(find('#sort-projects-dropdown')).to have_content(project_paths_label)
end
it "is set on the group_canonical_path" do
visit(group_canonical_path(group))
within '[data-testid=group_sort_by_dropdown]' do
expect(find('.gl-dropdown-toggle')).to have_content(group_paths_label)
end
end
it "is set on the details_group_path" do
visit(details_group_path(group))
within '[data-testid=group_sort_by_dropdown]' do
expect(find('.gl-dropdown-toggle')).to have_content(group_paths_label)
end
end
end
context "from explore projects", :js do
before do
stub_feature_flags(gl_listbox_for_sort_dropdowns: false)
sign_in(user)
visit(explore_projects_path)
find('#sort-projects-dropdown').click
first(:link, 'Updated date').click
end
it_behaves_like "sort order persists across all views", 'Updated date', 'Updated'
end
context 'from dashboard projects', :js do
before do
stub_feature_flags(gl_listbox_for_sort_dropdowns: false)
sign_in(user)
visit(dashboard_projects_path)
find('#sort-projects-dropdown').click
first(:link, 'Name').click
end
it_behaves_like "sort order persists across all views", "Name", "Name"
end
context 'from group homepage', :js do
before do
sign_in(user)
visit(group_canonical_path(group))
within '[data-testid=group_sort_by_dropdown]' do
find('button.gl-dropdown-toggle').click
first(:button, 'Created').click
wait_for_requests
end
end
it_behaves_like "sort order persists across all views", "Created date", "Created"
end
context 'from group details', :js do
before do
sign_in(user)
visit(details_group_path(group))
within '[data-testid=group_sort_by_dropdown]' do
find('button.gl-dropdown-toggle').click
first(:button, 'Stars').click
wait_for_requests
end
end
it_behaves_like "sort order persists across all views", "Stars", "Stars"
end
end
|