Commit 254e70eb authored by Alexander Turinske's avatar Alexander Turinske

Update security policies end to end tests

- create navigation to Policies page
- move tests for policies from Threat Monitoring page
  to Policies page
- add test for policy editor
parent cbc1b00b
......@@ -101,7 +101,12 @@ export default {
>
{{ $options.i18n.editPolicyProjectButtonText }}
</gl-button>
<gl-button data-testid="new-policy-button" variant="confirm" :href="newPolicyPath">
<gl-button
data-testid="new-policy-button"
data-qa-selector="new_policy_button"
variant="confirm"
:href="newPolicyPath"
>
{{ $options.i18n.newPolicyButtonText }}
</gl-button>
<scan-new-policy-modal
......
......@@ -283,6 +283,7 @@ export default {
<gl-table
ref="policiesTable"
data-qa-selector="policies_list"
:busy="isLoadingPolicies"
:items="policies"
:fields="fields"
......
......@@ -88,6 +88,7 @@ export default {
<gl-form-group :label="s__('SecurityOrchestration|Policy type')" label-for="policyType">
<gl-form-select
id="policyType"
data-qa-selector="policy_type_form_select"
:value="policyOptions.value"
:options="policyTypes"
:disabled="!shouldAllowPolicyTypeSelection"
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Policies
class Index < QA::Page::Base
view 'ee/app/assets/javascripts/threat_monitoring/components/policies/policies_list.vue' do
element :policies_list
end
view 'ee/app/assets/javascripts/threat_monitoring/components/policies/policies_header.vue' do
element :new_policy_button
end
def policies_list?
has_element?(:policies_list)
end
def click_new_policy_button
within_element(:policies_container) do
click_element(:new_policy_button)
end
end
end
end
end
end
end
end
......@@ -30,6 +30,14 @@ module QA
end
end
def click_on_policies
hover_security_compliance do
within_submenu do
click_element(:sidebar_menu_item_link, menu_item: 'Policies')
end
end
end
def click_on_vulnerability_report
hover_security_compliance do
within_submenu do
......
......@@ -8,13 +8,11 @@ module QA
class Index < QA::Page::Base
TAB_INDEX = {
alerts: 1,
policies: 2,
statistics: 3 # it hasn't been added yet
statistics: 2 # it hasn't been added yet
}.freeze
view 'ee/app/assets/javascripts/threat_monitoring/components/app.vue' do
element :alerts_tab
element :policies_tab
element :threat_monitoring_container
end
......@@ -22,16 +20,6 @@ module QA
has_element?(:alerts_tab)
end
def has_policies_tab?
has_element?(:policies_tab)
end
def click_policies_tab
within_element(:threat_monitoring_container) do
find(tab_element_for(:policies)).click
end
end
private
def tab_element_for(tab_name)
......
......@@ -2,7 +2,7 @@
module QA
RSpec.describe 'Protect' do
describe 'Threat Monitoring Policy List page' do
describe 'Policies List page' do
let!(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = Runtime::Env.auto_devops_project_name || 'project-with-protect'
......@@ -23,13 +23,24 @@ module QA
project.visit!
end
it 'can load Threat Monitoring page and view the policy alert list', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1892' do
Page::Project::Menu.perform(&:click_on_threat_monitoring)
it 'can load Policies page and view the policies list', :smoke, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1892' do
Page::Project::Menu.perform(&:click_on_policies)
EE::Page::Project::ThreatMonitoring::AlertsList.perform do |alerts_list|
EE::Page::Project::Policies.perform do |policies_list|
aggregate_failures do
expect(alerts_list).to have_alerts_tab
expect(alerts_list).to have_alerts_list
expect(policies_list).to have_policies_list
end
end
end
it 'can navigate to Policy Editor page', :smoke, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1892' do
Page::Project::Menu.perform(&:click_on_policies)
EE::Page::Project::Policies.perform(&:click_new_policy_button)
EE::Page::Project::Policies.perform do |policy_editor|
aggregate_failures do
expect(policies_editor).to have_policy_type_form_select
end
end
end
......@@ -64,7 +75,7 @@ module QA
cluster.remove!
end
it 'loads a sample network policy under policies tab on the Threat Monitoring page', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1925' do
it 'loads a sample network policy under policies page', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1925' do
Resource::KubernetesCluster::ProjectCluster.fabricate_via_browser_ui! do |k8s_cluster|
k8s_cluster.project = project
k8s_cluster.cluster = cluster
......@@ -87,11 +98,10 @@ module QA
cluster.add_sample_policy(project, policy_name: policy_name)
Page::Project::Menu.perform(&:click_on_threat_monitoring)
EE::Page::Project::ThreatMonitoring::Index.perform do |index|
index.click_policies_tab
Page::Project::Menu.perform(&:click_on_policies)
EE::Page::Project::Policies::Index.perform do |index|
aggregate_failures do
expect(index).to have_policies_tab
expect(policies_list).to have_policies_list
expect(index.has_content?(policy_name)).to be true
end
end
......
# frozen_string_literal: true
module QA
RSpec.describe 'Protect' do
describe 'Threat Monitoring Policy Alert List page' do
let!(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = Runtime::Env.auto_devops_project_name || 'project-with-protect'
project.description = 'Project with Protect'
project.auto_devops_enabled = true
project.initialize_with_readme = true
project.template_name = 'express'
end
end
after do
project.remove_via_api!
end
context 'without k8s cluster' do
before do
Flow::Login.sign_in
project.visit!
end
it 'can load Threat Monitoring page and view the policy alert list', :smoke, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/quality/test_cases/1892' do
Page::Project::Menu.perform(&:click_on_threat_monitoring)
EE::Page::Project::ThreatMonitoring::AlertsList.perform do |alerts_list|
aggregate_failures do
expect(alerts_list).to have_alerts_tab
expect(alerts_list).to have_alerts_list
end
end
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