Commit 1d43fae1 authored by Fernando Arias's avatar Fernando Arias Committed by Scott Hampton

Update package list logic for license compliance

* If we have 0 packages for a license then show empty string
parent 22a117e6
...@@ -14,6 +14,11 @@ export default { ...@@ -14,6 +14,11 @@ export default {
required: true, required: true,
}, },
}, },
computed: {
hasPackages() {
return Boolean(this.issue.packages.length);
},
},
methods: { ...mapActions(LICENSE_MANAGEMENT, ['setLicenseInModal']) }, methods: { ...mapActions(LICENSE_MANAGEMENT, ['setLicenseInModal']) },
}; };
</script> </script>
...@@ -21,6 +26,6 @@ export default { ...@@ -21,6 +26,6 @@ export default {
<template> <template>
<div class="report-block-info license-item"> <div class="report-block-info license-item">
<gl-link :href="issue.url" target="_blank">{{ issue.name }}</gl-link> <gl-link :href="issue.url" target="_blank">{{ issue.name }}</gl-link>
<license-packages :packages="issue.packages" class="text-secondary" /> <license-packages v-if="hasPackages" :packages="issue.packages" class="text-secondary" />
</div> </div>
</template> </template>
---
title: Hide package list if license compliance has an entry with 0 packages
merge_request: 55466
author:
type: fixed
...@@ -14,7 +14,6 @@ describe('LicenseIssueBody', () => { ...@@ -14,7 +14,6 @@ describe('LicenseIssueBody', () => {
beforeEach(() => { beforeEach(() => {
store = createStore(); store = createStore();
vm = mountComponentWithStore(Component, { props: { issue }, store });
}); });
afterEach(() => { afterEach(() => {
...@@ -22,6 +21,10 @@ describe('LicenseIssueBody', () => { ...@@ -22,6 +21,10 @@ describe('LicenseIssueBody', () => {
}); });
describe('template', () => { describe('template', () => {
beforeEach(() => {
vm = mountComponentWithStore(Component, { props: { issue }, store });
});
it('renders component container element with class `license-item`', () => { it('renders component container element with class `license-item`', () => {
expect(vm.$el.classList.contains('license-item')).toBe(true); expect(vm.$el.classList.contains('license-item')).toBe(true);
}); });
...@@ -40,4 +43,20 @@ describe('LicenseIssueBody', () => { ...@@ -40,4 +43,20 @@ describe('LicenseIssueBody', () => {
expect(trimText(packagesEl.innerText)).toBe('Used by pg, puma, foo, and 2 more'); expect(trimText(packagesEl.innerText)).toBe('Used by pg, puma, foo, and 2 more');
}); });
}); });
describe('template without packages', () => {
beforeEach(() => {
const issueWithoutPackages = licenseReport[0];
issueWithoutPackages.packages = [];
vm = mountComponentWithStore(Component, { props: { issue: issueWithoutPackages }, store });
});
it('does not render packages list', () => {
const packagesEl = vm.$el.querySelector('.license-packages');
expect(packagesEl).toBeNull();
vm.$destroy();
});
});
}); });
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