Commit 61572b5b authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '12530-clarify-detected-license-results-in-mr-add-text-changes' into 'master'

Change summary text copy for license-compliance MR widget

See merge request gitlab-org/gitlab!28732
parents ac0df5b2 c8ad69ee
...@@ -120,15 +120,17 @@ export default { ...@@ -120,15 +120,17 @@ export default {
data-qa-selector="license_report_widget" data-qa-selector="license_report_widget"
> >
<template #success> <template #success>
{{ licenseSummaryText }} <div class="pr-3">
<gl-link {{ licenseSummaryText }}
v-if="reportContainsBlacklistedLicense && securityApprovalsHelpPagePath" <gl-link
:href="securityApprovalsHelpPagePath" v-if="reportContainsBlacklistedLicense && securityApprovalsHelpPagePath"
class="js-security-approval-help-link" :href="securityApprovalsHelpPagePath"
target="_blank" class="js-security-approval-help-link"
> target="_blank"
<icon :size="12" name="question" /> >
</gl-link> <icon :size="12" name="question" />
</gl-link>
</div>
</template> </template>
<div v-if="showActionButtons" slot="actionButtons" class="append-right-default"> <div v-if="showActionButtons" slot="actionButtons" class="append-right-default">
<a <a
......
...@@ -33,8 +33,8 @@ export const licenseSummaryText = (state, getters) => { ...@@ -33,8 +33,8 @@ export const licenseSummaryText = (state, getters) => {
if (!baseReportHasLicenses) { if (!baseReportHasLicenses) {
return getters.reportContainsBlacklistedLicense return getters.reportContainsBlacklistedLicense
? n__( ? n__(
'LicenseCompliance|License Compliance detected %d license for the source branch only; approval required', 'LicenseCompliance|License Compliance detected %d license and policy violation for the source branch only; approval required',
'LicenseCompliance|License Compliance detected %d licenses for the source branch only; approval required', 'LicenseCompliance|License Compliance detected %d licenses and policy violations for the source branch only; approval required',
licenseReportLength, licenseReportLength,
) )
: n__( : n__(
...@@ -46,8 +46,8 @@ export const licenseSummaryText = (state, getters) => { ...@@ -46,8 +46,8 @@ export const licenseSummaryText = (state, getters) => {
return getters.reportContainsBlacklistedLicense return getters.reportContainsBlacklistedLicense
? n__( ? n__(
'LicenseCompliance|License Compliance detected %d new license; approval required', 'LicenseCompliance|License Compliance detected %d new license and policy violation; approval required',
'LicenseCompliance|License Compliance detected %d new licenses; approval required', 'LicenseCompliance|License Compliance detected %d new licenses and policy violations; approval required',
licenseReportLength, licenseReportLength,
) )
: n__( : n__(
......
---
title: Change summary text copy for license-compliance MR widget
merge_request: 28732
author:
type: changed
...@@ -120,81 +120,49 @@ describe('getters', () => { ...@@ -120,81 +120,49 @@ describe('getters', () => {
); );
}); });
it('should be `License Compliance detected no new licenses`, if the report is empty', () => { it.each`
const mockGetters = { licenseReport: [] }; givenLicenseReport | givenReportContainsBlacklistedLicense | expectedSummaryText
${[]} | ${false} | ${'License Compliance detected no new licenses'}
expect(getters.licenseSummaryText(state, mockGetters)).toBe( ${[licenseReportMock[0]]} | ${false} | ${'License Compliance detected 1 new license'}
'License Compliance detected no new licenses', ${[licenseReportMock[0], licenseReportMock[0]]} | ${false} | ${'License Compliance detected 2 new licenses'}
); ${[licenseReportMock[0]]} | ${true} | ${'License Compliance detected 1 new license and policy violation; approval required'}
}); ${[licenseReportMock[0], licenseReportMock[0]]} | ${true} | ${'License Compliance detected 2 new licenses and policy violations; approval required'}
`(
it('should be `License Compliance detected 1 new license`, if the report has one element', () => { `should show "$expectedSummaryText" if the report contains $givenLicenseReport.length license(s) and contains blacklisted licenses is: $givenReportContainsBlacklistedLicense`,
const mockGetters = { licenseReport: [licenseReportMock[0]] }; ({ givenLicenseReport, givenReportContainsBlacklistedLicense, expectedSummaryText }) => {
const mockGetters = {
expect(getters.licenseSummaryText(state, mockGetters)).toBe( licenseReport: givenLicenseReport,
'License Compliance detected 1 new license', reportContainsBlacklistedLicense: givenReportContainsBlacklistedLicense,
); };
});
expect(getters.licenseSummaryText(state, mockGetters)).toBe(expectedSummaryText);
it('should be `License Compliance detected 2 new licenses`, if the report has two elements', () => { },
const mockGetters = { licenseReport: [licenseReportMock[0], licenseReportMock[0]] }; );
expect(getters.licenseSummaryText(state, mockGetters)).toBe(
'License Compliance detected 2 new licenses',
);
});
it('should be `License Compliance detected 2 new licenses; approval required`, if the report has two elements and including some blacklisted', () => {
const mockGetters = {
licenseReport: [licenseReportMock[0], licenseReportMock[0]],
reportContainsBlacklistedLicense: true,
};
expect(getters.licenseSummaryText(state, mockGetters)).toBe(
'License Compliance detected 2 new licenses; approval required',
);
});
}); });
describe('when there are no licences on the BASE', () => { describe('when there are no licenses on the BASE', () => {
beforeEach(() => { beforeEach(() => {
state = createState(); state = createState();
}); });
it('should be `License Compliance detected no licenses for the source branch only` with no new licences', () => { it.each`
const mockGetters = { licenseReport: [] }; givenLicenseReport | givenReportContainsBlacklistedLicense | expectedSummaryText
${[]} | ${false} | ${'License Compliance detected no licenses for the source branch only'}
expect(getters.licenseSummaryText(state, mockGetters)).toBe( ${[licenseReportMock[0]]} | ${false} | ${'License Compliance detected 1 license for the source branch only'}
'License Compliance detected no licenses for the source branch only', ${[licenseReportMock[0], licenseReportMock[0]]} | ${false} | ${'License Compliance detected 2 licenses for the source branch only'}
); ${[licenseReportMock[0]]} | ${true} | ${'License Compliance detected 1 license and policy violation for the source branch only; approval required'}
}); ${[licenseReportMock[0], licenseReportMock[0]]} | ${true} | ${'License Compliance detected 2 licenses and policy violations for the source branch only; approval required'}
`(
it('should be `License Compliance detected 1 license for the source branch only` with one new licence', () => { `should show "$expectedSummaryText" if the report contains $givenLicenseReport.length license(s) and contains blacklisted licenses is: $givenReportContainsBlacklistedLicense`,
const mockGetters = { licenseReport: [licenseReportMock[0]] }; ({ givenLicenseReport, givenReportContainsBlacklistedLicense, expectedSummaryText }) => {
const mockGetters = {
expect(getters.licenseSummaryText(state, mockGetters)).toBe( licenseReport: givenLicenseReport,
'License Compliance detected 1 license for the source branch only', reportContainsBlacklistedLicense: givenReportContainsBlacklistedLicense,
); };
});
expect(getters.licenseSummaryText(state, mockGetters)).toBe(expectedSummaryText);
it('should be `License Compliance detected 2 licenses for the source branch only` with two new licences', () => { },
const mockGetters = { licenseReport: [licenseReportMock[0], licenseReportMock[0]] }; );
expect(getters.licenseSummaryText(state, mockGetters)).toBe(
'License Compliance detected 2 licenses for the source branch only',
);
});
it('should be `License Compliance detected 2 licenses for the source branch only; approval required` with two new licences including some blacklisted', () => {
const mockGetters = {
licenseReport: [licenseReportMock[0], licenseReportMock[0]],
reportContainsBlacklistedLicense: true,
};
expect(getters.licenseSummaryText(state, mockGetters)).toBe(
'License Compliance detected 2 licenses for the source branch only; approval required',
);
});
}); });
}); });
......
...@@ -11878,13 +11878,13 @@ msgstr "" ...@@ -11878,13 +11878,13 @@ msgstr ""
msgid "LicenseCompliance|License Compliance" msgid "LicenseCompliance|License Compliance"
msgstr "" msgstr ""
msgid "LicenseCompliance|License Compliance detected %d license for the source branch only" msgid "LicenseCompliance|License Compliance detected %d license and policy violation for the source branch only; approval required"
msgid_plural "LicenseCompliance|License Compliance detected %d licenses for the source branch only" msgid_plural "LicenseCompliance|License Compliance detected %d licenses and policy violations for the source branch only; approval required"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
msgid "LicenseCompliance|License Compliance detected %d license for the source branch only; approval required" msgid "LicenseCompliance|License Compliance detected %d license for the source branch only"
msgid_plural "LicenseCompliance|License Compliance detected %d licenses for the source branch only; approval required" msgid_plural "LicenseCompliance|License Compliance detected %d licenses for the source branch only"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
...@@ -11893,8 +11893,8 @@ msgid_plural "LicenseCompliance|License Compliance detected %d new licenses" ...@@ -11893,8 +11893,8 @@ msgid_plural "LicenseCompliance|License Compliance detected %d new licenses"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
msgid "LicenseCompliance|License Compliance detected %d new license; approval required" msgid "LicenseCompliance|License Compliance detected %d new license and policy violation; approval required"
msgid_plural "LicenseCompliance|License Compliance detected %d new licenses; approval required" msgid_plural "LicenseCompliance|License Compliance detected %d new licenses and policy violations; approval required"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
......
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