Commit 6588695f authored by Denys Mishunov's avatar Denys Mishunov

Merge branch...

Merge branch '288755-vulnerability-identifier-shows-as-link-even-though-it-doesn-t-have-a-link' into 'master'

Vuln Report: Show identifiers with no URL as plain-text

See merge request gitlab-org/gitlab!48653
parents 285e10aa e06e3909
...@@ -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(name);
expect(identifier.text()).toBe(`${index}${index}`);
if (url) {
expect(identifier.is(GlLink)).toBe(true);
expect(identifier.attributes()).toMatchObject({
target: '_blank',
href: url,
});
} else {
expect(identifier.is(GlLink)).toBe(false);
}
}; };
for (let i = 0; i < identifiers.length; i += 1) { identifiersData.forEach(checkIdentifier);
checkIdentifier(i);
}
}); });
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