Commit 150bb361 authored by Walmyr Lima e Silva Filho's avatar Walmyr Lima e Silva Filho

Merge branch 'zm-display-cov' into 'master'

E2E - display code coverage statistics

Closes gitlab-org/quality/testcases#147

See merge request gitlab-org/gitlab!18029
parents f0353a0c 73856472
......@@ -103,7 +103,7 @@
.input-group
%span.input-group-prepend
.input-group-text /
= f.text_field :build_coverage_regex, class: 'form-control', placeholder: 'Regular expression'
= f.text_field :build_coverage_regex, class: 'form-control', placeholder: 'Regular expression', data: { qa_selector: 'build_coverage_regex_field' }
%span.input-group-append
.input-group-text /
%p.form-text.text-muted
......@@ -143,7 +143,7 @@
go test -cover (Go)
%code coverage: \d+.\d+% of statements
= f.submit _('Save changes'), class: "btn btn-success"
= f.submit _('Save changes'), class: "btn btn-success", data: { qa_selector: 'save_general_pipelines_changes_button' }
%hr
......
......@@ -5,7 +5,7 @@
- expanded = expanded_by_default?
- general_expanded = @project.errors.empty? ? expanded : true
%section.settings#js-general-pipeline-settings.no-animate{ class: ('expanded' if general_expanded) }
%section.settings#js-general-pipeline-settings.no-animate{ class: ('expanded' if general_expanded), data: { qa_selector: 'general_pipelines_settings_content' } }
.settings-header
%h4
= _("General pipelines")
......
......@@ -252,6 +252,7 @@ module QA
autoload :Main, 'qa/page/project/settings/main'
autoload :Repository, 'qa/page/project/settings/repository'
autoload :CICD, 'qa/page/project/settings/ci_cd'
autoload :GeneralPipelines, 'qa/page/project/settings/general_pipelines'
autoload :AutoDevops, 'qa/page/project/settings/auto_devops'
autoload :DeployKeys, 'qa/page/project/settings/deploy_keys'
autoload :DeployTokens, 'qa/page/project/settings/deploy_tokens'
......
......@@ -11,6 +11,13 @@ module QA
element :autodevops_settings_content
element :runners_settings_content
element :variables_settings_content
element :general_pipelines_settings_content
end
def expand_general_pipelines(&block)
expand_section(:general_pipelines_settings_content) do
Settings::GeneralPipelines.perform(&block)
end
end
def expand_runners_settings(&block)
......
# frozen_string_literal: true
module QA
module Page
module Project
module Settings
class GeneralPipelines < Page::Base
include Common
view 'app/views/projects/settings/ci_cd/_form.html.haml' do
element :build_coverage_regex_field
element :save_general_pipelines_changes_button
end
def configure_coverage_regex(pattern)
fill_element :build_coverage_regex_field, pattern
click_element :save_general_pipelines_changes_button
end
end
end
end
end
end
# frozen_string_literal: true
module QA
context 'Verify', :docker, :runner do
describe 'Code coverage statistics' do
let(:simplecov) { '\(\d+.\d+\%\) covered' }
let(:executor) { "qa-runner-#{Time.now.to_i}" }
let(:runner) do
Resource::Runner.fabricate_via_api! do |runner|
runner.name = executor
end
end
let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |mr|
mr.project = runner.project
mr.file_name = '.gitlab-ci.yml'
mr.file_content = <<~EOF
test:
tags:
- qa
- e2e
script:
- echo '(66.67%) covered'
EOF
end
end
before do
Flow::Login.sign_in
end
after do
runner.remove_via_api!
end
it 'creates an MR with code coverage statistics' do
runner.project.visit!
configure_code_coverage(simplecov)
merge_request.visit!
Page::MergeRequest::Show.perform do |mr_widget|
Support::Retrier.retry_until(max_attempts: 5, sleep_interval: 5) do
mr_widget.has_pipeline_status?(/Pipeline #\d+ passed/)
end
expect(mr_widget).to have_content('Coverage 66.67%')
end
end
end
private
def configure_code_coverage(coverage_tool_pattern)
Page::Project::Menu.perform(&:go_to_ci_cd_settings)
Page::Project::Settings::CICD.perform do |settings|
settings.expand_general_pipelines do |coverage|
coverage.configure_coverage_regex(coverage_tool_pattern)
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment