Commit cd0b8533 authored by Alexander Turinske's avatar Alexander Turinske

Fix editing of scan execution policies

- update `isEditing` computed property
- update tests
parent de200ba4
...@@ -40,7 +40,10 @@ export default { ...@@ -40,7 +40,10 @@ export default {
return this.isEditing ? this.policyType : this.newPolicyType; return this.isEditing ? this.policyType : this.newPolicyType;
}, },
isEditing() { isEditing() {
return Boolean(this.existingPolicy?.creation_timestamp || this.existingPolicy?.updatedAt); return Boolean(
this.existingPolicy?.creation_timestamp ||
this.existingPolicy?.type === POLICY_TYPE_COMPONENT_OPTIONS.scanExecution.urlParameter,
);
}, },
policyTypes() { policyTypes() {
return Object.values(POLICY_TYPE_COMPONENT_OPTIONS); return Object.values(POLICY_TYPE_COMPONENT_OPTIONS);
......
...@@ -93,9 +93,9 @@ describe('PolicyEditor component', () => { ...@@ -93,9 +93,9 @@ describe('PolicyEditor component', () => {
describe('when an existing policy is present', () => { describe('when an existing policy is present', () => {
it.each` it.each`
policyType | option | existingPolicy | findComponent policyType | option | existingPolicy | findComponent
${'container_policy'} | ${POLICY_TYPE_COMPONENT_OPTIONS.container} | ${{ manifest: mockL3Manifest, updatedAt: '2020-04-14T00:08:30Z' }} | ${findNeworkPolicyEditor} ${'container_policy'} | ${POLICY_TYPE_COMPONENT_OPTIONS.container} | ${{ manifest: mockL3Manifest, creation_timestamp: '2020-04-14T00:08:30Z' }} | ${findNeworkPolicyEditor}
${'scan_execution_policy'} | ${POLICY_TYPE_COMPONENT_OPTIONS.scanExecution} | ${mockDastScanExecutionObject} | ${findScanExecutionPolicyEditor} ${'scan_execution_policy'} | ${POLICY_TYPE_COMPONENT_OPTIONS.scanExecution} | ${mockDastScanExecutionObject} | ${findScanExecutionPolicyEditor}
`( `(
'renders the disabled form select for existing policy of type $policyType', 'renders the disabled form select for existing policy of type $policyType',
async ({ existingPolicy, findComponent, option, policyType }) => { async ({ existingPolicy, findComponent, option, policyType }) => {
......
...@@ -6,6 +6,6 @@ import { ...@@ -6,6 +6,6 @@ import {
describe('fromYaml', () => { describe('fromYaml', () => {
it('returns policy object', () => { it('returns policy object', () => {
expect(fromYaml(mockDastScanExecutionManifest)).toMatchObject(mockDastScanExecutionObject); expect(fromYaml(mockDastScanExecutionManifest)).toStrictEqual(mockDastScanExecutionObject);
}); });
}); });
...@@ -23,7 +23,6 @@ rules: ...@@ -23,7 +23,6 @@ rules:
- type: pipeline - type: pipeline
branches: branches:
- main - main
updatedAt: '2020-04-14T00:08:30Z'
actions: actions:
- scan: dast - scan: dast
site_profile: required_site_profile site_profile: required_site_profile
...@@ -36,7 +35,6 @@ export const mockDastScanExecutionObject = { ...@@ -36,7 +35,6 @@ export const mockDastScanExecutionObject = {
description: 'This policy enforces pipeline configuration to have a job with DAST scan', description: 'This policy enforces pipeline configuration to have a job with DAST scan',
enabled: false, enabled: false,
rules: [{ type: 'pipeline', branches: ['main'] }], rules: [{ type: 'pipeline', branches: ['main'] }],
updatedAt: '2020-04-14T00:08:30Z',
actions: [ actions: [
{ {
scan: 'dast', scan: 'dast',
......
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