Commit 808f57df authored by Alexander Turinske's avatar Alexander Turinske

Clean up network-policy-editor

- fix styling
- make tests more concise
- move changelog
parent f42183fd
...@@ -22,6 +22,7 @@ export default { ...@@ -22,6 +22,7 @@ export default {
lineNumbers: 'off', lineNumbers: 'off',
minimap: { enabled: false }, minimap: { enabled: false },
folding: false, folding: false,
glyphMargin: false,
renderIndentGuides: false, renderIndentGuides: false,
renderWhitespace: 'boundary', renderWhitespace: 'boundary',
renderLineHighlight: 'none', renderLineHighlight: 'none',
......
...@@ -365,16 +365,17 @@ export default { ...@@ -365,16 +365,17 @@ export default {
> >
{{ s__('NetworkPolicies|YAML editor') }} {{ s__('NetworkPolicies|YAML editor') }}
</h5> </h5>
<div class="gl-p-4">
<network-policy-editor <network-policy-editor
data-testid="network-policy-editor" data-testid="network-policy-editor"
:value="yamlEditorValue" :value="yamlEditorValue"
:height="400"
:read-only="false" :read-only="false"
@input="loadYaml" @input="loadYaml"
/> />
</div> </div>
</div> </div>
</div> </div>
</div>
<hr /> <hr />
<div class="row"> <div class="row">
<div class="col-md-auto"> <div class="col-md-auto">
......
...@@ -5,6 +5,8 @@ import EditorLite from '~/vue_shared/components/editor_lite.vue'; ...@@ -5,6 +5,8 @@ import EditorLite from '~/vue_shared/components/editor_lite.vue';
describe('NetworkPolicyEditor component', () => { describe('NetworkPolicyEditor component', () => {
let wrapper; let wrapper;
const findEditor = () => wrapper.findComponent(EditorLite);
const factory = ({ propsData } = {}) => { const factory = ({ propsData } = {}) => {
wrapper = shallowMount(NetworkPolicyEditor, { wrapper = shallowMount(NetworkPolicyEditor, {
propsData: { propsData: {
...@@ -27,17 +29,18 @@ describe('NetworkPolicyEditor component', () => { ...@@ -27,17 +29,18 @@ describe('NetworkPolicyEditor component', () => {
}); });
it('renders container element', () => { it('renders container element', () => {
expect(wrapper.findComponent(EditorLite).exists()).toBe(true); expect(findEditor().exists()).toBe(true);
}); });
it('initializes monaco editor with yaml language and provided value', () => { it('initializes monaco editor with yaml language and provided value', () => {
const editor = wrapper.findComponent(EditorLite).vm.getEditor(); const editorComponent = findEditor();
expect(editorComponent.props('value')).toBe('foo');
const editor = editorComponent.vm.getEditor();
expect(editor.getModel().getModeId()).toBe('yaml'); expect(editor.getModel().getModeId()).toBe('yaml');
expect(editor.getValue()).toBe('foo');
}); });
it("emits input event on editor's input", async () => { it("emits input event on editor's input", async () => {
const editor = wrapper.findComponent(EditorLite); const editor = findEditor();
editor.vm.$emit('input'); editor.vm.$emit('input');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(wrapper.emitted().input).toBeTruthy(); expect(wrapper.emitted().input).toBeTruthy();
......
...@@ -24,7 +24,6 @@ exports[`PolicyEditorApp component given .yaml editor mode is enabled renders ya ...@@ -24,7 +24,6 @@ exports[`PolicyEditorApp component given .yaml editor mode is enabled renders ya
> >
<networkpolicyeditor-stub <networkpolicyeditor-stub
data-testid="network-policy-editor" data-testid="network-policy-editor"
height="400"
value="" value=""
/> />
</div> </div>
......
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