Commit 063f33f3 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'qa-license-management-mr-spec' into 'master'

Add license management via merge request spec

Closes gitlab-org/quality/testcases#141 and gitlab-org/quality/testcases#140

See merge request gitlab-org/gitlab!19771
parents a2f20422 b491f524
......@@ -265,7 +265,11 @@ export default {
<div class="table-section section-10 commit-link">
<div class="table-mobile-header" role="rowheader">{{ s__('Pipeline|Status') }}</div>
<div class="table-mobile-content">
<ci-badge :status="pipelineStatus" :show-text="!isChildView" />
<ci-badge
:status="pipelineStatus"
:show-text="!isChildView"
data-qa-selector="pipeline_commit_status"
/>
</div>
</div>
......
......@@ -45,6 +45,7 @@ export default {
id="modal-set-license-approval"
:header-title-text="headerTitleText"
modal-size="lg"
data-qa-selector="license_management_modal"
@cancel="resetLicenseInModal"
>
<slot v-if="currentLicenseInModal">
......@@ -93,6 +94,7 @@ export default {
v-if="canBlacklist"
class="btn btn-remove btn-inverted js-modal-secondary-action"
data-dismiss="modal"
data-qa-selector="blacklist_license_button"
@click="blacklistLicense(currentLicenseInModal)"
>
{{ s__('LicenseCompliance|Blacklist license') }}
......@@ -102,6 +104,7 @@ export default {
type="button"
class="btn btn-success js-modal-primary-action"
data-dismiss="modal"
data-qa-selector="approve_license_button"
@click="approveLicense(currentLicenseInModal)"
>
{{ s__('LicenseCompliance|Approve license') }}
......
......@@ -136,6 +136,7 @@ export default {
:class="reportSectionClass"
:always-open="alwaysOpen"
class="license-report-widget mr-report"
data-qa-selector="license_report_widget"
>
<template #success>
{{ licenseSummaryText }}
......
......@@ -14,6 +14,7 @@ module QA
module Page
module Component
autoload :DesignManagement, 'qa/ee/page/component/design_management'
autoload :LicenseManagement, 'qa/ee/page/component/license_management'
module IssueBoard
autoload :Show, 'qa/ee/page/component/issue_board/show'
......
include:
template: License-Management.gitlab-ci.yml
license_management:
tags:
- qa
- test
script:
- echo "Skipped"
artifacts:
reports:
license_management: gl-license-management-report.json
{
"licenses": [
{
"count": 1,
"name": "WTFPL"
}
]
}
# frozen_string_literal: true
module QA
module EE
module Page
module Component
module LicenseManagement
def self.prepended(page)
page.module_eval do
view 'app/assets/javascripts/reports/components/report_item.vue' do
element :report_item_row
end
view 'app/assets/javascripts/reports/components/issue_status_icon.vue' do
element :icon_status, ':data-qa-selector="`status_${status}_icon`" ' # rubocop:disable QA/ElementWithPattern
end
view 'ee/app/assets/javascripts/vue_shared/license_management/components/set_approval_status_modal.vue' do
element :license_management_modal
element :approve_license_button
element :blacklist_license_button
end
view 'ee/app/assets/javascripts/vue_shared/license_management/mr_widget_license_report.vue' do
element :license_report_widget
end
end
end
def has_approved_license?(name)
within_element(:report_item_row, text: name) do
has_element?(:status_success_icon, wait: 1)
end
end
def has_blacklisted_license?(name)
within_element(:report_item_row, text: name) do
has_element?(:status_failed_icon, wait: 1)
end
end
def click_license(name)
within_element(:license_report_widget) do
click_on name
end
wait_for_animated_element(:license_management_modal)
end
def approve_license(name)
click_license(name)
click_element(:approve_license_button)
end
def blacklist_license(name)
click_license(name)
click_element(:blacklist_license_button)
end
end
end
end
end
end
......@@ -5,6 +5,8 @@ module QA
module Page
module MergeRequest
module Show
include Page::Component::LicenseManagement
def self.prepended(page)
page.module_eval do
view 'app/assets/javascripts/vue_merge_request_widget/components/states/sha_mismatch.vue' do
......@@ -114,6 +116,28 @@ module QA
check_element :unresolve_review_discussion_checkbox
end
def expand_license_report
within_element(:license_report_widget) do
click_element(:expand_report_button)
end
end
def license_report_expanded?
within_element(:license_report_widget) do
has_element?(:expand_report_button, text: "Collapse")
end
end
def approve_license_with_mr(name)
expand_license_report unless license_report_expanded?
approve_license(name)
end
def blacklist_license_with_mr(name)
expand_license_report unless license_report_expanded?
blacklist_license(name)
end
def expand_vulnerability_report
within_element :vulnerability_report_grouped do
click_element :expand_report_button
......
# frozen_string_literal: true
module QA::EE::Page
module Project::Pipeline
module Show
def self.prepended(page)
page.module_eval do
view 'ee/app/views/projects/pipelines/_tabs_holder.html.haml' do
element :security_tab
element :security_counter
element :licenses_tab
element :licenses_counter
end
view 'ee/app/assets/javascripts/security_dashboard/components/filter.vue' do
element :filter_dropdown, ':data-qa-selector="qaSelector"' # rubocop:disable QA/ElementWithPattern
element :filter_dropdown_content
end
view 'ee/app/views/projects/pipelines/_tabs_holder.html.haml' do
element :security_tab
element :security_counter
end
view 'app/assets/javascripts/reports/components/report_item.vue' do
element :report_item_row
end
view 'app/assets/javascripts/reports/components/issue_status_icon.vue' do
element :icon_status, ':data-qa-selector="`status_${status}_icon`" ' # rubocop:disable QA/ElementWithPattern
module QA::EE
module Page::Project
module Pipeline
module Show
include Page::Component::LicenseManagement
def self.prepended(page)
page.module_eval do
view 'ee/app/views/projects/pipelines/_tabs_holder.html.haml' do
element :security_tab
element :security_counter
element :licenses_tab
element :licenses_counter
end
view 'ee/app/assets/javascripts/security_dashboard/components/filter.vue' do
element :filter_dropdown, ':data-qa-selector="qaSelector"' # rubocop:disable QA/ElementWithPattern
element :filter_dropdown_content
end
view 'ee/app/views/projects/pipelines/_tabs_holder.html.haml' do
element :security_tab
element :security_counter
end
end
end
end
def click_on_security
click_element(:security_tab)
end
def has_vulnerability_count_of?(count)
find_element(:security_counter).has_content?(count)
end
def filter_report_type(report)
click_element(:filter_report_type_dropdown)
within_element(:filter_dropdown_content) do
click_on report
def click_on_security
click_element(:security_tab)
end
# Click the dropdown to close the modal and ensure it isn't open if this function is called again
click_element(:filter_report_type_dropdown)
end
def click_on_licenses
click_element(:licenses_tab)
end
def has_vulnerability_count_of?(count)
find_element(:security_counter).has_content?(count)
end
def has_license_count_of?(count)
find_element(:licenses_counter).has_content?(count)
end
def filter_report_type(report)
click_element(:filter_report_type_dropdown)
within_element(:filter_dropdown_content) do
click_on report
end
# Click the dropdown to close the modal and ensure it isn't open if this function is called again
click_element(:filter_report_type_dropdown)
end
def has_approved_license?(name)
within_element(:report_item_row, text: name) do
has_element?(:status_success_icon)
def click_on_licenses
click_element(:licenses_tab)
end
end
def has_blacklisted_license?(name)
within_element(:report_item_row, text: name) do
has_element?(:status_failed_icon)
def has_license_count_of?(count)
find_element(:licenses_counter).has_content?(count)
end
end
end
......
......@@ -7,6 +7,10 @@ module QA::Page
element :pipeline_link, 'class="js-pipeline-url-link' # rubocop:disable QA/ElementWithPattern
end
view 'app/assets/javascripts/pipelines/components/pipelines_table_row.vue' do
element :pipeline_commit_status
end
def click_on_latest_pipeline
css = '.js-pipeline-url-link'
......@@ -16,6 +20,14 @@ module QA::Page
link.click
end
def wait_for_latest_pipeline_success
wait(reload: false, max: 300) do
within_element_by_index(:pipeline_commit_status, 0) do
has_text?('passed')
end
end
end
end
end
end
# frozen_string_literal: true
require 'pathname'
module QA
context 'Secure', :docker do
describe 'License merge request widget' do
let(:approved_license_name) { "MIT" }
let(:blacklisted_license_name) { "Zlib" }
let(:executor) {"qa-runner-#{Time.now.to_i}"}
after do
Service::DockerRun::GitlabRunner.new(executor).remove!
end
before do
Flow::Login.sign_in
@project = Resource::Project.fabricate_via_api! do |project|
project.name = 'license-widget-project'
project.description = 'License widget test'
end
Resource::Runner.fabricate! do |runner|
runner.project = @project
runner.name = executor
runner.tags = %w[qa test]
end
Resource::Repository::ProjectPush.fabricate! do |project_push|
project_push.project = @project
project_push.directory = Pathname
.new(__dir__)
.join('../../../../../ee/fixtures/secure_license_files')
project_push.commit_message = 'Create license file'
end
@project.visit!
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:wait_for_latest_pipeline_success)
@merge_request = Resource::MergeRequest.fabricate_via_api! do |mr|
mr.project = @project
mr.source_branch = 'license-management-mr'
mr.target_branch = 'master'
mr.target = 'master'
mr.file_name = 'gl-license-management-report.json'
mr.file_content =
<<~FILE_UPDATE
{
"licenses": [
{
"count": 1,
"name": "WTFPL"
},
{
"count": 1,
"name": "MIT"
},
{
"count": 1,
"name": "Zlib"
}
]
}
FILE_UPDATE
mr.target_new_branch = false
end
@project.visit!
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:wait_for_latest_pipeline_success)
end
it 'manage licenses from the merge request' do
@merge_request.visit!
Page::MergeRequest::Show.perform do |show|
show.approve_license_with_mr(approved_license_name)
show.blacklist_license_with_mr(blacklisted_license_name)
expect(show).to have_approved_license approved_license_name
expect(show).to have_blacklisted_license blacklisted_license_name
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