2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-24 18:00:50 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Value Stream Analytics', :js do
|
2020-08-25 05:10:42 -04:00
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:guest) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
2021-06-28 23:07:32 -04:00
|
|
|
|
2016-12-30 18:01:36 -05:00
|
|
|
let(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
|
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
2018-02-21 07:13:56 -05:00
|
|
|
let(:mr) { create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}") }
|
2017-05-19 16:51:07 -04:00
|
|
|
let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr) }
|
2016-11-24 18:00:50 -05:00
|
|
|
|
|
|
|
context 'as an allowed user' do
|
|
|
|
context 'when project is new' do
|
2020-08-25 05:10:42 -04:00
|
|
|
before(:all) do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2020-08-25 05:10:42 -04:00
|
|
|
end
|
2017-03-28 16:04:14 -04:00
|
|
|
|
2020-08-25 05:10:42 -04:00
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-03-28 16:04:14 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_cycle_analytics_path(project)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-11-24 18:00:50 -05:00
|
|
|
end
|
|
|
|
|
2017-08-10 02:41:41 -04:00
|
|
|
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-21 11:21:10 -04:00
|
|
|
expect(deployment_frequency_counter).to have_content('-')
|
2017-08-10 02:41:41 -04:00
|
|
|
end
|
|
|
|
|
2016-11-24 18:00:50 -05:00
|
|
|
it 'shows active stage with empty message' do
|
2021-06-02 05:09:46 -04:00
|
|
|
expect(page).to have_selector('.gl-path-active-item-indigo', text: 'Issue')
|
2016-11-24 18:00:50 -05:00
|
|
|
expect(page).to have_content("We don't have enough data to show this stage.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-02-07 16:08:39 -05:00
|
|
|
context "when there's value stream analytics data" do
|
2016-11-24 18:00:50 -05:00
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-05-05 15:00:18 -04:00
|
|
|
|
2018-02-15 08:23:39 -05:00
|
|
|
@build = create_cycle(user, project, issue, mr, milestone, pipeline)
|
2018-02-21 07:13:56 -05:00
|
|
|
deploy_master(user, project)
|
2016-11-24 18:00:50 -05:00
|
|
|
|
2020-12-11 07:09:43 -05:00
|
|
|
issue.metrics.update!(first_mentioned_in_commit_at: issue.metrics.first_associated_with_milestone_at + 1.day)
|
|
|
|
merge_request = issue.merge_requests_closing_issues.first.merge_request
|
|
|
|
merge_request.update!(created_at: issue.metrics.first_associated_with_milestone_at + 1.day)
|
|
|
|
merge_request.metrics.update!(
|
|
|
|
latest_build_started_at: 4.hours.ago,
|
|
|
|
latest_build_finished_at: 3.hours.ago,
|
|
|
|
merged_at: merge_request.created_at + 1.hour,
|
|
|
|
first_deployed_to_production_at: merge_request.created_at + 2.hours
|
|
|
|
)
|
|
|
|
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_cycle_analytics_path(project)
|
2016-11-24 18:00:50 -05:00
|
|
|
end
|
|
|
|
|
2017-08-10 02:41:41 -04:00
|
|
|
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-21 11:21:10 -04:00
|
|
|
expect(deployment_frequency_counter).to have_content('0')
|
2017-08-10 02:41:41 -04:00
|
|
|
end
|
|
|
|
|
2019-10-23 05:06:03 -04:00
|
|
|
it 'shows data on each stage', :sidekiq_might_not_need_inline do
|
2016-11-24 18:00:50 -05:00
|
|
|
expect_issue_to_be_present
|
|
|
|
|
|
|
|
click_stage('Plan')
|
2019-06-17 09:17:18 -04:00
|
|
|
expect_issue_to_be_present
|
2016-11-24 18:00:50 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
end
|
2017-08-10 02:42:28 -04:00
|
|
|
|
|
|
|
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
|
2016-11-24 18:00:50 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "as a guest" do
|
|
|
|
before do
|
2018-01-05 12:55:37 -05:00
|
|
|
project.add_developer(user)
|
2017-03-28 16:04:14 -04:00
|
|
|
project.add_guest(guest)
|
2016-11-24 18:00:50 -05:00
|
|
|
|
2018-02-15 08:23:39 -05:00
|
|
|
create_cycle(user, project, issue, mr, milestone, pipeline)
|
2018-02-21 07:13:56 -05:00
|
|
|
deploy_master(user, project)
|
2016-11-24 18:00:50 -05:00
|
|
|
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(guest)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_cycle_analytics_path(project)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-11-24 18:00:50 -05:00
|
|
|
end
|
|
|
|
|
2019-11-06 11:07:11 -05:00
|
|
|
it 'does not show the commit stats' do
|
|
|
|
expect(page).to have_no_selector(:xpath, commits_counter_selector)
|
|
|
|
end
|
|
|
|
|
2016-11-24 18:00:50 -05:00
|
|
|
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
|
|
|
|
|
2017-08-10 02:41:41 -04:00
|
|
|
def new_issues_counter
|
|
|
|
find(:xpath, "//p[contains(text(),'New Issue')]/preceding-sibling::h3")
|
|
|
|
end
|
|
|
|
|
2019-11-06 11:07:11 -05:00
|
|
|
def commits_counter_selector
|
|
|
|
"//p[contains(text(),'Commits')]/preceding-sibling::h3"
|
|
|
|
end
|
|
|
|
|
2017-08-10 02:41:41 -04:00
|
|
|
def commits_counter
|
2019-11-06 11:07:11 -05:00
|
|
|
find(:xpath, commits_counter_selector)
|
2017-08-10 02:41:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def deploys_counter
|
2020-04-21 11:21:10 -04:00
|
|
|
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)
|
2017-08-10 02:41:41 -04:00
|
|
|
end
|
|
|
|
|
2016-11-24 18:00:50 -05:00
|
|
|
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
|
2016-12-30 18:01:36 -05:00
|
|
|
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}")
|
2016-11-24 18:00:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def click_stage(stage_name)
|
2021-06-02 05:09:46 -04:00
|
|
|
find('.gl-path-nav-list-item', text: stage_name).click
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-11-24 18:00:50 -05:00
|
|
|
end
|
|
|
|
end
|