Commit 9d6f4599 authored by Fernando's avatar Fernando

Maintainer feedback changes

* Add additional unit tests around fetching approval rules
* Clean up unit tests
* Fix button/text alignment
* Remove uneeded prop for api path in pipeline context
parent b5064077
...@@ -15,7 +15,6 @@ export default () => { ...@@ -15,7 +15,6 @@ export default () => {
apiUrl, apiUrl,
licenseManagementSettingsPath, licenseManagementSettingsPath,
licensesApiPath, licensesApiPath,
approvalsApiPath,
} = licensesTab.dataset; } = licensesTab.dataset;
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
...@@ -30,7 +29,6 @@ export default () => { ...@@ -30,7 +29,6 @@ export default () => {
apiUrl, apiUrl,
licensesApiPath, licensesApiPath,
licenseManagementSettingsPath, licenseManagementSettingsPath,
approvalsApiPath,
canManageLicenses: parseBoolean(canManageLicenses), canManageLicenses: parseBoolean(canManageLicenses),
alwaysOpen: true, alwaysOpen: true,
reportSectionClass: 'split-report-section', reportSectionClass: 'split-report-section',
......
...@@ -12,14 +12,14 @@ export default { ...@@ -12,14 +12,14 @@ export default {
</script> </script>
<template> <template>
<div class="mr-widget-body media"> <div class="mr-widget-body media">
<div class="space-children"> <div class="space-children d-flex">
<status-icon status="warning" /> <status-icon status="warning" />
<gl-button category="primary" variant="success" disabled size="small"> <gl-button category="primary" variant="success" disabled size="small">
{{ s__('mrWidget|Merge') }} {{ s__('mrWidget|Merge') }}
</gl-button> </gl-button>
</div> </div>
<div class="media-body"> <div class="media-body">
<strong> <strong class="bold">
{{ s__('mrWidget|You can only merge once the denied license is removed') }} {{ s__('mrWidget|You can only merge once the denied license is removed') }}
</strong> </strong>
</div> </div>
......
...@@ -21,7 +21,7 @@ export const licenseReportGroups = state => ...@@ -21,7 +21,7 @@ export const licenseReportGroups = state =>
); );
export const hasReportItems = (_, getters) => { export const hasReportItems = (_, getters) => {
return Boolean(getters.licenseReport?.length); return Boolean(getters.licenseReportLength);
}; };
export const baseReportHasLicenses = state => { export const baseReportHasLicenses = state => {
......
...@@ -22,7 +22,7 @@ describe('EE MrWidgetPolicyViolation', () => { ...@@ -22,7 +22,7 @@ describe('EE MrWidgetPolicyViolation', () => {
it('shows the disabled merge button', () => { it('shows the disabled merge button', () => {
expect(wrapper.text()).toContain('Merge'); expect(wrapper.text()).toContain('Merge');
expect(findButton().attributes().disabled).toBe('true'); expect(findButton().props().disabled).toBe(true);
}); });
it('shows the disabled reason', () => { it('shows the disabled reason', () => {
......
...@@ -339,11 +339,68 @@ describe('License Report MR Widget', () => { ...@@ -339,11 +339,68 @@ describe('License Report MR Widget', () => {
expect(wrapper.find('#modal-set-license-approval')).not.toBeNull(); expect(wrapper.find('#modal-set-license-approval')).not.toBeNull();
}); });
describe('with approvalsApiPath prop set', () => {
it('should init store after mount calling fetchLicenseCheckApprovalRule', () => {
const actions = {
...defaultActions,
setAPISettings: jest.fn(),
fetchLicenseCheckApprovalRule: jest.fn(),
};
mountComponent({ actions });
expect(actions.setAPISettings).toHaveBeenCalledWith(
expect.any(Object),
{
apiUrlManageLicenses: apiUrl,
licensesApiPath: defaultProps.licensesApiPath,
approvalsApiPath: defaultProps.approvalsApiPath,
canManageLicenses: true,
},
undefined,
);
expect(actions.fetchLicenseCheckApprovalRule).toHaveBeenCalledWith(
expect.any(Object),
undefined,
undefined,
);
});
});
describe('with approvalsApiPath prop unset', () => {
it('should init store after mount without calling fetchLicenseCheckApprovalRule', () => {
const props = {
...defaultProps,
approvalsApiPath: '',
};
const actions = {
...defaultActions,
setAPISettings: jest.fn(),
fetchLicenseCheckApprovalRule: jest.fn(),
};
mountComponent({ actions, props });
expect(actions.setAPISettings).toHaveBeenCalledWith(
expect.any(Object),
{
apiUrlManageLicenses: apiUrl,
licensesApiPath: defaultProps.licensesApiPath,
canManageLicenses: true,
approvalsApiPath: '',
},
undefined,
);
expect(actions.fetchLicenseCheckApprovalRule).not.toHaveBeenCalled();
});
});
it('should init store after mount', () => { it('should init store after mount', () => {
const actions = { const actions = {
setAPISettings: jest.fn(() => {}), setAPISettings: jest.fn(),
fetchParsedLicenseReport: jest.fn(() => {}), fetchParsedLicenseReport: jest.fn(),
fetchLicenseCheckApprovalRule: jest.fn(() => {}), fetchLicenseCheckApprovalRule: jest.fn(),
}; };
mountComponent({ actions }); mountComponent({ actions });
......
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