2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-21 23:29:19 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe 'User uses shortcuts', :js do
|
2021-05-26 08:10:41 -04:00
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
|
|
|
|
|
|
|
let(:user) { project.owner }
|
2017-09-21 23:29:19 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(project_path(project))
|
2018-07-31 16:22:34 -04:00
|
|
|
|
|
|
|
wait_for_requests
|
2017-09-21 23:29:19 -04:00
|
|
|
end
|
|
|
|
|
2020-02-17 04:08:52 -05:00
|
|
|
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
|
|
|
|
|
2021-02-11 10:09:11 -05:00
|
|
|
expect(page).not_to have_selector('[data-testid="modal-shortcuts"]')
|
2020-02-17 04:08:52 -05:00
|
|
|
|
|
|
|
page.refresh
|
|
|
|
open_modal_shortcut_keys
|
|
|
|
|
|
|
|
# after reload, shortcuts modal doesn't exist at all until we add it
|
2021-02-11 10:09:11 -05:00
|
|
|
expect(page).not_to have_selector('[data-testid="modal-shortcuts"]')
|
2020-02-17 04:08:52 -05:00
|
|
|
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
|
2021-02-11 10:09:11 -05:00
|
|
|
expect(find('[data-testid="modal-shortcuts"]')).to be_visible
|
2020-02-17 04:08:52 -05:00
|
|
|
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
|
|
|
|
|
2018-04-12 13:49:05 -04:00
|
|
|
context 'when navigating to the Project pages' do
|
2021-05-07 14:10:21 -04:00
|
|
|
it 'redirects to the project page' do
|
2018-05-17 22:18:42 -04:00
|
|
|
visit project_issues_path(project)
|
|
|
|
|
2017-09-21 23:29:19 -04:00
|
|
|
find('body').native.send_key('g')
|
|
|
|
find('body').native.send_key('p')
|
|
|
|
|
2021-05-26 08:10:41 -04:00
|
|
|
expect(page).to have_active_navigation(project.name)
|
2021-05-07 14:10:21 -04:00
|
|
|
end
|
|
|
|
|
2017-09-21 23:29:19 -04:00
|
|
|
it 'redirects to the activity page' do
|
|
|
|
find('body').native.send_key('g')
|
2018-05-17 22:18:42 -04:00
|
|
|
find('body').native.send_key('v')
|
2017-09-21 23:29:19 -04:00
|
|
|
|
2018-04-12 13:49:05 -04:00
|
|
|
expect(page).to have_active_navigation('Project')
|
2017-09-21 23:29:19 -04:00
|
|
|
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')
|
|
|
|
|
2020-03-12 14:09:28 -04:00
|
|
|
expect(page).to have_active_navigation(_('Analytics'))
|
|
|
|
expect(page).to have_active_sub_navigation(_('Repository'))
|
2017-09-21 23:29:19 -04:00
|
|
|
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
|
|
|
|
|
2018-05-17 22:18:42 -04:00
|
|
|
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
|
|
|
|
|
2017-09-21 23:29:19 -04:00
|
|
|
it 'redirects to the new issue page' do
|
|
|
|
find('body').native.send_key('i')
|
|
|
|
|
|
|
|
expect(page).to have_content(project.title)
|
2018-05-17 22:18:42 -04:00
|
|
|
expect(page).to have_content('New Issue')
|
2017-09-21 23:29:19 -04:00
|
|
|
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')
|
|
|
|
|
2021-04-01 05:09:05 -04:00
|
|
|
expect(page).to have_active_navigation('Merge requests')
|
2017-09-21 23:29:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-10 13:09:32 -05:00
|
|
|
context 'when navigating to the CI/CD pages' do
|
2018-05-17 22:18:42 -04:00
|
|
|
it 'redirects to the Jobs page' do
|
|
|
|
find('body').native.send_key('g')
|
|
|
|
find('body').native.send_key('j')
|
|
|
|
|
2021-03-10 13:09:32 -05:00
|
|
|
expect(page).to have_active_navigation('CI/CD')
|
2018-05-17 22:18:42 -04:00
|
|
|
expect(page).to have_active_sub_navigation('Jobs')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-14 14:10:34 -04:00
|
|
|
context 'when navigating to the Deployments page' do
|
|
|
|
it 'redirects to the Environments page' do
|
2018-06-26 05:36:16 -04:00
|
|
|
find('body').native.send_key('g')
|
2021-05-14 14:10:34 -04:00
|
|
|
find('body').native.send_key('e')
|
2018-06-26 05:36:16 -04:00
|
|
|
|
2021-05-14 14:10:34 -04:00
|
|
|
expect(page).to have_active_navigation('Deployments')
|
|
|
|
expect(page).to have_active_sub_navigation('Environments')
|
2018-06-26 05:36:16 -04:00
|
|
|
end
|
2021-05-14 14:10:34 -04:00
|
|
|
end
|
2018-06-26 05:36:16 -04:00
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
context 'when navigating to the Monitor pages' do
|
2021-05-14 14:10:34 -04:00
|
|
|
it 'redirects to the Metrics page' do
|
2018-05-17 22:18:42 -04:00
|
|
|
find('body').native.send_key('g')
|
2021-05-14 14:10:34 -04:00
|
|
|
find('body').native.send_key('l')
|
2018-05-17 22:18:42 -04:00
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
expect(page).to have_active_navigation('Monitor')
|
2021-05-14 14:10:34 -04:00
|
|
|
expect(page).to have_active_sub_navigation('Metrics')
|
2018-05-17 22:18:42 -04:00
|
|
|
end
|
2021-05-05 14:10:31 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when navigating to the Infrastructure pages' do
|
2018-05-17 22:18:42 -04:00
|
|
|
it 'redirects to the Kubernetes page' do
|
|
|
|
find('body').native.send_key('g')
|
|
|
|
find('body').native.send_key('k')
|
|
|
|
|
2021-05-05 14:10:31 -04:00
|
|
|
expect(page).to have_active_navigation('Infrastructure')
|
2018-05-17 22:18:42 -04:00
|
|
|
expect(page).to have_active_sub_navigation('Kubernetes')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-21 23:29:19 -04:00
|
|
|
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
|