Commit f21dd104 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch...

Merge branch '327388-fe-generic-report-schema-render-code-type-on-vulnerability-details-page' into 'master'

Show generic 'code' type on vuln details

See merge request gitlab-org/gitlab!62861
parents c1b5d0d7 b9af9a5e
<script>
import CodeBlock from '~/vue_shared/components/code_block.vue';
export default {
components: {
CodeBlock,
},
props: {
value: {
type: String,
required: true,
},
},
};
</script>
<template>
<code-block :code="value" />
</template>
...@@ -10,6 +10,7 @@ export const REPORT_TYPES = { ...@@ -10,6 +10,7 @@ export const REPORT_TYPES = {
moduleLocation: 'module-location', moduleLocation: 'module-location',
fileLocation: 'file-location', fileLocation: 'file-location',
table: 'table', table: 'table',
code: 'code',
}; };
const REPORT_TYPE_TO_COMPONENT_MAP = { const REPORT_TYPE_TO_COMPONENT_MAP = {
...@@ -22,6 +23,7 @@ const REPORT_TYPE_TO_COMPONENT_MAP = { ...@@ -22,6 +23,7 @@ const REPORT_TYPE_TO_COMPONENT_MAP = {
[REPORT_TYPES.moduleLocation]: () => import('./module_location.vue'), [REPORT_TYPES.moduleLocation]: () => import('./module_location.vue'),
[REPORT_TYPES.fileLocation]: () => import('./file_location.vue'), [REPORT_TYPES.fileLocation]: () => import('./file_location.vue'),
[REPORT_TYPES.table]: () => import('./table.vue'), [REPORT_TYPES.table]: () => import('./table.vue'),
[REPORT_TYPES.code]: () => import('./code.vue'),
}; };
export const getComponentNameForType = (reportType) => export const getComponentNameForType = (reportType) =>
......
...@@ -6,24 +6,25 @@ import { extendedWrapper } from 'helpers/vue_test_utils_helper'; ...@@ -6,24 +6,25 @@ import { extendedWrapper } from 'helpers/vue_test_utils_helper';
const TEST_DATA = { const TEST_DATA = {
supportedTypes: { supportedTypes: {
one: { url: {
name: 'one', name: 'url',
type: REPORT_TYPES.url, type: REPORT_TYPES.url,
href: 'http://foo.com', href: 'http://foo.com',
}, },
two: { table: {
name: 'two', name: 'table',
type: REPORT_TYPES.url,
href: 'http://bar.com',
},
three: {
type: REPORT_TYPES.table, type: REPORT_TYPES.table,
header: [], header: [],
rows: [], rows: [],
}, },
code: {
name: 'code',
type: REPORT_TYPES.code,
value: '<h1>Foo</h1>',
},
}, },
unsupportedTypes: { unsupportedTypes: {
four: { unsupported: {
name: 'four', name: 'four',
type: 'not-supported', type: 'not-supported',
}, },
......
import { shallowMount } from '@vue/test-utils';
import Code from 'ee/vulnerabilities/components/generic_report/types/code.vue';
import CodeBlock from '~/vue_shared/components/code_block.vue';
const TEST_DATA = {
value: '<h1>Foo</h1>',
};
describe('ee/vulnerabilities/components/generic_report/types/code.vue', () => {
let wrapper;
const createWrapper = () => {
return shallowMount(Code, {
propsData: {
...TEST_DATA,
},
});
};
const findCodeBlock = () => wrapper.findComponent(CodeBlock);
beforeEach(() => {
wrapper = createWrapper();
});
afterEach(() => {
wrapper.destroy();
});
it('renders a code-block', () => {
expect(findCodeBlock().exists()).toBe(true);
});
it('passes the given value to the code-block component', () => {
expect(findCodeBlock().props('code')).toBe(TEST_DATA.value);
});
});
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