2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-10 05:49:18 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Project Graph', :js do
|
2018-03-10 05:49:18 -05:00
|
|
|
let(:user) { create :user }
|
|
|
|
let(:project) { create(:project, :repository, namespace: user.namespace) }
|
2018-06-18 09:29:27 -04:00
|
|
|
let(:branch_name) { 'master' }
|
2018-03-10 05:49:18 -05:00
|
|
|
|
|
|
|
before do
|
2019-03-20 13:23:23 -04:00
|
|
|
::Projects::DetectRepositoryLanguagesService.new(project, user).execute
|
|
|
|
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2018-03-10 05:49:18 -05:00
|
|
|
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'page should have commits graphs' do
|
|
|
|
it 'renders commits' do
|
2018-06-18 09:29:27 -04:00
|
|
|
expect(page).to have_content("Commit statistics for #{branch_name}")
|
2018-03-10 05:49:18 -05:00
|
|
|
expect(page).to have_content('Commits per day of month')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'commits graph' do
|
|
|
|
before do
|
|
|
|
visit commits_project_graph_path(project, 'master')
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page should have commits graphs'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'languages graph' do
|
|
|
|
before do
|
|
|
|
visit languages_project_graph_path(project, 'master')
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page should have commits graphs'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'charts graph' do
|
|
|
|
before do
|
|
|
|
visit charts_project_graph_path(project, 'master')
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page should have commits graphs'
|
|
|
|
end
|
|
|
|
|
2018-06-18 09:29:27 -04:00
|
|
|
context 'chart graph with HTML escaped branch name' do
|
|
|
|
let(:branch_name) { '<h1>evil</h1>' }
|
|
|
|
|
|
|
|
before do
|
2020-02-06 13:08:54 -05:00
|
|
|
project.repository.create_branch(branch_name)
|
2018-06-18 09:29:27 -04:00
|
|
|
|
|
|
|
visit charts_project_graph_path(project, branch_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page should have commits graphs'
|
|
|
|
|
|
|
|
it 'HTML escapes branch name' do
|
|
|
|
expect(page.body).to include("Commit statistics for <strong>#{ERB::Util.html_escape(branch_name)}</strong>")
|
2020-05-04 14:10:20 -04:00
|
|
|
expect(page.find('.dropdown-toggle-text')['innerHTML']).to eq(ERB::Util.html_escape(branch_name))
|
2018-06-18 09:29:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-10 05:49:18 -05:00
|
|
|
context 'when CI enabled' do
|
|
|
|
before do
|
|
|
|
project.enable_ci
|
|
|
|
|
|
|
|
visit ci_project_graph_path(project, 'master')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders CI graphs' do
|
|
|
|
expect(page).to have_content 'Overall'
|
2021-02-05 13:09:44 -05:00
|
|
|
expect(page).to have_content 'Last week'
|
|
|
|
expect(page).to have_content 'Last month'
|
|
|
|
expect(page).to have_content 'Last year'
|
2021-05-07 05:10:27 -04:00
|
|
|
expect(page).to have_content 'Pipeline durations for the last 30 commits'
|
2018-03-10 05:49:18 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|