Skip to content
Snippets Groups Projects
Commit 01990faa authored by Andrejs Cunskis's avatar Andrejs Cunskis
Browse files

Merge branch 'deq_license_specs_ff' into 'master'

Dequarantine License Compliance specs

See merge request gitlab-org/gitlab!87659
parents ad0d820d 3589125d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -31,11 +31,19 @@ module QA
end
end
 
def approve_license(license, selector = :approved_license_radio)
# Remove when feature flag lc_remove_legacy_approval_status no longer used
def has_ff_allowed_license_radio?
feature_flag_controlled_element(:lc_remove_legacy_approval_status,
:allowed_license_radio,
:approved_license_radio,
true)
end
def approve_license(license)
click_element(:license_add_button)
expand_select_list
search_and_select_exact(license)
choose_element(selector, true)
choose_element(has_ff_allowed_license_radio?, true)
click_element(:add_license_submit_button)
 
has_approved_license?(license)
Loading
Loading
@@ -48,11 +56,19 @@ module QA
end
end
 
def deny_license(license, selector = :blacklisted_license_radio)
# Remove when feature flag lc_remove_legacy_approval_status no longer used
def has_ff_denied_license_button?
feature_flag_controlled_element(:lc_remove_legacy_approval_status,
:denied_license_radio,
:denied_license_radio,
true)
end
def deny_license(license)
click_element(:license_add_button)
expand_select_list
search_and_select_exact(license)
choose_element(selector, true)
choose_element(has_ff_denied_license_button?, true)
click_element(:add_license_submit_button)
 
has_denied_license?(license)
Loading
Loading
Loading
Loading
@@ -461,7 +461,7 @@ module QA
click_by_js ? page.execute_script("arguments[0].click();", box) : box.click
end
 
def feature_flag_controlled_element(feature_flag, element_when_flag_enabled, element_when_flag_disabled)
def feature_flag_controlled_element(feature_flag, element_when_flag_enabled, element_when_flag_disabled, visibility = true)
# Feature flags can change the UI elements shown, but we need admin access to get feature flag values, which
# prevents us running the tests on production. Instead we detect the UI element that should be shown when the
# feature flag is enabled and otherwise use the element that should be displayed when the feature flag is
Loading
Loading
@@ -472,12 +472,12 @@ module QA
# load and render the UI
wait_for_requests
 
return element_when_flag_enabled if has_element?(element_when_flag_enabled, wait: 1)
return element_when_flag_disabled if has_element?(element_when_flag_disabled, wait: 1)
return element_when_flag_enabled if has_element?(element_when_flag_enabled, wait: 1, visible: visibility)
return element_when_flag_disabled if has_element?(element_when_flag_disabled, wait: 1, visibile: visibility)
 
# Check both options again, this time waiting for the default duration
return element_when_flag_enabled if has_element?(element_when_flag_enabled)
return element_when_flag_disabled if has_element?(element_when_flag_disabled)
return element_when_flag_enabled if has_element?(element_when_flag_enabled, visible: visibility)
return element_when_flag_disabled if has_element?(element_when_flag_disabled, visible: visibility)
 
raise ElementNotFound,
"Could not find the expected element as #{element_when_flag_enabled} or #{element_when_flag_disabled}." \
Loading
Loading
# frozen_string_literal: true
 
module QA
# Leaving :global scope out of feature_flag metadata
# This will allow test to still run in staging since we are only checking if the feature is enabled
RSpec.describe 'Secure', :runner,
feature_flag: { name: 'lc_remove_legacy_approval_status' },
quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/362182', type: :broken } do
RSpec.describe 'Secure', :runner do
describe 'License Compliance' do
before(:all) do
@project = Resource::Project.fabricate_via_api! do |project|
Loading
Loading
@@ -56,7 +52,6 @@ module QA
.join('../../../../../ee/fixtures/secure_premade_reports/gl-license-scanning-report.json')) }]
project_push.commit_message = 'Create Secure compatible application to serve premade reports'
end
remove_legacy_ff_enabled = Runtime::Feature.enabled?(:lc_remove_legacy_approval_status)
Flow::Login.sign_in_unless_signed_in
@project.visit!
Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
Loading
Loading
@@ -64,10 +59,8 @@ module QA
Page::Project::Menu.perform(&:click_on_license_compliance)
EE::Page::Project::Secure::LicenseCompliance.perform do |license_compliance|
license_compliance.open_tab
selector = remove_legacy_ff_enabled ? :allowed_license_radio : :approved_license_radio
license_compliance.approve_license(approved_license_name, selector)
selector = remove_legacy_ff_enabled ? :denied_license_radio : :blacklisted_license_radio
license_compliance.deny_license(denied_license_name, selector)
license_compliance.approve_license(approved_license_name)
license_compliance.deny_license(denied_license_name)
end
end
 
Loading
Loading
# frozen_string_literal: true
 
module QA
# Leaving :global scope out of feature_flag metadata
# This will allow test to still run in staging since we are only checking if the feature is enabled
RSpec.describe 'Secure', :runner,
feature_flag: { name: 'lc_remove_legacy_approval_status' },
quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/362182', type: :broken } do
RSpec.describe 'Secure', :runner do
describe 'License merge request widget' do
let(:approved_license_name) { "MIT License" }
let(:denied_license_name) { "zlib License" }
Loading
Loading
@@ -115,12 +111,8 @@ module QA
 
EE::Page::Project::Secure::LicenseCompliance.perform do |license_compliance|
license_compliance.open_tab
selector = Runtime::Feature.enabled?(:lc_remove_legacy_approval_status) ? :allowed_license_radio : :approved_license_radio
license_compliance.approve_license(approved_license_name, selector)
selector = Runtime::Feature.enabled?(:lc_remove_legacy_approval_status) ? :denied_license_radio : :blacklisted_license_radio
license_compliance.deny_license(denied_license_name, selector)
license_compliance.approve_license(approved_license_name)
license_compliance.deny_license(denied_license_name)
end
 
@merge_request.visit!
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment