2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'User uses shortcuts', :js do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2018-03-17 18:26:18 +05:30
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(project_path(project))
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
wait_for_requests
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
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-03-11 19:13:27 +05:30
|
|
|
expect(page).not_to have_selector('[data-testid="modal-shortcuts"]')
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
page.refresh
|
|
|
|
open_modal_shortcut_keys
|
|
|
|
|
|
|
|
# after reload, shortcuts modal doesn't exist at all until we add it
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(page).not_to have_selector('[data-testid="modal-shortcuts"]')
|
2020-03-13 15:44:24 +05:30
|
|
|
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-03-11 19:13:27 +05:30
|
|
|
expect(find('[data-testid="modal-shortcuts"]')).to be_visible
|
2020-03-13 15:44:24 +05:30
|
|
|
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-10-15 14:42:47 +05:30
|
|
|
context 'when navigating to the Project pages' do
|
2021-06-08 01:23:25 +05:30
|
|
|
it 'redirects to the project page' do
|
2018-11-08 19:23:39 +05:30
|
|
|
visit project_issues_path(project)
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
find('body').native.send_key('g')
|
|
|
|
find('body').native.send_key('p')
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(page).to have_active_navigation('Project')
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'when feature flag :sidebar_refactor is disabled' do
|
|
|
|
it 'redirects to the details page' do
|
|
|
|
stub_feature_flags(sidebar_refactor: false)
|
|
|
|
|
|
|
|
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
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to the activity page' do
|
|
|
|
find('body').native.send_key('g')
|
2018-11-08 19:23:39 +05:30
|
|
|
find('body').native.send_key('v')
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(page).to have_active_navigation('Project')
|
2018-03-17 18:26:18 +05:30
|
|
|
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-04-08 14:13:33 +05:30
|
|
|
expect(page).to have_active_navigation(_('Analytics'))
|
|
|
|
expect(page).to have_active_sub_navigation(_('Repository'))
|
2018-03-17 18:26:18 +05:30
|
|
|
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-11-08 19:23:39 +05:30
|
|
|
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
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'redirects to the new issue page' do
|
|
|
|
find('body').native.send_key('i')
|
|
|
|
|
|
|
|
expect(page).to have_content(project.title)
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(page).to have_content('New Issue')
|
2018-03-17 18:26:18 +05:30
|
|
|
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-29 21:17:54 +05:30
|
|
|
expect(page).to have_active_navigation('Merge requests')
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
context 'when navigating to the CI/CD pages' do
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'redirects to the Jobs page' do
|
|
|
|
find('body').native.send_key('g')
|
|
|
|
find('body').native.send_key('j')
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(page).to have_active_navigation('CI/CD')
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(page).to have_active_sub_navigation('Jobs')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
context 'when navigating to the Deployments page' do
|
|
|
|
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('Deployments')
|
|
|
|
expect(page).to have_active_sub_navigation('Environments')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when navigating to the Monitor pages' do
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'redirects to the Metrics page' do
|
|
|
|
find('body').native.send_key('g')
|
|
|
|
find('body').native.send_key('l')
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
expect(page).to have_active_navigation('Monitor')
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(page).to have_active_sub_navigation('Metrics')
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
context 'when feature flag :sidebar_refactor is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(sidebar_refactor: false)
|
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it 'redirects to the Operations 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 Kubernetes page with active Operations' 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
|
|
|
|
|
|
|
|
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
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
context 'when navigating to the Infrastructure pages' do
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'redirects to the Kubernetes page' do
|
|
|
|
find('body').native.send_key('g')
|
|
|
|
find('body').native.send_key('k')
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
expect(page).to have_active_navigation('Infrastructure')
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(page).to have_active_sub_navigation('Kubernetes')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
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
|