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 { ...@@ -265,7 +265,11 @@ export default {
<div class="table-section section-10 commit-link"> <div class="table-section section-10 commit-link">
<div class="table-mobile-header" role="rowheader">{{ s__('Pipeline|Status') }}</div> <div class="table-mobile-header" role="rowheader">{{ s__('Pipeline|Status') }}</div>
<div class="table-mobile-content"> <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>
</div> </div>
......
...@@ -45,6 +45,7 @@ export default { ...@@ -45,6 +45,7 @@ export default {
id="modal-set-license-approval" id="modal-set-license-approval"
:header-title-text="headerTitleText" :header-title-text="headerTitleText"
modal-size="lg" modal-size="lg"
data-qa-selector="license_management_modal"
@cancel="resetLicenseInModal" @cancel="resetLicenseInModal"
> >
<slot v-if="currentLicenseInModal"> <slot v-if="currentLicenseInModal">
...@@ -93,6 +94,7 @@ export default { ...@@ -93,6 +94,7 @@ export default {
v-if="canBlacklist" v-if="canBlacklist"
class="btn btn-remove btn-inverted js-modal-secondary-action" class="btn btn-remove btn-inverted js-modal-secondary-action"
data-dismiss="modal" data-dismiss="modal"
data-qa-selector="blacklist_license_button"
@click="blacklistLicense(currentLicenseInModal)" @click="blacklistLicense(currentLicenseInModal)"
> >
{{ s__('LicenseCompliance|Blacklist license') }} {{ s__('LicenseCompliance|Blacklist license') }}
...@@ -102,6 +104,7 @@ export default { ...@@ -102,6 +104,7 @@ export default {
type="button" type="button"
class="btn btn-success js-modal-primary-action" class="btn btn-success js-modal-primary-action"
data-dismiss="modal" data-dismiss="modal"
data-qa-selector="approve_license_button"
@click="approveLicense(currentLicenseInModal)" @click="approveLicense(currentLicenseInModal)"
> >
{{ s__('LicenseCompliance|Approve license') }} {{ s__('LicenseCompliance|Approve license') }}
......
...@@ -136,6 +136,7 @@ export default { ...@@ -136,6 +136,7 @@ export default {
:class="reportSectionClass" :class="reportSectionClass"
:always-open="alwaysOpen" :always-open="alwaysOpen"
class="license-report-widget mr-report" class="license-report-widget mr-report"
data-qa-selector="license_report_widget"
> >
<template #success> <template #success>
{{ licenseSummaryText }} {{ licenseSummaryText }}
......
...@@ -14,6 +14,7 @@ module QA ...@@ -14,6 +14,7 @@ module QA
module Page module Page
module Component module Component
autoload :DesignManagement, 'qa/ee/page/component/design_management' autoload :DesignManagement, 'qa/ee/page/component/design_management'
autoload :LicenseManagement, 'qa/ee/page/component/license_management'
module IssueBoard module IssueBoard
autoload :Show, 'qa/ee/page/component/issue_board/show' 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 ...@@ -5,6 +5,8 @@ module QA
module Page module Page
module MergeRequest module MergeRequest
module Show module Show
include Page::Component::LicenseManagement
def self.prepended(page) def self.prepended(page)
page.module_eval do page.module_eval do
view 'app/assets/javascripts/vue_merge_request_widget/components/states/sha_mismatch.vue' do view 'app/assets/javascripts/vue_merge_request_widget/components/states/sha_mismatch.vue' do
...@@ -114,6 +116,28 @@ module QA ...@@ -114,6 +116,28 @@ module QA
check_element :unresolve_review_discussion_checkbox check_element :unresolve_review_discussion_checkbox
end 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 def expand_vulnerability_report
within_element :vulnerability_report_grouped do within_element :vulnerability_report_grouped do
click_element :expand_report_button click_element :expand_report_button
......
# frozen_string_literal: true # frozen_string_literal: true
module QA::EE::Page module QA::EE
module Project::Pipeline module Page::Project
module Show module Pipeline
def self.prepended(page) module Show
page.module_eval do include Page::Component::LicenseManagement
view 'ee/app/views/projects/pipelines/_tabs_holder.html.haml' do
element :security_tab def self.prepended(page)
element :security_counter page.module_eval do
element :licenses_tab view 'ee/app/views/projects/pipelines/_tabs_holder.html.haml' do
element :licenses_counter element :security_tab
end element :security_counter
element :licenses_tab
view 'ee/app/assets/javascripts/security_dashboard/components/filter.vue' do element :licenses_counter
element :filter_dropdown, ':data-qa-selector="qaSelector"' # rubocop:disable QA/ElementWithPattern end
element :filter_dropdown_content
end view 'ee/app/assets/javascripts/security_dashboard/components/filter.vue' do
element :filter_dropdown, ':data-qa-selector="qaSelector"' # rubocop:disable QA/ElementWithPattern
view 'ee/app/views/projects/pipelines/_tabs_holder.html.haml' do element :filter_dropdown_content
element :security_tab end
element :security_counter
end view 'ee/app/views/projects/pipelines/_tabs_holder.html.haml' do
element :security_tab
view 'app/assets/javascripts/reports/components/report_item.vue' do element :security_counter
element :report_item_row end
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 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) def click_on_security
click_element(:filter_report_type_dropdown) click_element(:security_tab)
within_element(:filter_dropdown_content) do
click_on report
end 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 def has_vulnerability_count_of?(count)
click_element(:licenses_tab) find_element(:security_counter).has_content?(count)
end end
def has_license_count_of?(count) def filter_report_type(report)
find_element(:licenses_counter).has_content?(count) click_element(:filter_report_type_dropdown)
end 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) def click_on_licenses
within_element(:report_item_row, text: name) do click_element(:licenses_tab)
has_element?(:status_success_icon)
end end
end
def has_blacklisted_license?(name) def has_license_count_of?(count)
within_element(:report_item_row, text: name) do find_element(:licenses_counter).has_content?(count)
has_element?(:status_failed_icon)
end end
end end
end end
......
...@@ -7,6 +7,10 @@ module QA::Page ...@@ -7,6 +7,10 @@ module QA::Page
element :pipeline_link, 'class="js-pipeline-url-link' # rubocop:disable QA/ElementWithPattern element :pipeline_link, 'class="js-pipeline-url-link' # rubocop:disable QA/ElementWithPattern
end end
view 'app/assets/javascripts/pipelines/components/pipelines_table_row.vue' do
element :pipeline_commit_status
end
def click_on_latest_pipeline def click_on_latest_pipeline
css = '.js-pipeline-url-link' css = '.js-pipeline-url-link'
...@@ -16,6 +20,14 @@ module QA::Page ...@@ -16,6 +20,14 @@ module QA::Page
link.click link.click
end 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 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