Merge branch 'replace_project_shortcuts.feature' into 'master'

Replace the 'project/shortcuts.feature' spinach test with an rspec analog

See merge request gitlab-org/gitlab-ce!14431
This commit is contained in:
Rémy Coutable 2017-09-22 11:14:55 +00:00
commit c01bd64f56
6 changed files with 119 additions and 126 deletions

View File

@ -0,0 +1,5 @@
---
title: Replace the 'project/shortcuts.feature' spinach test with an rspec analog
merge_request: 14431
author: Vitaliy @blackst0ne Klachkov
type: other

View File

@ -1,63 +0,0 @@
@dashboard
Feature: Project Shortcuts
Background:
Given I sign in as a user
And I own a project
And I visit my project's commits page
@javascript
Scenario: Navigate to files tab
Given I press "g" and "f"
Then the active main tab should be Repository
Then the active sub tab should be Files
@javascript
Scenario: Navigate to commits tab
Given I visit my project's files page
Given I press "g" and "c"
Then the active main tab should be Repository
Then the active sub tab should be Commits
@javascript
Scenario: Navigate to graph tab
Given I press "g" and "n"
Then the active sub tab should be Graph
And the active main tab should be Repository
@javascript
Scenario: Navigate to repository charts tab
Given I press "g" and "d"
Then the active sub tab should be Charts
And the active main tab should be Repository
@javascript
Scenario: Navigate to issues tab
Given I press "g" and "i"
Then the active main tab should be Issues
@javascript
Scenario: Navigate to merge requests tab
Given I press "g" and "m"
Then the active main tab should be Merge Requests
@javascript
Scenario: Navigate to snippets tab
Given I press "g" and "s"
Then the active main tab should be Snippets
@javascript
Scenario: Navigate to wiki tab
Given I press "g" and "w"
Then the active main tab should be Wiki
@javascript
Scenario: Navigate to project home
Given I press "g" and "p"
Then the active sub tab should be Home
And the active main tab should be Project
@javascript
Scenario: Navigate to project feed
Given I press "g" and "e"
Then the active sub tab should be Activity
And the active main tab should be Project

View File

@ -1,42 +0,0 @@
class Spinach::Features::ProjectShortcuts < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
include SharedProjectTab
include SharedShortcuts
step 'I press "g" and "f"' do
find('body').native.send_key('g')
find('body').native.send_key('f')
end
step 'I press "g" and "c"' do
find('body').native.send_key('g')
find('body').native.send_key('c')
end
step 'I press "g" and "n"' do
find('body').native.send_key('g')
find('body').native.send_key('n')
end
step 'I press "g" and "d"' do
find('body').native.send_key('g')
find('body').native.send_key('d')
end
step 'I press "g" and "s"' do
find('body').native.send_key('g')
find('body').native.send_key('s')
end
step 'I press "g" and "w"' do
find('body').native.send_key('g')
find('body').native.send_key('w')
end
step 'I press "g" and "e"' do
find('body').native.send_key('g')
find('body').native.send_key('e')
end
end

View File

@ -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

View File

@ -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

View File

@ -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