Commit e06e3909 authored by David Pisek's avatar David Pisek Committed by Denys Mishunov

Vuln Report: show identifiers with no URL as text

* Update view logic to only render a link when a vulnerability
  identifier has a url attached to it
* Update specs
parent 72fdd799
...@@ -282,9 +282,13 @@ export default { ...@@ -282,9 +282,13 @@ export default {
:key="`${index}:${identifier.url}`" :key="`${index}:${identifier.url}`"
class="gl-ml-0! gl-list-style-position-inside" class="gl-ml-0! gl-list-style-position-inside"
> >
<gl-link :href="identifier.url" data-testid="identifier" target="_blank"> <component
:is="identifier.url ? 'gl-link' : 'span'"
v-bind="identifier.url && { href: identifier.url, target: '_blank' }"
data-testid="identifier"
>
{{ identifier.name }} {{ identifier.name }}
</gl-link> </component>
</li> </li>
</ul> </ul>
</template> </template>
......
---
title: 'Vulnerability Report: Show identifiers without URL as plain-text instead of
link'
merge_request: 48653
author:
type: fixed
...@@ -88,23 +88,40 @@ describe('Vulnerability Details', () => { ...@@ -88,23 +88,40 @@ describe('Vulnerability Details', () => {
}); });
it('shows the vulnerability identifiers if they exist', () => { it('shows the vulnerability identifiers if they exist', () => {
const identifiersData = [
{ name: '00', url: 'http://example.com/00' },
{ name: '11', url: 'http://example.com/11' },
{ name: '22', url: 'http://example.com/22' },
{ name: '33' },
{ name: '44' },
{ name: '55' },
];
createWrapper({ createWrapper({
identifiers: [{ url: '0', name: '00' }, { url: '1', name: '11' }, { url: '2', name: '22' }], identifiers: identifiersData,
}); });
const identifiers = getAllById('identifier'); const identifiers = getAllById('identifier');
expect(identifiers).toHaveLength(3);
const checkIdentifier = index => { expect(identifiers).toHaveLength(identifiersData.length);
const checkIdentifier = ({ name, url }, index) => {
const identifier = identifiers.at(index); const identifier = identifiers.at(index);
expect(identifier.attributes('target')).toBe('_blank');
expect(identifier.attributes('href')).toBe(index.toString());
expect(identifier.text()).toBe(`${index}${index}`);
};
for (let i = 0; i < identifiers.length; i += 1) { expect(identifier.text()).toBe(name);
checkIdentifier(i);
if (url) {
expect(identifier.is(GlLink)).toBe(true);
expect(identifier.attributes()).toMatchObject({
target: '_blank',
href: url,
});
} else {
expect(identifier.is(GlLink)).toBe(false);
} }
};
identifiersData.forEach(checkIdentifier);
}); });
describe('file link', () => { describe('file link', () => {
......
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