Add e2e test to ensure policies appear in settings/merge request
Why are we doing this work
- there is no test coverage to ensure that policies created show up in the settings => merge requests => Security approvals
Relevant links
Non-functional requirements
-
Documentation: -
Feature flag: -
Performance: -
Testing:
Implementation plan
-
Create a test that verifies that when a user creates a policy, it shows up in the project's merge request settings
===================================================================
diff --git a/ee/spec/features/admin/admin_merge_requests_approvals_spec.rb b/ee/spec/features/admin/admin_merge_requests_approvals_spec.rb
--- a/ee/spec/features/admin/admin_merge_requests_approvals_spec.rb (revision 21bad30927a931ea6e0820c5434b7ea5913c7eae)
+++ b/ee/spec/features/admin/admin_merge_requests_approvals_spec.rb (date 1697562392882)
@@ -40,4 +40,27 @@
expect(find('[data-testid="prevent-mr-approval-rule-edit"] > input')).to be_disabled.and be_checked
end
end
+
+ context 'when project has security policies' do
+ let_it_be(:policy_management_project) { create(:project, :repository, namespace: user.namespace) }
+
+ before do
+ project.add_developer(user)
+ policy_management_project.add_developer(user)
+ stub_licensed_features(security_orchestration_policies: true)
+ allow_next_instance_of(Repository) do |repository|
+ allow(repository).to receive(:blob_data_at).and_return({ scan_execution_policy: [policy] }.to_yaml)
+ end
+ end
+
+ let_it_be(:policy) { build(:scan_result_policy) }
+
+ it 'shows the security approvals', :js do
+ visit project_settings_merge_requests_path(project)
+
+ expect(page).to have_content('Security Approvals')
+ expect(page).to have_content('Create more robust vulnerability rules and apply them to all your projects.')
+ expect(page).to have_content(policy.name)
+ end
+ end
end
Verification steps
Edited by Marcos Rocha