Commit bf295d39 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch '327382-render-value-type' into 'master'

Add text generic report type

See merge request gitlab-org/gitlab!61727
parents 0d58b7ab f50cb38a
...@@ -5,6 +5,8 @@ export const REPORT_TYPES = { ...@@ -5,6 +5,8 @@ export const REPORT_TYPES = {
url: 'url', url: 'url',
diff: 'diff', diff: 'diff',
namedList: 'named-list', namedList: 'named-list',
text: 'text',
value: 'value',
}; };
const REPORT_TYPE_TO_COMPONENT_MAP = { const REPORT_TYPE_TO_COMPONENT_MAP = {
...@@ -12,6 +14,8 @@ const REPORT_TYPE_TO_COMPONENT_MAP = { ...@@ -12,6 +14,8 @@ const REPORT_TYPE_TO_COMPONENT_MAP = {
[REPORT_TYPES.url]: () => import('./url.vue'), [REPORT_TYPES.url]: () => import('./url.vue'),
[REPORT_TYPES.diff]: () => import('./diff.vue'), [REPORT_TYPES.diff]: () => import('./diff.vue'),
[REPORT_TYPES.namedList]: () => import('./named_list.vue'), [REPORT_TYPES.namedList]: () => import('./named_list.vue'),
[REPORT_TYPES.text]: () => import('./value.vue'),
[REPORT_TYPES.value]: () => import('./value.vue'),
}; };
export const getComponentNameForType = (reportType) => export const getComponentNameForType = (reportType) =>
......
<script>
export default {
inheritAttrs: false,
props: {
value: {
type: [String, Number, Boolean],
required: true,
},
},
};
</script>
<template>
<span>{{ value }}</span>
</template>
---
title: Render text and value generic report types on vulnerability report
merge_request: 61727
author:
type: added
...@@ -17,6 +17,14 @@ const TEST_DATA = { ...@@ -17,6 +17,14 @@ const TEST_DATA = {
before: 'foo', before: 'foo',
after: 'bar', after: 'bar',
}, },
[REPORT_TYPES.text]: {
name: 'some-string-field',
value: 'some-value',
},
[REPORT_TYPES.value]: {
name: 'some-numeric-field',
value: 15,
},
}; };
describe('ee/vulnerabilities/components/generic_report/report_item.vue', () => { describe('ee/vulnerabilities/components/generic_report/report_item.vue', () => {
......
import { shallowMount } from '@vue/test-utils';
import Text from 'ee/vulnerabilities/components/generic_report/types/value.vue';
describe('ee/vulnerabilities/components/generic_report/types/value.vue', () => {
let wrapper;
describe.each`
field type | value
${'string'} | ${'some string'}
${'number'} | ${8}
${'boolean'} | ${true}
${'boolean'} | ${false}
`('with value of type "$fieldType"', ({ fieldType, value }) => {
const createWrapper = () => {
return shallowMount(Text, {
propsData: {
type: 'text',
name: `${fieldType} field`,
value,
},
});
};
beforeEach(() => {
wrapper = createWrapper();
});
afterEach(() => {
wrapper.destroy();
});
it(`renders ${fieldType} type`, () => {
expect(wrapper.text()).toBe(value.toString());
});
});
});
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