Move and rename a few files, cleanup tests

- Renamed PolicyDrawer component to ContainerRuntimePolicy
- Moved NetworkPolicyDrawer to its own sub-directory
- Slightly refactored the specs to make descriptions more meaningful
  and to use findComponent where appropriate
parent ffb5bbdb
...@@ -5,7 +5,7 @@ import { getTimeago } from '~/lib/utils/datetime_utility'; ...@@ -5,7 +5,7 @@ import { getTimeago } from '~/lib/utils/datetime_utility';
import { setUrlFragment, mergeUrlParams } from '~/lib/utils/url_utility'; import { setUrlFragment, mergeUrlParams } from '~/lib/utils/url_utility';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import EnvironmentPicker from './environment_picker.vue'; import EnvironmentPicker from './environment_picker.vue';
import NetworkPolicyDrawer from './network_policy_drawer.vue'; import NetworkPolicyDrawer from './policy_drawer/network_policy_drawer.vue';
export default { export default {
components: { components: {
...@@ -200,6 +200,7 @@ export default { ...@@ -200,6 +200,7 @@ export default {
:policy="selectedPolicy" :policy="selectedPolicy"
:edit-policy-path="editPolicyPath" :edit-policy-path="editPolicyPath"
data-testid="policyDrawer" data-testid="policyDrawer"
@close="deselectPolicy"
/> />
</div> </div>
</template> </template>
<script> <script>
import { GlButton, GlDrawer } from '@gitlab/ui'; import { GlButton, GlDrawer } from '@gitlab/ui';
import { getContentWrapperHeight } from '../utils'; import { getContentWrapperHeight } from '../../utils';
import { CiliumNetworkPolicyKind } from './policy_editor/constants'; import { CiliumNetworkPolicyKind } from '../policy_editor/constants';
import PolicyDrawer from './policy_editor/policy_drawer.vue'; import ContainerRuntimePolicy from '../policy_editor/container_runtime_policy.vue';
export default { export default {
components: { components: {
GlButton, GlButton,
GlDrawer, GlDrawer,
NetworkPolicyEditor: () => NetworkPolicyEditor: () =>
import(/* webpackChunkName: 'network_policy_editor' */ './network_policy_editor.vue'), import(/* webpackChunkName: 'network_policy_editor' */ '../network_policy_editor.vue'),
PolicyDrawer, ContainerRuntimePolicy,
}, },
props: { props: {
policy: { policy: {
...@@ -25,7 +25,7 @@ export default { ...@@ -25,7 +25,7 @@ export default {
}, },
}, },
computed: { computed: {
isCiliumPolicy() { isContainerRuntimePolicy() {
return this.policy ? this.policy.manifest.includes(CiliumNetworkPolicyKind) : false; return this.policy ? this.policy.manifest.includes(CiliumNetworkPolicyKind) : false;
}, },
}, },
...@@ -59,7 +59,7 @@ export default { ...@@ -59,7 +59,7 @@ export default {
</div> </div>
</template> </template>
<div v-if="policy"> <div v-if="policy">
<policy-drawer v-if="isCiliumPolicy" :value="policy.manifest" /> <container-runtime-policy v-if="isContainerRuntimePolicy" :value="policy.manifest" />
<div v-else> <div v-else>
<h5>{{ s__('NetworkPolicies|Policy definition') }}</h5> <h5>{{ s__('NetworkPolicies|Policy definition') }}</h5>
......
...@@ -6,10 +6,10 @@ exports[`NetworkPolicyList component renders policies table 1`] = ` ...@@ -6,10 +6,10 @@ exports[`NetworkPolicyList component renders policies table 1`] = `
<table <table
aria-busy="false" aria-busy="false"
aria-colcount="3" aria-colcount="3"
aria-describedby="__BVID__208__caption_" aria-describedby="__BVID__181__caption_"
aria-multiselectable="false" aria-multiselectable="false"
class="table b-table gl-table table-hover b-table-stacked-md b-table-selectable b-table-select-single" class="table b-table gl-table table-hover b-table-stacked-md b-table-selectable b-table-select-single"
id="__BVID__208" id="__BVID__181"
role="table" role="table"
> >
<!----> <!---->
......
import { GlTable, GlDrawer } from '@gitlab/ui'; import { GlTable, GlDrawer } from '@gitlab/ui';
import NetworkPolicyList from 'ee/threat_monitoring/components/network_policy_list.vue'; import NetworkPolicyList from 'ee/threat_monitoring/components/network_policy_list.vue';
import PolicyDrawer from 'ee/threat_monitoring/components/policy_editor/policy_drawer.vue';
import createStore from 'ee/threat_monitoring/store'; import createStore from 'ee/threat_monitoring/store';
import { mountExtended } from 'helpers/vue_test_utils_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
...@@ -59,10 +58,6 @@ describe('NetworkPolicyList component', () => { ...@@ -59,10 +58,6 @@ describe('NetworkPolicyList component', () => {
expect(button.exists()).toBe(true); expect(button.exists()).toBe(true);
}); });
it('does not render the new policy drawer', () => {
expect(wrapper.find(PolicyDrawer).exists()).toBe(false);
});
it('fetches policies', () => { it('fetches policies', () => {
expect(store.dispatch).toHaveBeenCalledWith('networkPolicies/fetchPolicies', -1); expect(store.dispatch).toHaveBeenCalledWith('networkPolicies/fetchPolicies', -1);
}); });
......
import NetworkPolicyDrawer from 'ee/threat_monitoring/components/network_policy_drawer.vue'; import NetworkPolicyDrawer from 'ee/threat_monitoring/components/policy_drawer/network_policy_drawer.vue';
import PolicyDrawer from 'ee/threat_monitoring/components/policy_editor/policy_drawer.vue'; import ContainerRuntimePolicy from 'ee/threat_monitoring/components/policy_editor/container_runtime_policy.vue';
import { mountExtended } from 'helpers/vue_test_utils_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper';
import { mockPoliciesResponse, mockCiliumPolicy } from '../mocks/mock_data'; import { mockPoliciesResponse, mockCiliumPolicy } from '../../mocks/mock_data';
const [mockGenericPolicy] = mockPoliciesResponse; const [mockGenericPolicy] = mockPoliciesResponse;
...@@ -22,7 +22,7 @@ describe('NetworkPolicyDrawer component', () => { ...@@ -22,7 +22,7 @@ describe('NetworkPolicyDrawer component', () => {
// Finders // Finders
const findEditButton = () => wrapper.findByTestId('edit-button'); const findEditButton = () => wrapper.findByTestId('edit-button');
const findPolicyEditor = () => wrapper.findByTestId('policyEditor'); const findPolicyEditor = () => wrapper.findByTestId('policyEditor');
const findPolicyDrawer = () => wrapper.find(PolicyDrawer); const findCiliumPolicy = () => wrapper.findComponent(ContainerRuntimePolicy);
// Shared assertions // Shared assertions
const itRendersEditButton = () => { const itRendersEditButton = () => {
...@@ -75,8 +75,8 @@ describe('NetworkPolicyDrawer component', () => { ...@@ -75,8 +75,8 @@ describe('NetworkPolicyDrawer component', () => {
}); });
}); });
it('renders the new policy drawer', () => { it('renders the container runtime component', () => {
expect(findPolicyDrawer().exists()).toBe(true); expect(findCiliumPolicy().exists()).toBe(true);
}); });
itRendersEditButton(); itRendersEditButton();
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`PolicyDrawer component supported YAML renders policy preview tabs 1`] = ` exports[`ContainerRuntimePolicy component supported YAML renders policy preview tabs 1`] = `
<div> <div>
<h5 <h5
class="gl-mt-3" class="gl-mt-3"
...@@ -54,7 +54,7 @@ spec: ...@@ -54,7 +54,7 @@ spec:
</div> </div>
`; `;
exports[`PolicyDrawer component unsupported YAML renders policy preview tabs 1`] = ` exports[`ContainerRuntimePolicy component unsupported YAML renders policy preview tabs 1`] = `
<div> <div>
<h5 <h5
class="gl-mt-3" class="gl-mt-3"
......
import ContainerRuntimePolicy from 'ee/threat_monitoring/components/policy_editor/container_runtime_policy.vue';
import toYaml from 'ee/threat_monitoring/components/policy_editor/lib/to_yaml'; import toYaml from 'ee/threat_monitoring/components/policy_editor/lib/to_yaml';
import PolicyDrawer from 'ee/threat_monitoring/components/policy_editor/policy_drawer.vue';
import PolicyPreview from 'ee/threat_monitoring/components/policy_editor/policy_preview.vue'; import PolicyPreview from 'ee/threat_monitoring/components/policy_editor/policy_preview.vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
describe('PolicyDrawer component', () => { describe('ContainerRuntimePolicy component', () => {
let wrapper; let wrapper;
const policy = { const policy = {
name: 'test-policy', name: 'test-policy',
...@@ -17,7 +17,7 @@ describe('PolicyDrawer component', () => { ...@@ -17,7 +17,7 @@ describe('PolicyDrawer component', () => {
const findDescription = () => wrapper.findByTestId('description'); const findDescription = () => wrapper.findByTestId('description');
const factory = ({ propsData } = {}) => { const factory = ({ propsData } = {}) => {
wrapper = shallowMountExtended(PolicyDrawer, { wrapper = shallowMountExtended(ContainerRuntimePolicy, {
propsData: { propsData: {
...propsData, ...propsData,
}, },
......
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