Commit 9647d2e7 authored by Tim Zallmann's avatar Tim Zallmann

Enhancing Spec's with negative cases

parent bf601f07
@explore
Feature: New Menu
Background:
Given I sign in as "John Doe"
And "John Doe" is owner of group "Owned"
And I own project "Shop"
And I visit dashboard page
@javascript
Scenario: I should see New Projects page
When I visit dashboard page
And I click "New project" in top right menu
Then I see "New Project" page
@javascript
Scenario: I should see New Group page
When I visit dashboard page
And I click "New group" in top right menu
Then I see "New Group" page
@javascript
Scenario: I should see New Snippet page
When I visit dashboard page
And I click "New snippet" in top right menu
Then I see "New Snippet" page
@javascript
Scenario: I should see New Issue page
When I visit project "Shop" page
And I click "New issue" in top right menu
Then I see "New Issue" page
@javascript
Scenario: I should see New Merge Request page
When I visit project "Shop" page
And I click "New merge request" in top right menu
Then I see "New Merge Request" page
@javascript
Scenario: I should see New Project Snippet page
When I visit project "Shop" page
And I click "New project snippet" in top right menu
Then I see "New Snippet" page
@javascript
Scenario: I should see New Group Project page
When I visit group "Owned" page
And I click "New group project" in top right menu
Then I see "New Project" page
@javascript
Scenario: I should see New Subgroup page
When I visit group "Owned" page
And I click "New subgroup" in top right menu
Then I see "New Group" page
class Spinach::Features::NewMenu < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
include SharedGroup
include SharedUser
step 'I click "New project" in top right menu' do
click_topmenuitem("New project")
end
step 'I click "New group" in top right menu' do
click_topmenuitem("New group")
end
step 'I click "New snippet" in top right menu' do
click_topmenuitem("New snippet")
end
step 'I click "New project snippet" in top right menu' do
page.within '.header-content' do
find('.header-new-dropdown-toggle').trigger('click')
expect(page).to have_selector('.header-new.dropdown.open', count: 1)
find('.header-new-project-snippet a').trigger('click')
end
end
step 'I click "New issue" in top right menu' do
click_topmenuitem("New issue")
end
step 'I click "New merge request" in top right menu' do
click_topmenuitem("New merge request")
end
step 'I click "New subgroup" in top right menu' do
click_topmenuitem("New subgroup")
end
step 'I click "New group project" in top right menu' do
page.within '.header-content' do
find('.header-new-dropdown-toggle').trigger('click')
expect(page).to have_selector('.header-new.dropdown.open', count: 1)
find('.header-new-group-project a').trigger('click')
end
end
step 'I see "New Project" page' do
expect(page).to have_content('Project path')
expect(page).to have_content('Project name')
end
step 'I see "New Group" page' do
expect(page).to have_content('Group path')
expect(page).to have_content('Group name')
end
step 'I see "New Snippet" page' do
expect(page).to have_content('New Snippet')
expect(page).to have_content('Title')
end
step 'I see "New Issue" page' do
expect(page).to have_content('New Issue')
expect(page).to have_content('Title')
end
step 'I see "New Merge Request" page' do
expect(page).to have_content('New Merge Request')
expect(page).to have_content('Source branch')
expect(page).to have_content('Target branch')
end
def click_topmenuitem(item_name)
page.within '.header-content' do
find('.header-new-dropdown-toggle').trigger('click')
expect(page).to have_selector('.header-new.dropdown.open', count: 1)
click_link item_name
end
end
end
require 'spec_helper' require 'spec_helper'
feature 'Top Plus Menu', feature: true, js: true do feature 'Top Plus Menu', feature: true, js: true do
let!(:user) { create :user } let(:user) { create :user }
let!(:group) { create(:group) } let(:guest_user) { create :user}
let!(:public_group) { create(:group, :public) } let(:group) { create(:group) }
let!(:private_group) { create(:group, :private) } let(:public_group) { create(:group, :public) }
let!(:empty_project) { create(:empty_project, group: public_group) } let(:project) { create(:project, :repository, creator: user, namespace: user.namespace) }
before do before do
group.add_owner(user) group.add_owner(user)
group.add_guest(guest_user)
login_as(user) project.add_guest(guest_user)
visit explore_groups_path
end end
context 'used by full user' do context 'used by full user' do
before do before do
login_as :user login_as(user)
end end
scenario 'click on New project shows new project page' do scenario 'click on New project shows new project page' do
...@@ -48,7 +47,7 @@ feature 'Top Plus Menu', feature: true, js: true do ...@@ -48,7 +47,7 @@ feature 'Top Plus Menu', feature: true, js: true do
end end
scenario 'click on New issue shows new issue page' do scenario 'click on New issue shows new issue page' do
visit namespace_project_path(empty_project.namespace, empty_project) visit namespace_project_path(project.namespace, project)
click_topmenuitem("New issue") click_topmenuitem("New issue")
...@@ -57,7 +56,7 @@ feature 'Top Plus Menu', feature: true, js: true do ...@@ -57,7 +56,7 @@ feature 'Top Plus Menu', feature: true, js: true do
end end
scenario 'click on New merge request shows new merge request page' do scenario 'click on New merge request shows new merge request page' do
visit namespace_project_path(empty_project.namespace, empty_project) visit namespace_project_path(project.namespace, project)
click_topmenuitem("New merge request") click_topmenuitem("New merge request")
...@@ -67,7 +66,7 @@ feature 'Top Plus Menu', feature: true, js: true do ...@@ -67,7 +66,7 @@ feature 'Top Plus Menu', feature: true, js: true do
end end
scenario 'click on New project snippet shows new snippet page' do scenario 'click on New project snippet shows new snippet page' do
visit namespace_project_path(empty_project.namespace, empty_project) visit namespace_project_path(project.namespace, project)
page.within '.header-content' do page.within '.header-content' do
find('.header-new-dropdown-toggle').trigger('click') find('.header-new-dropdown-toggle').trigger('click')
...@@ -102,6 +101,45 @@ feature 'Top Plus Menu', feature: true, js: true do ...@@ -102,6 +101,45 @@ feature 'Top Plus Menu', feature: true, js: true do
end end
end end
context 'used by guest user' do
before do
login_as(guest_user)
end
scenario 'click on New issue shows new issue page' do
visit namespace_project_path(project.namespace, project)
click_topmenuitem("New issue")
expect(page).to have_content('New Issue')
expect(page).to have_content('Title')
end
scenario 'has no New merge request menu item' do
visit namespace_project_path(project.namespace, project)
hasnot_topmenuitem("New merge request")
end
scenario 'has no New project snippet menu item' do
visit namespace_project_path(project.namespace, project)
expect(find('.header-new.dropdown')).not_to have_selector('.header-new-project-snippet')
end
scenario 'has no New subgroup menu item' do
visit group_path(group)
hasnot_topmenuitem("New subgroup")
end
scenario 'has no New project for group menu item' do
visit group_path(group)
expect(find('.header-new.dropdown')).not_to have_selector('.header-new-group-project')
end
end
def click_topmenuitem(item_name) def click_topmenuitem(item_name)
page.within '.header-content' do page.within '.header-content' do
find('.header-new-dropdown-toggle').trigger('click') find('.header-new-dropdown-toggle').trigger('click')
...@@ -109,4 +147,9 @@ feature 'Top Plus Menu', feature: true, js: true do ...@@ -109,4 +147,9 @@ feature 'Top Plus Menu', feature: true, js: true do
click_link item_name click_link item_name
end end
end end
def hasnot_topmenuitem(item_name)
expect(find('.header-new.dropdown')).not_to have_content(item_name)
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment