Replace commits spinach tests with RSpec analog
https://gitlab.com/gitlab-org/gitlab-ce/issues/23036
This commit is contained in:
parent
31fa96960f
commit
d0c854bd2e
|
@ -1,96 +0,0 @@
|
|||
@project_commits
|
||||
Feature: Project Commits
|
||||
Background:
|
||||
Given I sign in as a user
|
||||
And I own a project
|
||||
And I visit my project's commits page
|
||||
|
||||
Scenario: I browse commits list for master branch
|
||||
Then I see project commits
|
||||
And I should not see button to create a new merge request
|
||||
Then I click the "Compare" tab
|
||||
And I should not see button to create a new merge request
|
||||
|
||||
Scenario: I browse commits list for feature branch without a merge request
|
||||
Given I visit commits list page for feature branch
|
||||
Then I see feature branch commits
|
||||
And I see button to create a new merge request
|
||||
Then I click the "Compare" tab
|
||||
And I see button to create a new merge request
|
||||
|
||||
Scenario: I browse commits list for feature branch with an open merge request
|
||||
Given project have an open merge request
|
||||
And I visit commits list page for feature branch
|
||||
Then I see feature branch commits
|
||||
And I should not see button to create a new merge request
|
||||
And I should see button to the merge request
|
||||
Then I click the "Compare" tab
|
||||
And I should not see button to create a new merge request
|
||||
And I should see button to the merge request
|
||||
|
||||
Scenario: I browse atom feed of commits list for master branch
|
||||
Given I click atom feed link
|
||||
Then I see commits atom feed
|
||||
|
||||
Scenario: I browse commit from list
|
||||
Given I click on commit link
|
||||
Then I see commit info
|
||||
And I see side-by-side diff button
|
||||
|
||||
Scenario: I browse commit from list and create a new tag
|
||||
Given I click on commit link
|
||||
And I click on tag link
|
||||
Then I see commit SHA pre-filled
|
||||
|
||||
Scenario: I browse commit with ci from list
|
||||
Given commit has ci status
|
||||
And repository contains ".gitlab-ci.yml" file
|
||||
When I click on commit link
|
||||
Then I see commit ci info
|
||||
|
||||
Scenario: I browse commit with side-by-side diff view
|
||||
Given I click on commit link
|
||||
And I click side-by-side diff button
|
||||
Then I see inline diff button
|
||||
|
||||
@javascript
|
||||
Scenario: I compare branches without a merge request
|
||||
Given I visit compare refs page
|
||||
And I fill compare fields with branches
|
||||
Then I see compared branches
|
||||
And I see button to create a new merge request
|
||||
|
||||
@javascript
|
||||
Scenario: I compare branches with an open merge request
|
||||
Given project have an open merge request
|
||||
And I visit compare refs page
|
||||
And I fill compare fields with branches
|
||||
Then I see compared branches
|
||||
And I should not see button to create a new merge request
|
||||
And I should see button to the merge request
|
||||
|
||||
@javascript
|
||||
Scenario: I compare refs
|
||||
Given I visit compare refs page
|
||||
And I fill compare fields with refs
|
||||
Then I see compared refs
|
||||
And I unfold diff
|
||||
Then I should see additional file lines
|
||||
|
||||
Scenario: I browse commits for a specific path
|
||||
Given I visit my project's commits page for a specific path
|
||||
Then I see breadcrumb links
|
||||
|
||||
# TODO: Implement feature in graphs
|
||||
#Scenario: I browse commits stats
|
||||
#Given I visit my project's commits stats page
|
||||
#Then I see commits stats
|
||||
|
||||
Scenario: I browse a commit with an image
|
||||
Given I visit a commit with an image that changed
|
||||
Then The diff links to both the previous and current image
|
||||
|
||||
@javascript
|
||||
Scenario: I filter commits by message
|
||||
When I search "submodules" commits
|
||||
Then I should see only "submodules" commits
|
|
@ -1,192 +0,0 @@
|
|||
class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
|
||||
include SharedAuthentication
|
||||
include SharedProject
|
||||
include SharedPaths
|
||||
include SharedDiffNote
|
||||
include RepoHelpers
|
||||
|
||||
step 'I see project commits' do
|
||||
commit = @project.repository.commit
|
||||
expect(page).to have_content(@project.name)
|
||||
expect(page).to have_content(commit.message[0..20])
|
||||
expect(page).to have_content(commit.short_id)
|
||||
end
|
||||
|
||||
step 'I click atom feed link' do
|
||||
click_link "Commits feed"
|
||||
end
|
||||
|
||||
step 'I see commits atom feed' do
|
||||
commit = @project.repository.commit
|
||||
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
|
||||
expect(body).to have_selector("title", text: "#{@project.name}:master commits")
|
||||
expect(body).to have_selector("author email", text: commit.author_email)
|
||||
expect(body).to have_selector("entry summary", text: commit.description[0..10].delete("\r\n"))
|
||||
end
|
||||
|
||||
step 'I click on tag link' do
|
||||
click_link "Tag"
|
||||
end
|
||||
|
||||
step 'I see commit SHA pre-filled' do
|
||||
expect(page).to have_selector("input[value='#{sample_commit.id}']")
|
||||
end
|
||||
|
||||
step 'I click on commit link' do
|
||||
visit project_commit_path(@project, sample_commit.id)
|
||||
end
|
||||
|
||||
step 'I see commit info' do
|
||||
expect(page).to have_content sample_commit.message
|
||||
expect(page).to have_content "Showing #{sample_commit.files_changed_count} changed files"
|
||||
end
|
||||
|
||||
step 'I fill compare fields with branches' do
|
||||
select_using_dropdown('from', 'feature')
|
||||
select_using_dropdown('to', 'master')
|
||||
|
||||
click_button 'Compare'
|
||||
end
|
||||
|
||||
step 'I fill compare fields with refs' do
|
||||
select_using_dropdown('from', sample_commit.parent_id, true)
|
||||
select_using_dropdown('to', sample_commit.id, true)
|
||||
|
||||
click_button "Compare"
|
||||
end
|
||||
|
||||
step 'I unfold diff' do
|
||||
@diff = first('.js-unfold')
|
||||
@diff.click
|
||||
sleep 2
|
||||
end
|
||||
|
||||
step 'I should see additional file lines' do
|
||||
page.within @diff.query_scope do
|
||||
expect(first('.new_line').text).not_to have_content "..."
|
||||
end
|
||||
end
|
||||
|
||||
step 'I see compared refs' do
|
||||
expect(page).to have_content "Commits (1)"
|
||||
expect(page).to have_content "Showing 2 changed files"
|
||||
end
|
||||
|
||||
step 'I visit commits list page for feature branch' do
|
||||
visit project_commits_path(@project, 'feature', { limit: 5 })
|
||||
end
|
||||
|
||||
step 'I see feature branch commits' do
|
||||
commit = @project.repository.commit('0b4bc9a')
|
||||
expect(page).to have_content(@project.name)
|
||||
expect(page).to have_content(commit.message[0..12])
|
||||
expect(page).to have_content(commit.short_id)
|
||||
end
|
||||
|
||||
step 'project have an open merge request' do
|
||||
create(:merge_request,
|
||||
title: 'Feature',
|
||||
source_project: @project,
|
||||
source_branch: 'feature',
|
||||
target_branch: 'master',
|
||||
author: @project.users.first
|
||||
)
|
||||
end
|
||||
|
||||
step 'I click the "Compare" tab' do
|
||||
click_link('Compare')
|
||||
end
|
||||
|
||||
step 'I fill compare fields with branches' do
|
||||
select_using_dropdown('from', 'master')
|
||||
select_using_dropdown('to', 'feature')
|
||||
|
||||
click_button 'Compare'
|
||||
end
|
||||
|
||||
step 'I see compared branches' do
|
||||
expect(page).to have_content 'Commits (1)'
|
||||
expect(page).to have_content 'Showing 1 changed file with 5 additions and 0 deletions'
|
||||
end
|
||||
|
||||
step 'I see button to create a new merge request' do
|
||||
expect(page).to have_link 'Create merge request'
|
||||
end
|
||||
|
||||
step 'I should not see button to create a new merge request' do
|
||||
expect(page).not_to have_link 'Create merge request'
|
||||
end
|
||||
|
||||
step 'I should see button to the merge request' do
|
||||
merge_request = MergeRequest.find_by(title: 'Feature')
|
||||
expect(page).to have_link "View open merge request", href: project_merge_request_path(@project, merge_request)
|
||||
end
|
||||
|
||||
step 'I see breadcrumb links' do
|
||||
expect(page).to have_selector('ul.breadcrumb')
|
||||
expect(page).to have_selector('ul.breadcrumb a', count: 4)
|
||||
end
|
||||
|
||||
step 'I see commits stats' do
|
||||
expect(page).to have_content 'Top 50 Committers'
|
||||
expect(page).to have_content 'Committers'
|
||||
expect(page).to have_content 'Total commits'
|
||||
expect(page).to have_content 'Authors'
|
||||
end
|
||||
|
||||
step 'I visit a commit with an image that changed' do
|
||||
visit project_commit_path(@project, sample_image_commit.id)
|
||||
end
|
||||
|
||||
step 'The diff links to both the previous and current image' do
|
||||
links = page.all('.file-actions a')
|
||||
expect(links[0]['href']).to match %r{blob/#{sample_image_commit.old_blob_id}}
|
||||
expect(links[1]['href']).to match %r{blob/#{sample_image_commit.new_blob_id}}
|
||||
end
|
||||
|
||||
step 'I see inline diff button' do
|
||||
expect(page).to have_content "Inline"
|
||||
end
|
||||
|
||||
step 'I click side-by-side diff button' do
|
||||
find('#parallel-diff-btn').click
|
||||
end
|
||||
|
||||
step 'commit has ci status' do
|
||||
@project.enable_ci
|
||||
@pipeline = create(:ci_pipeline, project: @project, sha: sample_commit.id)
|
||||
create(:ci_build, pipeline: @pipeline)
|
||||
end
|
||||
|
||||
step 'repository contains ".gitlab-ci.yml" file' do
|
||||
allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return(String.new)
|
||||
end
|
||||
|
||||
step 'I see commit ci info' do
|
||||
expect(page).to have_content "Pipeline ##{@pipeline.id} pending"
|
||||
end
|
||||
|
||||
step 'I search "submodules" commits' do
|
||||
fill_in 'commits-search', with: 'submodules'
|
||||
end
|
||||
|
||||
step 'I should see only "submodules" commits' do
|
||||
expect(page).to have_content "More submodules"
|
||||
expect(page).not_to have_content "Change some files"
|
||||
end
|
||||
|
||||
def select_using_dropdown(dropdown_type, selection, is_commit = false)
|
||||
dropdown = find(".js-compare-#{dropdown_type}-dropdown")
|
||||
dropdown.find(".compare-dropdown-toggle").click
|
||||
dropdown.find('.dropdown-menu', visible: true)
|
||||
dropdown.fill_in("Filter by Git revision", with: selection)
|
||||
|
||||
if is_commit
|
||||
dropdown.find('input[type="search"]').send_keys(:return)
|
||||
else
|
||||
find_link(selection, visible: true).click
|
||||
end
|
||||
|
||||
dropdown.find('.dropdown-menu', visible: false)
|
||||
end
|
||||
end
|
|
@ -1,6 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'User browses commits' do
|
||||
include RepoHelpers
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project, :repository, namespace: user.namespace) }
|
||||
|
||||
|
@ -9,13 +11,68 @@ describe 'User browses commits' do
|
|||
sign_in(user)
|
||||
end
|
||||
|
||||
it 'renders commit' do
|
||||
visit project_commit_path(project, sample_commit.id)
|
||||
|
||||
expect(page).to have_content(sample_commit.message)
|
||||
.and have_content("Showing #{sample_commit.files_changed_count} changed files")
|
||||
.and have_content('Side-by-side')
|
||||
end
|
||||
|
||||
it 'fill commit sha when click new tag from commit page' do
|
||||
visit project_commit_path(project, sample_commit.id)
|
||||
click_link 'Tag'
|
||||
|
||||
expect(page).to have_selector("input[value='#{sample_commit.id}']", visible: false)
|
||||
end
|
||||
|
||||
it 'renders inline diff button when click side-by-side diff button' do
|
||||
visit project_commit_path(project, sample_commit.id)
|
||||
find('#parallel-diff-btn').click
|
||||
|
||||
expect(page).to have_content 'Inline'
|
||||
end
|
||||
|
||||
it 'renders breadcrumbs on specific commit path' do
|
||||
visit project_commits_path(project, project.repository.root_ref + '/files/ruby/regex.rb', limit: 5)
|
||||
|
||||
expect(page).to have_selector('ul.breadcrumb')
|
||||
.and have_selector('ul.breadcrumb a', count: 4)
|
||||
end
|
||||
|
||||
it 'renders diff links to both the previous and current image' do
|
||||
visit project_commit_path(project, sample_image_commit.id)
|
||||
|
||||
links = page.all('.file-actions a')
|
||||
expect(links[0]['href']).to match %r{blob/#{sample_image_commit.old_blob_id}}
|
||||
expect(links[1]['href']).to match %r{blob/#{sample_image_commit.new_blob_id}}
|
||||
end
|
||||
|
||||
context 'when commit has ci status' do
|
||||
let(:pipeline) { create(:ci_pipeline, project: project, sha: sample_commit.id) }
|
||||
|
||||
before do
|
||||
project.enable_ci
|
||||
|
||||
create(:ci_build, pipeline: pipeline)
|
||||
|
||||
allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return('')
|
||||
end
|
||||
|
||||
it 'renders commit ci info' do
|
||||
visit project_commit_path(project, sample_commit.id)
|
||||
|
||||
expect(page).to have_content "Pipeline ##{pipeline.id} pending"
|
||||
end
|
||||
end
|
||||
|
||||
context 'primary email' do
|
||||
it 'finds a commit by a primary email' do
|
||||
user = create(:user, email: 'dmitriy.zaporozhets@gmail.com')
|
||||
|
||||
visit(project_commit_path(project, RepoHelpers.sample_commit.id))
|
||||
visit(project_commit_path(project, sample_commit.id))
|
||||
|
||||
check_author_link(RepoHelpers.sample_commit.author_email, user)
|
||||
check_author_link(sample_commit.author_email, user)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -26,9 +83,9 @@ describe 'User browses commits' do
|
|||
create(:email, { user: user, email: 'dmitriy.zaporozhets@gmail.com' })
|
||||
end
|
||||
|
||||
visit(project_commit_path(project, RepoHelpers.sample_commit.parent_id))
|
||||
visit(project_commit_path(project, sample_commit.parent_id))
|
||||
|
||||
check_author_link(RepoHelpers.sample_commit.author_email, user)
|
||||
check_author_link(sample_commit.author_email, user)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -44,6 +101,135 @@ describe 'User browses commits' do
|
|||
expect(find('.diff-file-changes', visible: false)).to have_content('No file name available')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'commits list' do
|
||||
let(:visit_commits_page) do
|
||||
visit project_commits_path(project, project.repository.root_ref, limit: 5)
|
||||
end
|
||||
|
||||
it 'searches commit', :js do
|
||||
visit_commits_page
|
||||
fill_in 'commits-search', with: 'submodules'
|
||||
|
||||
expect(page).to have_content 'More submodules'
|
||||
expect(page).not_to have_content 'Change some files'
|
||||
end
|
||||
|
||||
it 'renders commits atom feed' do
|
||||
visit_commits_page
|
||||
click_link('Commits feed')
|
||||
|
||||
commit = project.repository.commit
|
||||
|
||||
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
|
||||
expect(body).to have_selector('title', text: "#{project.name}:master commits")
|
||||
.and have_selector('author email', text: commit.author_email)
|
||||
.and have_selector('entry summary', text: commit.description[0..10].delete("\r\n"))
|
||||
end
|
||||
|
||||
context 'master branch' do
|
||||
before do
|
||||
visit_commits_page
|
||||
end
|
||||
|
||||
it 'renders project commits' do
|
||||
commit = project.repository.commit
|
||||
|
||||
expect(page).to have_content(project.name)
|
||||
.and have_content(commit.message[0..20])
|
||||
.and have_content(commit.short_id)
|
||||
end
|
||||
|
||||
it 'does not render create merge request button' do
|
||||
expect(page).not_to have_link 'Create merge request'
|
||||
end
|
||||
|
||||
context 'when click the compare tab' do
|
||||
before do
|
||||
click_link('Compare')
|
||||
end
|
||||
|
||||
it 'does not render create merge request button' do
|
||||
expect(page).not_to have_link 'Create merge request'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'feature branch' do
|
||||
let(:visit_commits_page) do
|
||||
visit project_commits_path(project, 'feature')
|
||||
end
|
||||
|
||||
context 'when project does not have open merge requests' do
|
||||
before do
|
||||
visit_commits_page
|
||||
end
|
||||
|
||||
it 'renders project commits' do
|
||||
commit = project.repository.commit('0b4bc9a')
|
||||
|
||||
expect(page).to have_content(project.name)
|
||||
.and have_content(commit.message[0..12])
|
||||
.and have_content(commit.short_id)
|
||||
end
|
||||
|
||||
it 'renders create merge request button' do
|
||||
expect(page).to have_link 'Create merge request'
|
||||
end
|
||||
|
||||
context 'when click the compare tab' do
|
||||
before do
|
||||
click_link('Compare')
|
||||
end
|
||||
|
||||
it 'renders create merge request button' do
|
||||
expect(page).to have_link 'Create merge request'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when project have open merge request' do
|
||||
let!(:merge_request) do
|
||||
create(
|
||||
:merge_request,
|
||||
title: 'Feature',
|
||||
source_project: project,
|
||||
source_branch: 'feature',
|
||||
target_branch: 'master',
|
||||
author: project.users.first
|
||||
)
|
||||
end
|
||||
|
||||
before do
|
||||
visit_commits_page
|
||||
end
|
||||
|
||||
it 'renders project commits' do
|
||||
commit = project.repository.commit('0b4bc9a')
|
||||
|
||||
expect(page).to have_content(project.name)
|
||||
.and have_content(commit.message[0..12])
|
||||
.and have_content(commit.short_id)
|
||||
end
|
||||
|
||||
it 'renders button to the merge request' do
|
||||
expect(page).not_to have_link 'Create merge request'
|
||||
expect(page).to have_link 'View open merge request', href: project_merge_request_path(project, merge_request)
|
||||
end
|
||||
|
||||
context 'when click the compare tab' do
|
||||
before do
|
||||
click_link('Compare')
|
||||
end
|
||||
|
||||
it 'renders button to the merge request' do
|
||||
expect(page).not_to have_link 'Create merge request'
|
||||
expect(page).to have_link 'View open merge request', href: project_merge_request_path(project, merge_request)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -7,16 +7,19 @@ describe "Compare", :js do
|
|||
before do
|
||||
project.add_master(user)
|
||||
sign_in user
|
||||
visit project_compare_index_path(project, from: "master", to: "master")
|
||||
end
|
||||
|
||||
describe "branches" do
|
||||
it "pre-populates fields" do
|
||||
visit project_compare_index_path(project, from: "master", to: "master")
|
||||
|
||||
expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("master")
|
||||
expect(find(".js-compare-to-dropdown .dropdown-toggle-text")).to have_content("master")
|
||||
end
|
||||
|
||||
it "compares branches" do
|
||||
visit project_compare_index_path(project, from: "master", to: "master")
|
||||
|
||||
select_using_dropdown "from", "feature"
|
||||
expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("feature")
|
||||
|
||||
|
@ -26,9 +29,58 @@ describe "Compare", :js do
|
|||
click_button "Compare"
|
||||
|
||||
expect(page).to have_content "Commits"
|
||||
expect(page).to have_link 'Create merge request'
|
||||
end
|
||||
|
||||
it 'renders additions info when click unfold diff' do
|
||||
visit project_compare_index_path(project)
|
||||
|
||||
select_using_dropdown('from', RepoHelpers.sample_commit.parent_id, commit: true)
|
||||
select_using_dropdown('to', RepoHelpers.sample_commit.id, commit: true)
|
||||
|
||||
click_button 'Compare'
|
||||
expect(page).to have_content 'Commits (1)'
|
||||
expect(page).to have_content "Showing 2 changed files"
|
||||
|
||||
diff = first('.js-unfold')
|
||||
diff.click
|
||||
wait_for_requests
|
||||
|
||||
page.within diff.query_scope do
|
||||
expect(first('.new_line').text).not_to have_content "..."
|
||||
end
|
||||
end
|
||||
|
||||
context 'when project have an open merge request' do
|
||||
let!(:merge_request) do
|
||||
create(
|
||||
:merge_request,
|
||||
title: 'Feature',
|
||||
source_project: project,
|
||||
source_branch: 'feature',
|
||||
target_branch: 'master',
|
||||
author: project.users.first
|
||||
)
|
||||
end
|
||||
|
||||
it 'compares branches' do
|
||||
visit project_compare_index_path(project)
|
||||
|
||||
select_using_dropdown('from', 'master')
|
||||
select_using_dropdown('to', 'feature')
|
||||
|
||||
click_button 'Compare'
|
||||
|
||||
expect(page).to have_content 'Commits (1)'
|
||||
expect(page).to have_content 'Showing 1 changed file with 5 additions and 0 deletions'
|
||||
expect(page).to have_link 'View open merge request', href: project_merge_request_path(project, merge_request)
|
||||
expect(page).not_to have_link 'Create merge request'
|
||||
end
|
||||
end
|
||||
|
||||
it "filters branches" do
|
||||
visit project_compare_index_path(project, from: "master", to: "master")
|
||||
|
||||
select_using_dropdown("from", "wip")
|
||||
|
||||
find(".js-compare-from-dropdown .compare-dropdown-toggle").click
|
||||
|
@ -39,6 +91,8 @@ describe "Compare", :js do
|
|||
|
||||
describe "tags" do
|
||||
it "compares tags" do
|
||||
visit project_compare_index_path(project, from: "master", to: "master")
|
||||
|
||||
select_using_dropdown "from", "v1.0.0"
|
||||
expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("v1.0.0")
|
||||
|
||||
|
@ -50,15 +104,20 @@ describe "Compare", :js do
|
|||
end
|
||||
end
|
||||
|
||||
def select_using_dropdown(dropdown_type, selection)
|
||||
def select_using_dropdown(dropdown_type, selection, commit: false)
|
||||
dropdown = find(".js-compare-#{dropdown_type}-dropdown")
|
||||
dropdown.find(".compare-dropdown-toggle").click
|
||||
# find input before using to wait for the inputs visiblity
|
||||
dropdown.find('.dropdown-menu')
|
||||
dropdown.fill_in("Filter by Git revision", with: selection)
|
||||
wait_for_requests
|
||||
# find before all to wait for the items visiblity
|
||||
dropdown.find("a[data-ref=\"#{selection}\"]", match: :first)
|
||||
dropdown.all("a[data-ref=\"#{selection}\"]").last.click
|
||||
|
||||
if commit
|
||||
dropdown.find('input[type="search"]').send_keys(:return)
|
||||
else
|
||||
# find before all to wait for the items visiblity
|
||||
dropdown.find("a[data-ref=\"#{selection}\"]", match: :first)
|
||||
dropdown.all("a[data-ref=\"#{selection}\"]").last.click
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue