Commit 8b3ba189 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'replace_explore_projects.feature' into 'master'

Replace the 'features/explore/projects.feature' spinach test with an rspec analog

See merge request gitlab-org/gitlab-ce!14755
parents 1621b456 bd69b794
---
title: Replace the 'features/explore/projects.feature' spinach test with an rspec analog
merge_request: 14755
author: Vitaliy @blackst0ne Klachkov
type: other
@public
Feature: Explore Projects
Background:
Given public project "Community"
And internal project "Internal"
And private project "Enterprise"
Scenario: I visit public area
Given archived project "Archive"
When I visit the public projects area
Then I should see project "Community"
And I should not see project "Internal"
And I should not see project "Enterprise"
And I should not see project "Archive"
Scenario: I visit public project page
When I visit project "Community" page
Then I should see project "Community" home page
Scenario: I visit internal project page
When I visit project "Internal" page
Then I should be redirected to sign in page
Scenario: I visit private project page
When I visit project "Enterprise" page
Then I should be redirected to sign in page
Scenario: I visit an empty public project page
Given public empty project "Empty Public Project"
When I visit empty project page
Then I should see empty public project details
And I should see empty public project details with http clone info
Scenario: I visit an empty public project page as user with no ssh-keys
Given I sign in as a user
And I have no ssh keys
And public empty project "Empty Public Project"
When I visit empty project page
Then I should see empty public project details
And I should see empty public project details with http clone info
Scenario: I visit an empty public project page as user with an ssh-key
Given I sign in as a user
And I have an ssh key
And public empty project "Empty Public Project"
When I visit empty project page
Then I should see empty public project details
And I should see empty public project details with ssh clone info
Scenario: I visit public area as user
Given archived project "Archive"
And I sign in as a user
When I visit the public projects area
Then I should see project "Community"
And I should see project "Internal"
And I should not see project "Enterprise"
And I should not see project "Archive"
Scenario: I visit internal project page as user
Given I sign in as a user
When I visit project "Internal" page
Then I should see project "Internal" home page
Scenario: I visit public project page
When I visit project "Community" page
Then I should see project "Community" home page
And I should see an http link to the repository
Scenario: I visit public project page as user with no ssh-keys
Given I sign in as a user
And I have no ssh keys
When I visit project "Community" page
Then I should see project "Community" home page
And I should see an http link to the repository
Scenario: I visit public project page as user with an ssh-key
Given I sign in as a user
And I have an ssh key
When I visit project "Community" page
Then I should see project "Community" home page
And I should see an ssh link to the repository
Scenario: I visit an empty public project page
Given public empty project "Empty Public Project"
When I visit empty project page
Then I should see empty public project details
Scenario: I visit public project issues page as a non authorized user
Given I visit project "Community" page
Then I should not see command line instructions
And I visit "Community" issues page
Then I should see list of issues for "Community" project
Scenario: I visit public project issues page as authorized user
Given I sign in as a user
Given I visit project "Community" page
And I visit "Community" issues page
Then I should see list of issues for "Community" project
Scenario: I visit internal project issues page as authorized user
Given I sign in as a user
Given I visit project "Internal" page
And I visit "Internal" issues page
Then I should see list of issues for "Internal" project
Scenario: I visit public project merge requests page as an authorized user
Given I sign in as a user
Given I visit project "Community" page
And I visit "Community" merge requests page
And project "Community" has "Bug fix" open merge request
Then I should see list of merge requests for "Community" project
Scenario: I visit public project merge requests page as a non authorized user
Given I visit project "Community" page
And I visit "Community" merge requests page
And project "Community" has "Bug fix" open merge request
Then I should see list of merge requests for "Community" project
Scenario: I visit internal project merge requests page as an authorized user
Given I sign in as a user
Given I visit project "Internal" page
And I visit "Internal" merge requests page
And project "Internal" has "Feature implemented" open merge request
Then I should see list of merge requests for "Internal" project
Scenario: Trending page
Given archived project "Archive"
And project "Archive" has comments
And I sign in as a user
And project "Community" has comments
And trending projects are refreshed
When I visit the explore trending projects
Then I should see project "Community"
And I should not see project "Internal"
And I should not see project "Enterprise"
And I should not see project "Archive"
Scenario: Most starred page
Given archived project "Archive"
And I sign in as a user
When I visit the explore starred projects
Then I should see project "Community"
And I should see project "Internal"
And I should not see project "Archive"
class Spinach::Features::ExploreProjects < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
include SharedUser
step 'I should see project "Empty Public Project"' do
expect(page).to have_content "Empty Public Project"
end
step 'I should see public project details' do
expect(page).to have_content '32 branches'
expect(page).to have_content '16 tags'
end
step 'I should see project readme' do
expect(page).to have_content 'README.md'
end
step 'I should see empty public project details' do
expect(page).not_to have_content 'Git global setup'
end
step 'I should see empty public project details with http clone info' do
project = Project.find_by(name: 'Empty Public Project')
page.all(:css, '.git-empty .clone').each do |element|
expect(element.text).to include(project.http_url_to_repo)
end
end
step 'I should see empty public project details with ssh clone info' do
project = Project.find_by(name: 'Empty Public Project')
page.all(:css, '.git-empty .clone').each do |element|
expect(element.text).to include(project.url_to_repo)
end
end
step 'I should see project "Community" home page' do
page.within '.breadcrumbs .breadcrumb-item-text' do
expect(page).to have_content 'Community'
end
end
step 'I should see project "Internal" home page' do
page.within '.breadcrumbs .breadcrumb-item-text' do
expect(page).to have_content 'Internal'
end
end
step 'I should see an http link to the repository' do
project = Project.find_by(name: 'Community')
expect(page).to have_field('project_clone', with: project.http_url_to_repo)
end
step 'I should see an ssh link to the repository' do
project = Project.find_by(name: 'Community')
expect(page).to have_field('project_clone', with: project.url_to_repo)
end
step 'I visit "Community" issues page' do
create(:issue,
title: "Bug",
project: public_project
)
create(:issue,
title: "New feature",
project: public_project
)
visit project_issues_path(public_project)
end
step 'I should see list of issues for "Community" project' do
expect(page).to have_content "Bug"
expect(page).to have_content public_project.name
expect(page).to have_content "New feature"
end
step 'I visit "Internal" issues page' do
create(:issue,
title: "Internal Bug",
project: internal_project
)
create(:issue,
title: "New internal feature",
project: internal_project
)
visit project_issues_path(internal_project)
end
step 'I should see list of issues for "Internal" project' do
expect(page).to have_content "Internal Bug"
expect(page).to have_content internal_project.name
expect(page).to have_content "New internal feature"
end
step 'I visit "Community" merge requests page' do
visit project_merge_requests_path(public_project)
end
step 'project "Community" has "Bug fix" open merge request' do
create(:merge_request,
title: "Bug fix for public project",
source_project: public_project,
target_project: public_project
)
end
step 'I should see list of merge requests for "Community" project' do
expect(page).to have_content public_project.name
expect(page).to have_content public_merge_request.source_project.name
end
step 'I visit "Internal" merge requests page' do
visit project_merge_requests_path(internal_project)
end
step 'project "Internal" has "Feature implemented" open merge request' do
create(:merge_request,
title: "Feature implemented",
source_project: internal_project,
target_project: internal_project
)
end
step 'I should see list of merge requests for "Internal" project' do
expect(page).to have_content internal_project.name
expect(page).to have_content internal_merge_request.source_project.name
end
def internal_project
@internal_project ||= Project.find_by!(name: 'Internal')
end
def public_project
@public_project ||= Project.find_by!(name: 'Community')
end
def internal_merge_request
@internal_merge_request ||= MergeRequest.find_by!(title: 'Feature implemented')
end
def public_merge_request
@public_merge_request ||= MergeRequest.find_by!(title: 'Bug fix for public project')
end
end
......@@ -454,19 +454,6 @@ module SharedPaths
# ----------------------------------------
# Public Projects
# ----------------------------------------
step 'I visit the public projects area' do
visit explore_projects_path
end
step 'I visit the explore trending projects' do
visit trending_explore_projects_path
end
step 'I visit the explore starred projects' do
visit starred_explore_projects_path
end
step 'I visit the public groups area' do
visit explore_groups_path
end
......
......@@ -112,10 +112,6 @@ module SharedProject
# Visibility of archived project
# ----------------------------------------
step 'archived project "Archive"' do
create(:project, :archived, :public, :repository, name: 'Archive')
end
step 'I should not see project "Archive"' do
project = Project.find_by(name: "Archive")
expect(page).not_to have_content project.name_with_namespace
......@@ -126,11 +122,6 @@ module SharedProject
expect(page).to have_content project.name_with_namespace
end
step 'project "Archive" has comments' do
project = Project.find_by(name: "Archive")
2.times { create(:note_on_issue, project: project) }
end
# ----------------------------------------
# Visibility level
# ----------------------------------------
......@@ -209,15 +200,6 @@ module SharedProject
create :project_empty_repo, :public, name: "Empty Public Project"
end
step 'project "Community" has comments' do
project = Project.find_by(name: "Community")
2.times { create(:note_on_issue, project: project) }
end
step 'trending projects are refreshed' do
TrendingProject.refresh!
end
step 'project "Shop" has labels: "bug", "feature", "enhancement"' do
project = Project.find_by(name: "Shop")
create(:label, project: project, title: 'bug')
......
require 'spec_helper'
describe 'User explores projects' do
set(:archived_project) { create(:project, :archived) }
set(:internal_project) { create(:project, :internal) }
set(:private_project) { create(:project, :private) }
set(:public_project) { create(:project, :public) }
shared_examples_for 'shows public projects' do
it 'shows projects' do
expect(page).to have_content(public_project.title)
expect(page).not_to have_content(internal_project.title)
expect(page).not_to have_content(private_project.title)
expect(page).not_to have_content(archived_project.title)
end
end
shared_examples_for 'shows public and internal projects' do
it 'shows projects' do
expect(page).to have_content(public_project.title)
expect(page).to have_content(internal_project.title)
expect(page).not_to have_content(private_project.title)
expect(page).not_to have_content(archived_project.title)
end
end
context 'when not signed in' do
context 'when viewing public projects' do
before do
visit(explore_projects_path)
end
include_examples 'shows public projects'
end
end
context 'when signed in' do
set(:user) { create(:user) }
before do
sign_in(user)
end
context 'when viewing public projects' do
before do
visit(explore_projects_path)
end
include_examples 'shows public and internal projects'
end
context 'when viewing most starred projects' do
before do
visit(starred_explore_projects_path)
end
include_examples 'shows public and internal projects'
end
context 'when viewing trending projects' do
before do
[archived_project, public_project].each { |project| create(:note_on_issue, project: project) }
TrendingProject.refresh!
visit(trending_explore_projects_path)
end
include_examples 'shows public projects'
end
end
end
require 'spec_helper'
feature 'Issues List' do
let(:user) { create(:user) }
let(:project) { create(:project) }
background do
project.team << [user, :developer]
sign_in(user)
end
scenario 'user does not see create new list button' do
create(:issue, project: project)
visit project_issues_path(project)
expect(page).not_to have_selector('.js-new-board-list')
end
end
require 'spec_helper'
describe 'User views issues' do
set(:user) { create(:user) }
shared_examples_for 'shows issues' do
it 'shows issues' do
expect(page).to have_content(project.name)
.and have_content(issue1.title)
.and have_content(issue2.title)
.and have_no_selector('.js-new-board-list')
end
end
context 'when project is public' do
set(:project) { create(:project_empty_repo, :public) }
set(:issue1) { create(:issue, project: project) }
set(:issue2) { create(:issue, project: project) }
context 'when signed in' do
before do
project.add_developer(user)
sign_in(user)
visit(project_issues_path(project))
end
include_examples 'shows issues'
end
context 'when not signed in' do
before do
visit(project_issues_path(project))
end
include_examples 'shows issues'
end
end
context 'when project is internal' do
set(:project) { create(:project_empty_repo, :internal) }
set(:issue1) { create(:issue, project: project) }
set(:issue2) { create(:issue, project: project) }
context 'when signed in' do
before do
project.add_developer(user)
sign_in(user)
visit(project_issues_path(project))
end
include_examples 'shows issues'
end
end
end
require 'spec_helper'
describe 'User views open merge requests' do
let(:project) { create(:project, :public, :repository) }
set(:user) { create(:user) }
context "when the target branch is the project's default branch" do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:closed_merge_request) { create(:closed_merge_request, source_project: project, target_project: project) }
before do
visit(project_merge_requests_path(project))
shared_examples_for 'shows merge requests' do
it 'shows merge requests' do
expect(page).to have_content(project.name).and have_content(merge_request.source_project.name)
end
end
it 'shows open merge requests' do
expect(page).to have_content(merge_request.title).and have_no_content(closed_merge_request.title)
end
context 'when project is public' do
set(:project) { create(:project, :public, :repository) }
it 'does not show target branch name' do
expect(page).to have_content(merge_request.title)
expect(find('.issuable-info')).not_to have_content(project.default_branch)
end
end
context 'when not signed in' do
context "when the target branch is the project's default branch" do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:closed_merge_request) { create(:closed_merge_request, source_project: project, target_project: project) }
context "when the target branch is different from the project's default branch" do
let!(:merge_request) do
create(:merge_request,
source_project: project,
target_project: project,
source_branch: 'fix',
target_branch: 'feature_conflict')
end
before do
visit(project_merge_requests_path(project))
end
before do
visit(project_merge_requests_path(project))
end
include_examples 'shows merge requests'
it 'shows target branch name' do
expect(page).to have_content(merge_request.target_branch)
end
end
it 'shows open merge requests' do
expect(page).to have_content(merge_request.title).and have_no_content(closed_merge_request.title)
end
context 'when a merge request has pipelines' do
let!(:build) { create :ci_build, pipeline: pipeline }
it 'does not show target branch name' do
expect(page).to have_content(merge_request.title)
expect(find('.issuable-info')).not_to have_content(project.default_branch)
end
end
let(:merge_request) do
create(:merge_request_with_diffs,
source_project: project,
target_project: project,
source_branch: 'merge-test')
end
context "when the target branch is different from the project's default branch" do
let!(:merge_request) do
create(:merge_request,
source_project: project,
target_project: project,
source_branch: 'fix',
target_branch: 'feature_conflict')
end
before do
visit(project_merge_requests_path(project))
end
it 'shows target branch name' do
expect(page).to have_content(merge_request.target_branch)
end
end
let(:pipeline) do
create(:ci_pipeline,
project: project,
sha: merge_request.diff_head_sha,
ref: merge_request.source_branch,
head_pipeline_of: merge_request)
context 'when a merge request has pipelines' do
let!(:build) { create :ci_build, pipeline: pipeline }
let(:merge_request) do
create(:merge_request_with_diffs,
source_project: project,
target_project: project,
source_branch: 'merge-test')
end
let(:pipeline) do
create(:ci_pipeline,
project: project,
sha: merge_request.diff_head_sha,
ref: merge_request.source_branch,
head_pipeline_of: merge_request)
end
before do
project.enable_ci
visit(project_merge_requests_path(project))
end
it 'shows pipeline status' do
page.within('.mr-list') do
expect(page).to have_link('Pipeline: pending')
end
end
end