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 () => {
apiUrl,
licenseManagementSettingsPath,
licensesApiPath,
approvalsApiPath,
} = licensesTab.dataset;
// eslint-disable-next-line no-new
......@@ -30,7 +29,6 @@ export default () => {
apiUrl,
licensesApiPath,
licenseManagementSettingsPath,
approvalsApiPath,
canManageLicenses: parseBoolean(canManageLicenses),
alwaysOpen: true,
reportSectionClass: 'split-report-section',
......
......@@ -12,14 +12,14 @@ export default {
</script>
<template>
<div class="mr-widget-body media">
<div class="space-children">
<div class="space-children d-flex">
<status-icon status="warning" />
<gl-button category="primary" variant="success" disabled size="small">
{{ s__('mrWidget|Merge') }}
</gl-button>
</div>
<div class="media-body">
<strong>
<strong class="bold">
{{ s__('mrWidget|You can only merge once the denied license is removed') }}
</strong>
</div>
......
......@@ -21,7 +21,7 @@ export const licenseReportGroups = state =>
);
export const hasReportItems = (_, getters) => {
return Boolean(getters.licenseReport?.length);
return Boolean(getters.licenseReportLength);
};
export const baseReportHasLicenses = state => {
......
......@@ -22,7 +22,7 @@ describe('EE MrWidgetPolicyViolation', () => {
it('shows the disabled merge button', () => {
expect(wrapper.text()).toContain('Merge');
expect(findButton().attributes().disabled).toBe('true');
expect(findButton().props().disabled).toBe(true);
});
it('shows the disabled reason', () => {
......
......@@ -339,11 +339,68 @@ describe('License Report MR Widget', () => {
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', () => {
const actions = {
setAPISettings: jest.fn(() => {}),
fetchParsedLicenseReport: jest.fn(() => {}),
fetchLicenseCheckApprovalRule: jest.fn(() => {}),
setAPISettings: jest.fn(),
fetchParsedLicenseReport: jest.fn(),
fetchLicenseCheckApprovalRule: jest.fn(),
};
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