Commit cc88dc11 authored by Alexander Turinske's avatar Alexander Turinske

Remove unnecessary html from policy drawer

- unnest policy drawer elements unnecessarily
- udpate tests
parent 60fefed9
...@@ -47,33 +47,30 @@ export default { ...@@ -47,33 +47,30 @@ export default {
<template> <template>
<div> <div>
<p data-testid="policy-summary"> <div data-testid="policy-summary">
<slot name="summary"></slot> <slot name="summary"></slot>
</p> </div>
<h5 class="gl-mt-3">{{ $options.i18n.policyTypeTitle }}</h5> <policy-info-row data-testid="policy-type" :label="$options.i18n.policyTypeTitle">
<p data-testid="policy-type">{{ type }}</p> {{ type }}
</policy-info-row>
<p data-testid="policy-description"> <policy-info-row :label="$options.i18n.descriptionTitle">
<policy-info-row :label="$options.i18n.descriptionTitle"> <div v-if="description" data-testid="custom-description-text">
<div v-if="description" data-testid="custom-description-text"> {{ description }}
{{ description }} </div>
</div> <div v-else class="gl-text-gray-500" data-testid="default-description-text">
<div v-else class="gl-text-gray-500" data-testid="default-description-text"> {{ $options.i18n.defaultDescription }}
{{ $options.i18n.defaultDescription }} </div>
</div> </policy-info-row>
</policy-info-row>
</p>
<p data-testid="policy-status"> <policy-info-row :label="$options.i18n.statusTitle">
<policy-info-row :label="$options.i18n.statusTitle"> <div v-if="policy.enabled" class="gl-text-green-500" data-testid="enabled-status-text">
<div v-if="policy.enabled" class="gl-text-green-500" data-testid="enabled-status-text"> <gl-icon name="check-circle-filled" class="gl-mr-3" />{{ statusLabel }}
<gl-icon name="check-circle-filled" class="gl-mr-3" />{{ statusLabel }} </div>
</div> <div v-else class="gl-text-gray-500" data-testid="not-enabled-status-text">
<div v-else class="gl-text-gray-500" data-testid="not-enabled-status-text"> {{ statusLabel }}
{{ statusLabel }} </div>
</div> </policy-info-row>
</policy-info-row>
</p>
</div> </div>
</template> </template>
...@@ -12,7 +12,7 @@ describe('PolicyDrawerLayout component', () => { ...@@ -12,7 +12,7 @@ describe('PolicyDrawerLayout component', () => {
const DESCRIPTION = 'This policy enforces pipeline configuration to have a job with DAST scan'; const DESCRIPTION = 'This policy enforces pipeline configuration to have a job with DAST scan';
const SUMMARY = 'Summary'; const SUMMARY = 'Summary';
const TYPE = 'Policy Type'; const TYPE = 'Scan Execution';
const findCustomDescription = () => wrapper.findByTestId('custom-description-text'); const findCustomDescription = () => wrapper.findByTestId('custom-description-text');
const findDefaultDescription = () => wrapper.findByTestId('default-description-text'); const findDefaultDescription = () => wrapper.findByTestId('default-description-text');
......
...@@ -6,7 +6,6 @@ import { mockScanResultPolicy } from '../../mocks/mock_data'; ...@@ -6,7 +6,6 @@ import { mockScanResultPolicy } from '../../mocks/mock_data';
describe('ScanResultPolicy component', () => { describe('ScanResultPolicy component', () => {
let wrapper; let wrapper;
const findDescription = () => wrapper.findByTestId('policy-description');
const findRules = () => wrapper.findByTestId('policy-rules'); const findRules = () => wrapper.findByTestId('policy-rules');
const factory = ({ propsData } = {}) => { const factory = ({ propsData } = {}) => {
...@@ -27,16 +26,8 @@ describe('ScanResultPolicy component', () => { ...@@ -27,16 +26,8 @@ describe('ScanResultPolicy component', () => {
factory({ propsData: { policy: mockScanResultPolicy } }); factory({ propsData: { policy: mockScanResultPolicy } });
}); });
it.each` it('does render the policy rules', () => {
component | finder | text expect(findRules().exists()).toBe(true);
${'rules'} | ${findRules} | ${''}
${'description'} | ${findDescription} | ${'This policy enforces critical vulnerability CS approvals'}
`('does render the policy $component', ({ finder, text }) => {
const component = finder();
expect(component.exists()).toBe(true);
if (text) {
expect(component.text()).toBe(text);
}
}); });
}); });
}); });
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