Commit 9f1993a7 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch 'async-import-monaco-component-for-threat-monitoring' into 'master'

Asyncronously import monaco components

See merge request gitlab-org/gitlab!56909
parents 6734df45 24f54bca
...@@ -14,7 +14,6 @@ import { getTimeago } from '~/lib/utils/datetime_utility'; ...@@ -14,7 +14,6 @@ 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 NetworkPolicyEditor from './network_policy_editor.vue';
import { CiliumNetworkPolicyKind } from './policy_editor/constants'; import { CiliumNetworkPolicyKind } from './policy_editor/constants';
import PolicyDrawer from './policy_editor/policy_drawer.vue'; import PolicyDrawer from './policy_editor/policy_drawer.vue';
...@@ -32,7 +31,8 @@ export default { ...@@ -32,7 +31,8 @@ export default {
GlLink, GlLink,
GlToggle, GlToggle,
EnvironmentPicker, EnvironmentPicker,
NetworkPolicyEditor, NetworkPolicyEditor: () =>
import(/* webpackChunkName: 'network_policy_editor' */ './network_policy_editor.vue'),
PolicyDrawer, PolicyDrawer,
}, },
props: { props: {
......
...@@ -16,7 +16,6 @@ import { redirectTo } from '~/lib/utils/url_utility'; ...@@ -16,7 +16,6 @@ import { redirectTo } from '~/lib/utils/url_utility';
import { s__, __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import EnvironmentPicker from '../environment_picker.vue'; import EnvironmentPicker from '../environment_picker.vue';
import NetworkPolicyEditor from '../network_policy_editor.vue';
import { import {
EditorModeRule, EditorModeRule,
EditorModeYAML, EditorModeYAML,
...@@ -49,7 +48,8 @@ export default { ...@@ -49,7 +48,8 @@ export default {
GlAlert, GlAlert,
GlModal, GlModal,
EnvironmentPicker, EnvironmentPicker,
NetworkPolicyEditor, NetworkPolicyEditor: () =>
import(/* webpackChunkName: 'network_policy_editor' */ '../network_policy_editor.vue'),
PolicyRuleBuilder, PolicyRuleBuilder,
PolicyPreview, PolicyPreview,
PolicyActionPicker, PolicyActionPicker,
...@@ -367,6 +367,7 @@ export default { ...@@ -367,6 +367,7 @@ export default {
</h5> </h5>
<div class="gl-p-4"> <div class="gl-p-4">
<network-policy-editor <network-policy-editor
data-testid="network-policy-editor"
:value="yamlEditorValue" :value="yamlEditorValue"
:height="400" :height="400"
:read-only="false" :read-only="false"
......
...@@ -32,6 +32,7 @@ describe('NetworkPolicyList component', () => { ...@@ -32,6 +32,7 @@ describe('NetworkPolicyList component', () => {
data, data,
store, store,
provide, provide,
stubs: { NetworkPolicyEditor: true },
}); });
}; };
...@@ -171,7 +172,7 @@ spec: ...@@ -171,7 +172,7 @@ spec:
it('renders network policy editor with manifest', () => { it('renders network policy editor with manifest', () => {
const policyEditor = findPolicyEditor(); const policyEditor = findPolicyEditor();
expect(policyEditor.exists()).toBe(true); expect(policyEditor.exists()).toBe(true);
expect(policyEditor.props('value')).toBe(mockData[0].manifest); expect(policyEditor.attributes('value')).toBe(mockData[0].manifest);
}); });
it('renders network policy toggle', () => { it('renders network policy toggle', () => {
......
...@@ -22,7 +22,8 @@ exports[`PolicyEditorApp component given .yaml editor mode is enabled renders ya ...@@ -22,7 +22,8 @@ exports[`PolicyEditorApp component given .yaml editor mode is enabled renders ya
<div <div
class="gl-p-4" class="gl-p-4"
> >
<network-policy-editor-stub <networkpolicyeditor-stub
data-testid="network-policy-editor"
height="400" height="400"
value="" value=""
/> />
......
import { GlModal, GlToggle } from '@gitlab/ui'; import { GlModal, GlToggle } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import NetworkPolicyEditor from 'ee/threat_monitoring/components/network_policy_editor.vue';
import { import {
RuleDirectionInbound, RuleDirectionInbound,
PortMatchModeAny, PortMatchModeAny,
...@@ -66,6 +65,7 @@ spec: ...@@ -66,6 +65,7 @@ spec:
}, },
store, store,
data, data,
stubs: { NetworkPolicyEditor: true },
}); });
}; };
...@@ -74,7 +74,7 @@ spec: ...@@ -74,7 +74,7 @@ spec:
const findPreview = () => wrapper.find(PolicyPreview); const findPreview = () => wrapper.find(PolicyPreview);
const findAddRuleButton = () => wrapper.find('[data-testid="add-rule"]'); const findAddRuleButton = () => wrapper.find('[data-testid="add-rule"]');
const findYAMLParsingAlert = () => wrapper.find('[data-testid="parsing-alert"]'); const findYAMLParsingAlert = () => wrapper.find('[data-testid="parsing-alert"]');
const findNetworkPolicyEditor = () => wrapper.find(NetworkPolicyEditor); const findNetworkPolicyEditor = () => wrapper.find('[data-testid="network-policy-editor"]');
const findPolicyAlertPicker = () => wrapper.find(PolicyAlertPicker); const findPolicyAlertPicker = () => wrapper.find(PolicyAlertPicker);
const findPolicyName = () => wrapper.find("[id='policyName']"); const findPolicyName = () => wrapper.find("[id='policyName']");
const findSavePolicy = () => wrapper.find("[data-testid='save-policy']"); const findSavePolicy = () => wrapper.find("[data-testid='save-policy']");
...@@ -259,7 +259,7 @@ spec: ...@@ -259,7 +259,7 @@ spec:
const editor = findNetworkPolicyEditor(); const editor = findNetworkPolicyEditor();
expect(editor.exists()).toBe(true); expect(editor.exists()).toBe(true);
expect(fromYaml(editor.props('value'))).toMatchObject({ expect(fromYaml(editor.attributes('value'))).toMatchObject({
name: 'test-policy', name: 'test-policy',
}); });
}); });
...@@ -296,7 +296,7 @@ spec: ...@@ -296,7 +296,7 @@ spec:
const editor = findNetworkPolicyEditor(); const editor = findNetworkPolicyEditor();
expect(editor.exists()).toBe(true); expect(editor.exists()).toBe(true);
expect(editor.props('value')).toEqual(''); expect(editor.attributes('value')).toEqual('');
}); });
}); });
......
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