diff options
author | Vitaliy @blackst0ne Klachkov <blackst0ne.ru@gmail.com> | 2017-09-22 14:29:19 +1100 |
---|---|---|
committer | Vitaliy @blackst0ne Klachkov <blackst0ne.ru@gmail.com> | 2017-09-22 14:29:19 +1100 |
commit | 0ed3d8a07b997651df5f2b18b11bb1e0cb1c74de (patch) | |
tree | 26944f4126c74644dc4f1aa772bc5745b0d1b94f /spec | |
parent | 92173ac55cd921a65ce137e238ed8bc4474aaccb (diff) | |
download | gitlab-ce-0ed3d8a07b997651df5f2b18b11bb1e0cb1c74de.tar.gz |
Replace the 'project/shortcuts.feature' spinach test with an rspec analogreplace_project_shortcuts.feature
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/projects/shortcuts_spec.rb | 21 | ||||
-rw-r--r-- | spec/features/projects/user_uses_shortcuts_spec.rb | 108 | ||||
-rw-r--r-- | spec/support/matchers/navigation_matcher.rb | 6 |
3 files changed, 114 insertions, 21 deletions
diff --git a/spec/features/projects/shortcuts_spec.rb b/spec/features/projects/shortcuts_spec.rb deleted file mode 100644 index bf18c444c3d..00000000000 --- a/spec/features/projects/shortcuts_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -feature 'Project shortcuts' do - let(:project) { create(:project, name: 'Victorialand') } - let(:user) { create(:user) } - - describe 'On a project', js: true do - before do - project.team << [user, :master] - sign_in user - visit project_path(project) - end - - describe 'pressing "i"' do - it 'redirects to new issue page' do - find('body').native.send_key('i') - expect(page).to have_content('Victorialand') - end - end - end -end diff --git a/spec/features/projects/user_uses_shortcuts_spec.rb b/spec/features/projects/user_uses_shortcuts_spec.rb new file mode 100644 index 00000000000..fb0d8c766fe --- /dev/null +++ b/spec/features/projects/user_uses_shortcuts_spec.rb @@ -0,0 +1,108 @@ +require 'spec_helper' + +describe 'User uses shortcuts', :js do + let(:project) { create(:project, :repository) } + let(:user) { create(:user) } + + before do + project.add_master(user) + sign_in(user) + + visit(project_path(project)) + end + + context 'when navigating to the Overview pages' do + it 'redirects to the details page' do + find('body').native.send_key('g') + find('body').native.send_key('p') + + expect(page).to have_active_navigation('Overview') + 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('e') + + expect(page).to have_active_navigation('Overview') + 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('Repository') + expect(page).to have_active_sub_navigation('Charts') + 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 new issue page' do + find('body').native.send_key('i') + + expect(page).to have_content(project.title) + 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 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 diff --git a/spec/support/matchers/navigation_matcher.rb b/spec/support/matchers/navigation_matcher.rb index 5b6d9c1a4df..63f59b9654c 100644 --- a/spec/support/matchers/navigation_matcher.rb +++ b/spec/support/matchers/navigation_matcher.rb @@ -4,3 +4,9 @@ RSpec::Matchers.define :have_active_navigation do |expected| expect(page.find('.sidebar-top-level-items > li.active')).to have_content(expected) end end + +RSpec::Matchers.define :have_active_sub_navigation do |expected| + match do |page| + expect(page.find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)')).to have_content(expected) + end +end |