Skip to content
Snippets Groups Projects
Unverified Commit 42c75988 authored by Leaminn Ma's avatar Leaminn Ma Committed by GitLab
Browse files

Merge branch '486713-add-feature-tests-for-scen-execution-policies' into 'master'

parents 4f9ad401 1790d3ed
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -137,7 +137,12 @@ export default {
<template>
<div class="gl-mb-4">
<div class="gl-mb-4 gl-grid gl-gap-6 md:gl-grid-cols-2" data-testid="policy-selection-wizard">
<gl-card v-for="option in policies" :key="option.title" body-class="gl-p-6 gl-flex gl-grow">
<gl-card
v-for="option in policies"
:key="option.title"
body-class="gl-p-6 gl-flex gl-grow"
:data-testid="`${option.urlParameter}-card`"
>
<div class="gl-mr-6 gl-text-white">
<img :alt="option.title" aria-hidden="true" :src="option.imageSrc" />
</div>
Loading
Loading
Loading
Loading
@@ -17,7 +17,7 @@
)
end
 
it_behaves_like 'policy editor' do
it_behaves_like 'merge request approval policy editor' do
let(:path_to_policy_editor) { new_group_security_policy_path(group) }
end
end
Loading
Loading
@@ -3,6 +3,7 @@
require 'spec_helper'
 
RSpec.describe "User creates security policy", :js, feature_category: :security_policy_management do
include Features::SourceEditorSpecHelpers
include ListboxHelpers
 
let_it_be(:owner) { create(:user, :with_namespace) }
Loading
Loading
@@ -17,7 +18,36 @@
)
end
 
it_behaves_like 'policy editor' do
context 'for a merge request approval policy' do
it_behaves_like 'merge request approval policy editor' do
let(:path_to_policy_editor) { new_project_security_policy_path(project) }
end
end
context 'for a scan execution policy' do
let(:path_to_policy_editor) { new_project_security_policy_path(project) }
before do
sign_in(owner)
stub_licensed_features(security_orchestration_policies: true)
visit(path_to_policy_editor)
within_testid("scan_execution_policy-card") do
click_link _('Select policy')
end
end
it "can create a valid policy when a policy project exists" do
fill_in _('Name'), with: 'Run secret detection scan on every branch'
click_button _('Configure with a merge request')
expect(page).to have_current_path(project_merge_request_path(policy_management_project, 1))
end
it "cannot create an invalid policy" do
click_button _('.yaml mode')
editor_set_value('invalid: policy')
click_button _('Configure with a merge request')
expect(page).to have_current_path("#{path_to_policy_editor}?type=scan_execution_policy")
expect(page).to have_text(_('Empty policy name'))
end
end
end
Loading
Loading
@@ -25,7 +25,7 @@
 
# Requires the url to the policy editor:
# - path_to_policy_editor
RSpec.shared_examples 'policy editor' do
RSpec.shared_examples 'merge request approval policy editor' do
before do
sign_in(owner)
stub_licensed_features(security_orchestration_policies: true)
Loading
Loading
@@ -33,13 +33,13 @@
 
it "can create a policy when a policy project exists" do
visit(path_to_policy_editor)
page.within(".gl-card:nth-child(1)") do
within_testid("approval_policy-card") do
click_link _('Select policy')
end
fill_in _('Name'), with: 'Prevent vulnerabilities'
click_button _('Select scan type')
select_listbox_item _('Security Scan')
page.within(find_by_testid('actions-section')) do
within_testid('actions-section') do
click_button _('Remove'), match: :first
end
click_button _('Configure with a merge request')
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