diff --git a/ee/app/assets/javascripts/threat_monitoring/components/policies/policies_header.vue b/ee/app/assets/javascripts/threat_monitoring/components/policies/policies_header.vue index 28e7c378728e2664db880e7788e6f94dee7571ab..d77970682f4d72a5324115cff543ac528c94e4d3 100644 --- a/ee/app/assets/javascripts/threat_monitoring/components/policies/policies_header.vue +++ b/ee/app/assets/javascripts/threat_monitoring/components/policies/policies_header.vue @@ -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 diff --git a/ee/app/assets/javascripts/threat_monitoring/components/policies/policies_list.vue b/ee/app/assets/javascripts/threat_monitoring/components/policies/policies_list.vue index 65cd77a7e9b9e213ab0b6b2be10ec1091a9fa7d2..85af952b12112bd9a7e45d9973deea1896978e7b 100644 --- a/ee/app/assets/javascripts/threat_monitoring/components/policies/policies_list.vue +++ b/ee/app/assets/javascripts/threat_monitoring/components/policies/policies_list.vue @@ -283,6 +283,7 @@ export default { <gl-table ref="policiesTable" + data-qa-selector="policies_list" :busy="isLoadingPolicies" :items="policies" :fields="fields" diff --git a/ee/app/assets/javascripts/threat_monitoring/components/policy_editor/policy_editor.vue b/ee/app/assets/javascripts/threat_monitoring/components/policy_editor/policy_editor.vue index 2992d1a32f314ef71e1ff48e6244388a2ca04282..f63eb082ff2a8ab77fd2dc114597f0e54a5ee010 100644 --- a/ee/app/assets/javascripts/threat_monitoring/components/policy_editor/policy_editor.vue +++ b/ee/app/assets/javascripts/threat_monitoring/components/policy_editor/policy_editor.vue @@ -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" diff --git a/qa/qa/ee/page/project/policies/index.rb b/qa/qa/ee/page/project/policies/index.rb new file mode 100644 index 0000000000000000000000000000000000000000..aef864cc93f82101567f1e474737445b67b20d1e --- /dev/null +++ b/qa/qa/ee/page/project/policies/index.rb @@ -0,0 +1,31 @@ +# 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 diff --git a/qa/qa/ee/page/project/sub_menus/security_compliance.rb b/qa/qa/ee/page/project/sub_menus/security_compliance.rb index 4bdf91e22ac17c1156eccde7c3b0d8694fd2671a..6dab2d2cc7de83a13346913098514d35548e5c22 100644 --- a/qa/qa/ee/page/project/sub_menus/security_compliance.rb +++ b/qa/qa/ee/page/project/sub_menus/security_compliance.rb @@ -30,6 +30,14 @@ def click_on_threat_monitoring 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 diff --git a/qa/qa/ee/page/project/threat_monitoring/index.rb b/qa/qa/ee/page/project/threat_monitoring/index.rb index ebb99540d705ec6b730e359041f5a088cc12e552..117e6d05e97f643fe8f497211f6087ca761b9b10 100644 --- a/qa/qa/ee/page/project/threat_monitoring/index.rb +++ b/qa/qa/ee/page/project/threat_monitoring/index.rb @@ -8,13 +8,11 @@ module ThreatMonitoring 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 @@ def has_alerts_tab? 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) diff --git a/qa/qa/specs/features/ee/browser_ui/10_protect/policy_list_spec.rb b/qa/qa/specs/features/ee/browser_ui/10_protect/policies_list_spec.rb similarity index 68% rename from qa/qa/specs/features/ee/browser_ui/10_protect/policy_list_spec.rb rename to qa/qa/specs/features/ee/browser_ui/10_protect/policies_list_spec.rb index 0499def700eac6ac104ed42161592e08112446de..b2837687ea0bc1463ee26120a1ebfd317a58159f 100644 --- a/qa/qa/specs/features/ee/browser_ui/10_protect/policy_list_spec.rb +++ b/qa/qa/specs/features/ee/browser_ui/10_protect/policies_list_spec.rb @@ -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 diff --git a/qa/qa/specs/features/ee/browser_ui/10_protect/policy_alerts_list_spec.rb b/qa/qa/specs/features/ee/browser_ui/10_protect/policy_alerts_list_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..82d0dd1c2fded57245b740083e6d3fff2de93726 --- /dev/null +++ b/qa/qa/specs/features/ee/browser_ui/10_protect/policy_alerts_list_spec.rb @@ -0,0 +1,39 @@ +# 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