Commit 64746b1b authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'update-license-compliance-ui-classifcations' into 'master'

Update license compliance policy classifications text in the UI and refactor

See merge request gitlab-org/gitlab!27058
parents 42fbb62e a5448f04
...@@ -14,8 +14,8 @@ export default { ...@@ -14,8 +14,8 @@ export default {
}, },
LICENSE_APPROVAL_STATUS, LICENSE_APPROVAL_STATUS,
approvalStatusOptions: [ approvalStatusOptions: [
{ value: LICENSE_APPROVAL_STATUS.APPROVED, label: s__('LicenseCompliance|Allow') }, { value: LICENSE_APPROVAL_STATUS.ALLOWED, label: s__('LicenseCompliance|Allow') },
{ value: LICENSE_APPROVAL_STATUS.BLACKLISTED, label: s__('LicenseCompliance|Deny') }, { value: LICENSE_APPROVAL_STATUS.DENIED, label: s__('LicenseCompliance|Deny') },
], ],
props: { props: {
managedLicenses: { managedLicenses: {
......
...@@ -6,7 +6,7 @@ import { s__ } from '~/locale'; ...@@ -6,7 +6,7 @@ import { s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import IssueStatusIcon from '~/reports/components/issue_status_icon.vue'; import IssueStatusIcon from '~/reports/components/issue_status_icon.vue';
import { LICENSE_APPROVAL_STATUS } from '../constants'; import { LICENSE_APPROVAL_STATUS, LICENSE_APPROVAL_ACTION } from '../constants';
import { LICENSE_MANAGEMENT } from 'ee/vue_shared/license_management/store/constants'; import { LICENSE_MANAGEMENT } from 'ee/vue_shared/license_management/store/constants';
const visibleClass = 'visible'; const visibleClass = 'visible';
...@@ -36,16 +36,19 @@ export default { ...@@ -36,16 +36,19 @@ export default {
}, },
}, },
LICENSE_APPROVAL_STATUS, LICENSE_APPROVAL_STATUS,
[LICENSE_APPROVAL_STATUS.APPROVED]: s__('LicenseCompliance|Allowed'), LICENSE_APPROVAL_ACTION,
[LICENSE_APPROVAL_STATUS.BLACKLISTED]: s__('LicenseCompliance|Denied'), [LICENSE_APPROVAL_ACTION.ALLOW]: s__('LicenseCompliance|Allow'),
[LICENSE_APPROVAL_ACTION.DENY]: s__('LicenseCompliance|Deny'),
[LICENSE_APPROVAL_STATUS.ALLOWED]: s__('LicenseCompliance|Allowed'),
[LICENSE_APPROVAL_STATUS.DENIED]: s__('LicenseCompliance|Denied'),
computed: { computed: {
approveIconClass() { approveIconClass() {
return this.license.approvalStatus === LICENSE_APPROVAL_STATUS.APPROVED return this.license.approvalStatus === LICENSE_APPROVAL_STATUS.ALLOWED
? visibleClass ? visibleClass
: invisibleClass; : invisibleClass;
}, },
blacklistIconClass() { blacklistIconClass() {
return this.license.approvalStatus === LICENSE_APPROVAL_STATUS.BLACKLISTED return this.license.approvalStatus === LICENSE_APPROVAL_STATUS.DENIED
? visibleClass ? visibleClass
: invisibleClass; : invisibleClass;
}, },
...@@ -57,7 +60,7 @@ export default { ...@@ -57,7 +60,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(LICENSE_MANAGEMENT, ['setLicenseInModal', 'approveLicense', 'blacklistLicense']), ...mapActions(LICENSE_MANAGEMENT, ['setLicenseInModal', 'allowLicense', 'denyLicense']),
}, },
}; };
</script> </script>
...@@ -74,13 +77,13 @@ export default { ...@@ -74,13 +77,13 @@ export default {
toggle-class="d-flex justify-content-between align-items-center" toggle-class="d-flex justify-content-between align-items-center"
right right
> >
<gl-dropdown-item @click="approveLicense(license)"> <gl-dropdown-item @click="allowLicense(license)">
<icon :class="approveIconClass" name="mobile-issue-close" /> <icon :class="approveIconClass" name="mobile-issue-close" />
{{ $options[$options.LICENSE_APPROVAL_STATUS.APPROVED] }} {{ $options[$options.LICENSE_APPROVAL_ACTION.ALLOW] }}
</gl-dropdown-item> </gl-dropdown-item>
<gl-dropdown-item @click="blacklistLicense(license)"> <gl-dropdown-item @click="denyLicense(license)">
<icon :class="blacklistIconClass" name="mobile-issue-close" /> <icon :class="blacklistIconClass" name="mobile-issue-close" />
{{ $options[$options.LICENSE_APPROVAL_STATUS.BLACKLISTED] }} {{ $options[$options.LICENSE_APPROVAL_ACTION.DENY] }}
</gl-dropdown-item> </gl-dropdown-item>
</gl-dropdown> </gl-dropdown>
<button <button
......
...@@ -22,23 +22,19 @@ export default { ...@@ -22,23 +22,19 @@ export default {
return ( return (
this.canManageLicenses && this.canManageLicenses &&
this.currentLicenseInModal && this.currentLicenseInModal &&
this.currentLicenseInModal.approvalStatus !== LICENSE_APPROVAL_STATUS.APPROVED this.currentLicenseInModal.approvalStatus !== LICENSE_APPROVAL_STATUS.ALLOWED
); );
}, },
canBlacklist() { canBlacklist() {
return ( return (
this.canManageLicenses && this.canManageLicenses &&
this.currentLicenseInModal && this.currentLicenseInModal &&
this.currentLicenseInModal.approvalStatus !== LICENSE_APPROVAL_STATUS.BLACKLISTED this.currentLicenseInModal.approvalStatus !== LICENSE_APPROVAL_STATUS.DENIED
); );
}, },
}, },
methods: { methods: {
...mapActions(LICENSE_MANAGEMENT, [ ...mapActions(LICENSE_MANAGEMENT, ['resetLicenseInModal', 'allowLicense', 'denyLicense']),
'resetLicenseInModal',
'approveLicense',
'blacklistLicense',
]),
}, },
}; };
</script> </script>
...@@ -97,7 +93,7 @@ export default { ...@@ -97,7 +93,7 @@ export default {
class="btn btn-remove btn-inverted js-modal-secondary-action" class="btn btn-remove btn-inverted js-modal-secondary-action"
data-dismiss="modal" data-dismiss="modal"
data-qa-selector="blacklist_license_button" data-qa-selector="blacklist_license_button"
@click="blacklistLicense(currentLicenseInModal)" @click="denyLicense(currentLicenseInModal)"
> >
{{ s__('LicenseCompliance|Deny') }} {{ s__('LicenseCompliance|Deny') }}
</button> </button>
...@@ -107,7 +103,7 @@ export default { ...@@ -107,7 +103,7 @@ export default {
class="btn btn-success js-modal-primary-action" class="btn btn-success js-modal-primary-action"
data-dismiss="modal" data-dismiss="modal"
data-qa-selector="approve_license_button" data-qa-selector="approve_license_button"
@click="approveLicense(currentLicenseInModal)" @click="allowLicense(currentLicenseInModal)"
> >
{{ s__('LicenseCompliance|Allow') }} {{ s__('LicenseCompliance|Allow') }}
</button> </button>
......
/* eslint-disable @gitlab/i18n/no-non-i18n-strings */ /* eslint-disable @gitlab/i18n/no-non-i18n-strings */
/*
* Endpoint still returns 'approved' & 'blacklisted'
* even though we adopted 'allowed' & 'denied' in the UI
*/
export const LICENSE_APPROVAL_STATUS = { export const LICENSE_APPROVAL_STATUS = {
APPROVED: 'approved', ALLOWED: 'approved',
BLACKLISTED: 'blacklisted', DENIED: 'blacklisted',
};
export const LICENSE_APPROVAL_ACTION = {
ALLOW: 'allow',
DENY: 'deny',
}; };
export const KNOWN_LICENSES = [ export const KNOWN_LICENSES = [
......
...@@ -154,17 +154,17 @@ export const setLicenseApproval = ({ dispatch, state }, payload) => { ...@@ -154,17 +154,17 @@ export const setLicenseApproval = ({ dispatch, state }, payload) => {
dispatch('removePendingLicense', id); dispatch('removePendingLicense', id);
}); });
}; };
export const approveLicense = ({ dispatch }, license) => { export const allowLicense = ({ dispatch }, license) => {
const { approvalStatus } = license; const { approvalStatus } = license;
if (approvalStatus !== LICENSE_APPROVAL_STATUS.APPROVED) { if (approvalStatus !== LICENSE_APPROVAL_STATUS.ALLOWED) {
dispatch('setLicenseApproval', { license, newStatus: LICENSE_APPROVAL_STATUS.APPROVED }); dispatch('setLicenseApproval', { license, newStatus: LICENSE_APPROVAL_STATUS.ALLOWED });
} }
}; };
export const blacklistLicense = ({ dispatch }, license) => { export const denyLicense = ({ dispatch }, license) => {
const { approvalStatus } = license; const { approvalStatus } = license;
if (approvalStatus !== LICENSE_APPROVAL_STATUS.BLACKLISTED) { if (approvalStatus !== LICENSE_APPROVAL_STATUS.DENIED) {
dispatch('setLicenseApproval', { license, newStatus: LICENSE_APPROVAL_STATUS.BLACKLISTED }); dispatch('setLicenseApproval', { license, newStatus: LICENSE_APPROVAL_STATUS.DENIED });
} }
}; };
......
...@@ -68,7 +68,7 @@ export const licenseSummaryText = (state, getters) => { ...@@ -68,7 +68,7 @@ export const licenseSummaryText = (state, getters) => {
export const reportContainsBlacklistedLicense = (_state, getters) => export const reportContainsBlacklistedLicense = (_state, getters) =>
(getters.licenseReport || []).some( (getters.licenseReport || []).some(
license => license.approvalStatus === LICENSE_APPROVAL_STATUS.BLACKLISTED, license => license.approvalStatus === LICENSE_APPROVAL_STATUS.DENIED,
); );
// prevent babel-plugin-rewire from generating an invalid default during karma tests // prevent babel-plugin-rewire from generating an invalid default during karma tests
......
...@@ -19,18 +19,18 @@ export const normalizeLicense = license => { ...@@ -19,18 +19,18 @@ export const normalizeLicense = license => {
}; };
export const getStatusTranslationsFromLicenseStatus = approvalStatus => { export const getStatusTranslationsFromLicenseStatus = approvalStatus => {
if (approvalStatus === LICENSE_APPROVAL_STATUS.APPROVED) { if (approvalStatus === LICENSE_APPROVAL_STATUS.ALLOWED) {
return s__('LicenseCompliance|Allowed'); return s__('LicenseCompliance|Allowed');
} else if (approvalStatus === LICENSE_APPROVAL_STATUS.BLACKLISTED) { } else if (approvalStatus === LICENSE_APPROVAL_STATUS.DENIED) {
return s__('LicenseCompliance|Denied'); return s__('LicenseCompliance|Denied');
} }
return ''; return '';
}; };
export const getIssueStatusFromLicenseStatus = approvalStatus => { export const getIssueStatusFromLicenseStatus = approvalStatus => {
if (approvalStatus === LICENSE_APPROVAL_STATUS.APPROVED) { if (approvalStatus === LICENSE_APPROVAL_STATUS.ALLOWED) {
return STATUS_SUCCESS; return STATUS_SUCCESS;
} else if (approvalStatus === LICENSE_APPROVAL_STATUS.BLACKLISTED) { } else if (approvalStatus === LICENSE_APPROVAL_STATUS.DENIED) {
return STATUS_FAILED; return STATUS_FAILED;
} }
return STATUS_NEUTRAL; return STATUS_NEUTRAL;
......
---
title: Update license compliance policy classifications text in the UI
merge_request: 27058
author:
type: changed
...@@ -22,7 +22,7 @@ describe('AddLicenseForm', () => { ...@@ -22,7 +22,7 @@ describe('AddLicenseForm', () => {
it('clicking the Submit button submits the data and closes the form', done => { it('clicking the Submit button submits the data and closes the form', done => {
const name = 'LICENSE_TEST'; const name = 'LICENSE_TEST';
jest.spyOn(vm, '$emit').mockImplementation(() => {}); jest.spyOn(vm, '$emit').mockImplementation(() => {});
vm.approvalStatus = LICENSE_APPROVAL_STATUS.APPROVED; vm.approvalStatus = LICENSE_APPROVAL_STATUS.ALLOWED;
vm.licenseName = name; vm.licenseName = name;
Vue.nextTick(() => { Vue.nextTick(() => {
...@@ -30,7 +30,7 @@ describe('AddLicenseForm', () => { ...@@ -30,7 +30,7 @@ describe('AddLicenseForm', () => {
linkEl.click(); linkEl.click();
expect(vm.$emit).toHaveBeenCalledWith('addLicense', { expect(vm.$emit).toHaveBeenCalledWith('addLicense', {
newStatus: LICENSE_APPROVAL_STATUS.APPROVED, newStatus: LICENSE_APPROVAL_STATUS.ALLOWED,
license: { name }, license: { name },
}); });
...@@ -58,7 +58,7 @@ describe('AddLicenseForm', () => { ...@@ -58,7 +58,7 @@ describe('AddLicenseForm', () => {
it('is true if the licenseName is empty', () => { it('is true if the licenseName is empty', () => {
vm.licenseName = ''; vm.licenseName = '';
vm.approvalStatus = LICENSE_APPROVAL_STATUS.APPROVED; vm.approvalStatus = LICENSE_APPROVAL_STATUS.ALLOWED;
expect(vm.submitDisabled).toBe(true); expect(vm.submitDisabled).toBe(true);
}); });
...@@ -66,7 +66,7 @@ describe('AddLicenseForm', () => { ...@@ -66,7 +66,7 @@ describe('AddLicenseForm', () => {
it('is true if the entered license is duplicated', () => { it('is true if the entered license is duplicated', () => {
vm = mountComponent(Component, { managedLicenses: [{ name: 'FOO' }] }); vm = mountComponent(Component, { managedLicenses: [{ name: 'FOO' }] });
vm.licenseName = 'FOO'; vm.licenseName = 'FOO';
vm.approvalStatus = LICENSE_APPROVAL_STATUS.APPROVED; vm.approvalStatus = LICENSE_APPROVAL_STATUS.ALLOWED;
expect(vm.submitDisabled).toBe(true); expect(vm.submitDisabled).toBe(true);
}); });
......
...@@ -32,8 +32,8 @@ describe('AdminLicenseManagementRow', () => { ...@@ -32,8 +32,8 @@ describe('AdminLicenseManagementRow', () => {
beforeEach(() => { beforeEach(() => {
actions = { actions = {
setLicenseInModal: jest.fn(), setLicenseInModal: jest.fn(),
approveLicense: jest.fn(), allowLicense: jest.fn(),
blacklistLicense: jest.fn(), denyLicense: jest.fn(),
}; };
store = new Vuex.Store({ store = new Vuex.Store({
...@@ -55,7 +55,7 @@ describe('AdminLicenseManagementRow', () => { ...@@ -55,7 +55,7 @@ describe('AdminLicenseManagementRow', () => {
describe('approved license', () => { describe('approved license', () => {
beforeEach(done => { beforeEach(done => {
vm.license = { ...approvedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.APPROVED }; vm.license = { ...approvedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED };
Vue.nextTick(done); Vue.nextTick(done);
}); });
...@@ -90,7 +90,7 @@ describe('AdminLicenseManagementRow', () => { ...@@ -90,7 +90,7 @@ describe('AdminLicenseManagementRow', () => {
describe('blacklisted license', () => { describe('blacklisted license', () => {
beforeEach(done => { beforeEach(done => {
vm.license = { ...approvedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.BLACKLISTED }; vm.license = { ...approvedLicense, approvalStatus: LICENSE_APPROVAL_STATUS.DENIED };
Vue.nextTick(done); Vue.nextTick(done);
}); });
...@@ -131,18 +131,18 @@ describe('AdminLicenseManagementRow', () => { ...@@ -131,18 +131,18 @@ describe('AdminLicenseManagementRow', () => {
expect(actions.setLicenseInModal).toHaveBeenCalled(); expect(actions.setLicenseInModal).toHaveBeenCalled();
}); });
it('triggering approveLicense by clicking the first dropdown option', () => { it('triggering allowLicense by clicking the first dropdown option', () => {
const linkEl = findNthDropdown(0); const linkEl = findNthDropdown(0);
linkEl.click(); linkEl.click();
expect(actions.approveLicense).toHaveBeenCalled(); expect(actions.allowLicense).toHaveBeenCalled();
}); });
it('triggering approveLicense blacklistLicense by clicking the second dropdown option', () => { it('triggering allowLicense denyLicense by clicking the second dropdown option', () => {
const linkEl = findNthDropdown(1); const linkEl = findNthDropdown(1);
linkEl.click(); linkEl.click();
expect(actions.blacklistLicense).toHaveBeenCalled(); expect(actions.denyLicense).toHaveBeenCalled();
}); });
}); });
...@@ -176,7 +176,7 @@ describe('AdminLicenseManagementRow', () => { ...@@ -176,7 +176,7 @@ describe('AdminLicenseManagementRow', () => {
expect(dropdownEl.innerText.trim()).toBe(vm.dropdownText); expect(dropdownEl.innerText.trim()).toBe(vm.dropdownText);
}); });
it('renders the dropdown with `Allowed` and `Denied` options', () => { it('renders the dropdown with `Allow` and `Deny` options', () => {
const dropdownEl = vm.$el.querySelector('.dropdown'); const dropdownEl = vm.$el.querySelector('.dropdown');
expect(dropdownEl).not.toBeNull(); expect(dropdownEl).not.toBeNull();
...@@ -184,12 +184,12 @@ describe('AdminLicenseManagementRow', () => { ...@@ -184,12 +184,12 @@ describe('AdminLicenseManagementRow', () => {
const firstOption = findNthDropdown(0); const firstOption = findNthDropdown(0);
expect(firstOption).not.toBeNull(); expect(firstOption).not.toBeNull();
expect(firstOption.innerText.trim()).toBe('Allowed'); expect(firstOption.innerText.trim()).toBe('Allow');
const secondOption = findNthDropdown(1); const secondOption = findNthDropdown(1);
expect(secondOption).not.toBeNull(); expect(secondOption).not.toBeNull();
expect(secondOption.innerText.trim()).toBe('Denied'); expect(secondOption.innerText.trim()).toBe('Deny');
}); });
it('does not show a loading icon and enables both the dropdown and the remove button by default', () => { it('does not show a loading icon and enables both the dropdown and the remove button by default', () => {
......
...@@ -19,8 +19,8 @@ describe('SetApprovalModal', () => { ...@@ -19,8 +19,8 @@ describe('SetApprovalModal', () => {
beforeEach(() => { beforeEach(() => {
actions = { actions = {
resetLicenseInModal: jest.fn(), resetLicenseInModal: jest.fn(),
approveLicense: jest.fn(), allowLicense: jest.fn(),
blacklistLicense: jest.fn(), denyLicense: jest.fn(),
}; };
store = new Vuex.Store({ store = new Vuex.Store({
...@@ -49,7 +49,7 @@ describe('SetApprovalModal', () => { ...@@ -49,7 +49,7 @@ describe('SetApprovalModal', () => {
licenseManagement: { licenseManagement: {
currentLicenseInModal: { currentLicenseInModal: {
...licenseReport[0], ...licenseReport[0],
approvalStatus: LICENSE_APPROVAL_STATUS.APPROVED, approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED,
}, },
canManageLicenses: true, canManageLicenses: true,
}, },
...@@ -152,7 +152,7 @@ describe('SetApprovalModal', () => { ...@@ -152,7 +152,7 @@ describe('SetApprovalModal', () => {
licenseManagement: { licenseManagement: {
currentLicenseInModal: { currentLicenseInModal: {
...licenseReport[0], ...licenseReport[0],
approvalStatus: LICENSE_APPROVAL_STATUS.BLACKLISTED, approvalStatus: LICENSE_APPROVAL_STATUS.DENIED,
}, },
canManageLicenses: true, canManageLicenses: true,
}, },
...@@ -292,12 +292,12 @@ describe('SetApprovalModal', () => { ...@@ -292,12 +292,12 @@ describe('SetApprovalModal', () => {
}); });
}); });
describe('triggering approveLicense on approving', () => { describe('triggering allowLicense on approving', () => {
it('by clicking the confirmation button', () => { it('by clicking the confirmation button', () => {
const linkEl = vm.$el.querySelector('.js-modal-primary-action'); const linkEl = vm.$el.querySelector('.js-modal-primary-action');
linkEl.click(); linkEl.click();
expect(actions.approveLicense).toHaveBeenCalledWith( expect(actions.allowLicense).toHaveBeenCalledWith(
expect.any(Object), expect.any(Object),
store.state.licenseManagement.currentLicenseInModal, store.state.licenseManagement.currentLicenseInModal,
undefined, undefined,
...@@ -305,12 +305,12 @@ describe('SetApprovalModal', () => { ...@@ -305,12 +305,12 @@ describe('SetApprovalModal', () => {
}); });
}); });
describe('triggering blacklistLicense on blacklisting', () => { describe('triggering denyLicense on blacklisting', () => {
it('by clicking the confirmation button', () => { it('by clicking the confirmation button', () => {
const linkEl = vm.$el.querySelector('.js-modal-secondary-action'); const linkEl = vm.$el.querySelector('.js-modal-secondary-action');
linkEl.click(); linkEl.click();
expect(actions.blacklistLicense).toHaveBeenCalledWith( expect(actions.denyLicense).toHaveBeenCalledWith(
expect.any(Object), expect.any(Object),
store.state.licenseManagement.currentLicenseInModal, store.state.licenseManagement.currentLicenseInModal,
undefined, undefined,
...@@ -328,7 +328,7 @@ describe('SetApprovalModal', () => { ...@@ -328,7 +328,7 @@ describe('SetApprovalModal', () => {
currentLicenseInModal: { currentLicenseInModal: {
...licenseReport[0], ...licenseReport[0],
url: badURL, url: badURL,
approvalStatus: LICENSE_APPROVAL_STATUS.APPROVED, approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED,
}, },
}, },
}); });
......
...@@ -3,13 +3,13 @@ import { LICENSE_APPROVAL_STATUS } from 'ee/vue_shared/license_management/consta ...@@ -3,13 +3,13 @@ import { LICENSE_APPROVAL_STATUS } from 'ee/vue_shared/license_management/consta
export const approvedLicense = { export const approvedLicense = {
id: 5, id: 5,
name: 'MIT', name: 'MIT',
approvalStatus: LICENSE_APPROVAL_STATUS.APPROVED, approvalStatus: LICENSE_APPROVAL_STATUS.ALLOWED,
}; };
export const blacklistedLicense = { export const blacklistedLicense = {
id: 6, id: 6,
name: 'New BSD', name: 'New BSD',
approvalStatus: LICENSE_APPROVAL_STATUS.BLACKLISTED, approvalStatus: LICENSE_APPROVAL_STATUS.DENIED,
}; };
export const licenseReport = [ export const licenseReport = [
......
...@@ -320,14 +320,14 @@ describe('License store actions', () => { ...@@ -320,14 +320,14 @@ describe('License store actions', () => {
}); });
}); });
describe('approveLicense', () => { describe('allowLicense', () => {
const newStatus = LICENSE_APPROVAL_STATUS.APPROVED; const newStatus = LICENSE_APPROVAL_STATUS.ALLOWED;
it('dispatches setLicenseApproval for un-approved licenses', done => { it('dispatches setLicenseApproval for un-approved licenses', done => {
const license = { name: 'FOO' }; const license = { name: 'FOO' };
testAction( testAction(
actions.approveLicense, actions.allowLicense,
license, license,
state, state,
[], [],
...@@ -341,7 +341,7 @@ describe('License store actions', () => { ...@@ -341,7 +341,7 @@ describe('License store actions', () => {
const license = blacklistedLicense; const license = blacklistedLicense;
testAction( testAction(
actions.approveLicense, actions.allowLicense,
license, license,
state, state,
[], [],
...@@ -352,20 +352,20 @@ describe('License store actions', () => { ...@@ -352,20 +352,20 @@ describe('License store actions', () => {
}); });
it('does not dispatch setLicenseApproval for approved licenses', done => { it('does not dispatch setLicenseApproval for approved licenses', done => {
testAction(actions.approveLicense, approvedLicense, state, [], []) testAction(actions.allowLicense, approvedLicense, state, [], [])
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
}); });
}); });
describe('blacklistLicense', () => { describe('denyLicense', () => {
const newStatus = LICENSE_APPROVAL_STATUS.BLACKLISTED; const newStatus = LICENSE_APPROVAL_STATUS.DENIED;
it('dispatches setLicenseApproval for un-approved licenses', done => { it('dispatches setLicenseApproval for un-approved licenses', done => {
const license = { name: 'FOO' }; const license = { name: 'FOO' };
testAction( testAction(
actions.blacklistLicense, actions.denyLicense,
license, license,
state, state,
[], [],
...@@ -379,7 +379,7 @@ describe('License store actions', () => { ...@@ -379,7 +379,7 @@ describe('License store actions', () => {
const license = approvedLicense; const license = approvedLicense;
testAction( testAction(
actions.blacklistLicense, actions.denyLicense,
license, license,
state, state,
[], [],
...@@ -390,7 +390,7 @@ describe('License store actions', () => { ...@@ -390,7 +390,7 @@ describe('License store actions', () => {
}); });
it('does not dispatch setLicenseApproval for blacklisted licenses', done => { it('does not dispatch setLicenseApproval for blacklisted licenses', done => {
testAction(actions.blacklistLicense, blacklistedLicense, state, [], []) testAction(actions.denyLicense, blacklistedLicense, state, [], [])
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
}); });
...@@ -448,7 +448,7 @@ describe('License store actions', () => { ...@@ -448,7 +448,7 @@ describe('License store actions', () => {
}); });
it('dispatches requestManagedLicenses and receiveManagedLicensesSuccess for successful response', done => { it('dispatches requestManagedLicenses and receiveManagedLicensesSuccess for successful response', done => {
const payload = [{ name: 'foo', approval_status: LICENSE_APPROVAL_STATUS.BLACKLISTED }]; const payload = [{ name: 'foo', approval_status: LICENSE_APPROVAL_STATUS.DENIED }];
endpointMock.replyOnce(() => [200, payload]); endpointMock.replyOnce(() => [200, payload]);
testAction( testAction(
......
...@@ -48,15 +48,13 @@ describe('utils', () => { ...@@ -48,15 +48,13 @@ describe('utils', () => {
describe('getStatusTranslationsFromLicenseStatus', () => { describe('getStatusTranslationsFromLicenseStatus', () => {
it('returns "Allowed" for allowed license status', () => { it('returns "Allowed" for allowed license status', () => {
expect(getStatusTranslationsFromLicenseStatus(LICENSE_APPROVAL_STATUS.APPROVED)).toBe( expect(getStatusTranslationsFromLicenseStatus(LICENSE_APPROVAL_STATUS.ALLOWED)).toBe(
'Allowed', 'Allowed',
); );
}); });
it('returns "Denied" status for denied license status', () => { it('returns "Denied" status for denied license status', () => {
expect(getStatusTranslationsFromLicenseStatus(LICENSE_APPROVAL_STATUS.BLACKLISTED)).toBe( expect(getStatusTranslationsFromLicenseStatus(LICENSE_APPROVAL_STATUS.DENIED)).toBe('Denied');
'Denied',
);
}); });
it('returns "" for any other status', () => { it('returns "" for any other status', () => {
...@@ -66,15 +64,11 @@ describe('utils', () => { ...@@ -66,15 +64,11 @@ describe('utils', () => {
describe('getIssueStatusFromLicenseStatus', () => { describe('getIssueStatusFromLicenseStatus', () => {
it('returns SUCCESS status for approved license status', () => { it('returns SUCCESS status for approved license status', () => {
expect(getIssueStatusFromLicenseStatus(LICENSE_APPROVAL_STATUS.APPROVED)).toBe( expect(getIssueStatusFromLicenseStatus(LICENSE_APPROVAL_STATUS.ALLOWED)).toBe(STATUS_SUCCESS);
STATUS_SUCCESS,
);
}); });
it('returns FAILED status for blacklisted licensens', () => { it('returns FAILED status for blacklisted licenses', () => {
expect(getIssueStatusFromLicenseStatus(LICENSE_APPROVAL_STATUS.BLACKLISTED)).toBe( expect(getIssueStatusFromLicenseStatus(LICENSE_APPROVAL_STATUS.DENIED)).toBe(STATUS_FAILED);
STATUS_FAILED,
);
}); });
it('returns NEUTRAL status for undefined', () => { it('returns NEUTRAL status for undefined', () => {
...@@ -87,7 +81,7 @@ describe('utils', () => { ...@@ -87,7 +81,7 @@ describe('utils', () => {
name: 'license', name: 'license',
classification: { classification: {
id: 1, id: 1,
approval_status: LICENSE_APPROVAL_STATUS.APPROVED, approval_status: LICENSE_APPROVAL_STATUS.ALLOWED,
}, },
dependencies: [{ id: 1 }, { id: 2 }, { id: 3 }], dependencies: [{ id: 1 }, { id: 2 }, { id: 3 }],
}; };
......
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