blob: 13ae035e8ef645a641204143b6aa5d0f562f39ba (
plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User uses shortcuts', :js do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
project.add_maintainer(user)
sign_in(user)
visit(project_path(project))
wait_for_requests
end
context 'disabling shortcuts' do
before do
page.evaluate_script("localStorage.removeItem('shortcutsDisabled')")
end
it 'can disable shortcuts from help menu' do
open_modal_shortcut_keys
click_toggle_button
close_modal
open_modal_shortcut_keys
expect(page).not_to have_selector('[data-testid="modal-shortcuts"]')
page.refresh
open_modal_shortcut_keys
# after reload, shortcuts modal doesn't exist at all until we add it
expect(page).not_to have_selector('[data-testid="modal-shortcuts"]')
end
it 're-enables shortcuts' do
open_modal_shortcut_keys
click_toggle_button
close_modal
open_modal_from_help_menu
click_toggle_button
close_modal
open_modal_shortcut_keys
expect(find('[data-testid="modal-shortcuts"]')).to be_visible
end
def open_modal_shortcut_keys
find('body').native.send_key('?')
end
def open_modal_from_help_menu
find('.header-help-dropdown-toggle').click
find('button', text: 'Keyboard shortcuts').click
end
def click_toggle_button
find('.js-toggle-shortcuts .gl-toggle').click
end
def close_modal
find('.modal button[aria-label="Close"]').click
end
end
context 'when navigating to the Project pages' do
it 'redirects to the details page' do
visit project_issues_path(project)
find('body').native.send_key('g')
find('body').native.send_key('p')
expect(page).to have_active_navigation('Project')
expect(page).to have_active_sub_navigation('Details')
end
it 'redirects to the activity page' do
find('body').native.send_key('g')
find('body').native.send_key('v')
expect(page).to have_active_navigation('Project')
expect(page).to have_active_sub_navigation('Activity')
end
end
context 'when navigating to the Repository pages' do
it 'redirects to the repository files page' do
find('body').native.send_key('g')
find('body').native.send_key('f')
expect(page).to have_active_navigation('Repository')
expect(page).to have_active_sub_navigation('Files')
end
it 'redirects to the repository commits page' do
find('body').native.send_key('g')
find('body').native.send_key('c')
expect(page).to have_active_navigation('Repository')
expect(page).to have_active_sub_navigation('Commits')
end
it 'redirects to the repository graph page' do
find('body').native.send_key('g')
find('body').native.send_key('n')
expect(page).to have_active_navigation('Repository')
expect(page).to have_active_sub_navigation('Graph')
end
it 'redirects to the repository charts page' do
find('body').native.send_key('g')
find('body').native.send_key('d')
expect(page).to have_active_navigation(_('Analytics'))
expect(page).to have_active_sub_navigation(_('Repository'))
end
end
context 'when navigating to the Issues pages' do
it 'redirects to the issues list page' do
find('body').native.send_key('g')
find('body').native.send_key('i')
expect(page).to have_active_navigation('Issues')
expect(page).to have_active_sub_navigation('List')
end
it 'redirects to the issue board page' do
find('body').native.send_key('g')
find('body').native.send_key('b')
expect(page).to have_active_navigation('Issues')
expect(page).to have_active_sub_navigation('Board')
end
it 'redirects to the new issue page' do
find('body').native.send_key('i')
expect(page).to have_content(project.title)
expect(page).to have_content('New Issue')
end
end
context 'when navigating to the Merge Requests pages' do
it 'redirects to the merge requests page' do
find('body').native.send_key('g')
find('body').native.send_key('m')
expect(page).to have_active_navigation('Merge Requests')
end
end
context 'when navigating to the CI / CD pages' do
it 'redirects to the Jobs page' do
find('body').native.send_key('g')
find('body').native.send_key('j')
expect(page).to have_active_navigation('CI / CD')
expect(page).to have_active_sub_navigation('Jobs')
end
end
context 'when navigating to the Operations pages' do
it 'redirects to the Metrics page' do
find('body').native.send_key('g')
find('body').native.send_key('l')
expect(page).to have_active_navigation('Operations')
expect(page).to have_active_sub_navigation('Metrics')
end
it 'redirects to the Environments page' do
find('body').native.send_key('g')
find('body').native.send_key('e')
expect(page).to have_active_navigation('Operations')
expect(page).to have_active_sub_navigation('Environments')
end
it 'redirects to the Kubernetes page' do
find('body').native.send_key('g')
find('body').native.send_key('k')
expect(page).to have_active_navigation('Operations')
expect(page).to have_active_sub_navigation('Kubernetes')
end
end
context 'when navigating to the Snippets pages' do
it 'redirects to the snippets page' do
find('body').native.send_key('g')
find('body').native.send_key('s')
expect(page).to have_active_navigation('Snippets')
end
end
context 'when navigating to the Wiki pages' do
it 'redirects to the wiki page' do
find('body').native.send_key('g')
find('body').native.send_key('w')
expect(page).to have_active_navigation('Wiki')
end
end
end
|