debian-mirror-gitlab/spec/features/cycle_analytics_spec.rb

173 lines
5.1 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-03-13 15:44:24 +05:30
describe 'Value Stream Analytics', :js do
2017-08-17 22:00:37 +05:30
let(:user) { create(:user) }
let(:guest) { create(:user) }
let(:project) { create(:project, :repository) }
let(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
let(:milestone) { create(:milestone, project: project) }
2018-03-27 19:54:05 +05:30
let(:mr) { create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}") }
2017-09-10 17:25:29 +05:30
let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr) }
2017-08-17 22:00:37 +05:30
context 'as an allowed user' do
context 'when project is new' do
2019-03-02 22:35:43 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2017-09-10 17:25:29 +05:30
sign_in(user)
visit project_cycle_analytics_path(project)
wait_for_requests
2017-08-17 22:00:37 +05:30
end
it 'shows introductory message' do
2020-03-13 15:44:24 +05:30
expect(page).to have_content('Introducing Value Stream Analytics')
2017-08-17 22:00:37 +05:30
end
2018-03-17 18:26:18 +05:30
it 'shows pipeline summary' do
expect(new_issues_counter).to have_content('-')
expect(commits_counter).to have_content('-')
expect(deploys_counter).to have_content('-')
2020-04-22 19:07:51 +05:30
expect(deployment_frequency_counter).to have_content('-')
2018-03-17 18:26:18 +05:30
end
2017-08-17 22:00:37 +05:30
it 'shows active stage with empty message' do
expect(page).to have_selector('.stage-nav-item.active', text: 'Issue')
expect(page).to have_content("We don't have enough data to show this stage.")
end
end
2020-03-13 15:44:24 +05:30
context "when there's value stream analytics data" do
2017-08-17 22:00:37 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2017-09-10 17:25:29 +05:30
2018-03-27 19:54:05 +05:30
@build = create_cycle(user, project, issue, mr, milestone, pipeline)
deploy_master(user, project)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
sign_in(user)
visit project_cycle_analytics_path(project)
2017-08-17 22:00:37 +05:30
end
2018-03-17 18:26:18 +05:30
it 'shows pipeline summary' do
expect(new_issues_counter).to have_content('1')
expect(commits_counter).to have_content('2')
expect(deploys_counter).to have_content('1')
2020-04-22 19:07:51 +05:30
expect(deployment_frequency_counter).to have_content('0')
2018-03-17 18:26:18 +05:30
end
2019-12-26 22:10:19 +05:30
it 'shows data on each stage', :sidekiq_might_not_need_inline do
2017-08-17 22:00:37 +05:30
expect_issue_to_be_present
click_stage('Plan')
2019-09-04 21:01:54 +05:30
expect_issue_to_be_present
2017-08-17 22:00:37 +05:30
click_stage('Code')
expect_merge_request_to_be_present
click_stage('Test')
expect_build_to_be_present
click_stage('Review')
expect_merge_request_to_be_present
click_stage('Staging')
expect_build_to_be_present
2020-03-13 15:44:24 +05:30
click_stage('Total')
2017-08-17 22:00:37 +05:30
expect_issue_to_be_present
end
2018-03-17 18:26:18 +05:30
context "when I change the time period observed" do
before do
_two_weeks_old_issue = create(:issue, project: project, created_at: 2.weeks.ago)
click_button('Last 30 days')
click_link('Last 7 days')
wait_for_requests
end
it 'shows only relevant data' do
expect(new_issues_counter).to have_content('1')
end
end
2017-08-17 22:00:37 +05:30
end
end
context "as a guest" do
before do
2018-03-17 18:26:18 +05:30
project.add_developer(user)
2017-09-10 17:25:29 +05:30
project.add_guest(guest)
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
create_cycle(user, project, issue, mr, milestone, pipeline)
deploy_master(user, project)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
sign_in(guest)
visit project_cycle_analytics_path(project)
wait_for_requests
2017-08-17 22:00:37 +05:30
end
2019-12-04 20:38:33 +05:30
it 'does not show the commit stats' do
expect(page).to have_no_selector(:xpath, commits_counter_selector)
end
2017-08-17 22:00:37 +05:30
it 'needs permissions to see restricted stages' do
expect(find('.stage-events')).to have_content(issue.title)
click_stage('Code')
expect(find('.stage-events')).to have_content('You need permission.')
click_stage('Review')
expect(find('.stage-events')).to have_content('You need permission.')
end
end
2018-03-17 18:26:18 +05:30
def new_issues_counter
find(:xpath, "//p[contains(text(),'New Issue')]/preceding-sibling::h3")
end
2019-12-04 20:38:33 +05:30
def commits_counter_selector
"//p[contains(text(),'Commits')]/preceding-sibling::h3"
end
2018-03-17 18:26:18 +05:30
def commits_counter
2019-12-04 20:38:33 +05:30
find(:xpath, commits_counter_selector)
2018-03-17 18:26:18 +05:30
end
def deploys_counter
2020-04-22 19:07:51 +05:30
find(:xpath, "//p[contains(text(),'Deploy')]/preceding-sibling::h3", match: :first)
end
def deployment_frequency_counter_selector
"//p[contains(text(),'Deployment Frequency')]/preceding-sibling::h3"
end
def deployment_frequency_counter
find(:xpath, deployment_frequency_counter_selector)
2018-03-17 18:26:18 +05:30
end
2017-08-17 22:00:37 +05:30
def expect_issue_to_be_present
expect(find('.stage-events')).to have_content(issue.title)
expect(find('.stage-events')).to have_content(issue.author.name)
expect(find('.stage-events')).to have_content("##{issue.iid}")
end
def expect_build_to_be_present
expect(find('.stage-events')).to have_content(@build.ref)
expect(find('.stage-events')).to have_content(@build.short_sha)
expect(find('.stage-events')).to have_content("##{@build.id}")
end
def expect_merge_request_to_be_present
expect(find('.stage-events')).to have_content(mr.title)
expect(find('.stage-events')).to have_content(mr.author.name)
expect(find('.stage-events')).to have_content("!#{mr.iid}")
end
def click_stage(stage_name)
find('.stage-nav li', text: stage_name).click
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
end
end