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 = {
moduleLocation: 'module-location',
fileLocation: 'file-location',
table: 'table',
code: 'code',
};
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.fileLocation]: () => import('./file_location.vue'),
[REPORT_TYPES.table]: () => import('./table.vue'),
[REPORT_TYPES.code]: () => import('./code.vue'),
};
export const getComponentNameForType = (reportType) =>
......
......@@ -6,24 +6,25 @@ import { extendedWrapper } from 'helpers/vue_test_utils_helper';
const TEST_DATA = {
supportedTypes: {
one: {
name: 'one',
url: {
name: 'url',
type: REPORT_TYPES.url,
href: 'http://foo.com',
},
two: {
name: 'two',
type: REPORT_TYPES.url,
href: 'http://bar.com',
},
three: {
table: {
name: 'table',
type: REPORT_TYPES.table,
header: [],
rows: [],
},
code: {
name: 'code',
type: REPORT_TYPES.code,
value: '<h1>Foo</h1>',
},
},
unsupportedTypes: {
four: {
unsupported: {
name: 'four',
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