summaryrefslogtreecommitdiff
path: root/spec/frontend/security_configuration/components
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/security_configuration/components')
-rw-r--r--spec/frontend/security_configuration/components/auto_dev_ops_alert_spec.js55
-rw-r--r--spec/frontend/security_configuration/components/feature_card_spec.js25
-rw-r--r--spec/frontend/security_configuration/components/redesigned_app_spec.js82
3 files changed, 144 insertions, 18 deletions
diff --git a/spec/frontend/security_configuration/components/auto_dev_ops_alert_spec.js b/spec/frontend/security_configuration/components/auto_dev_ops_alert_spec.js
new file mode 100644
index 00000000000..467ae35408c
--- /dev/null
+++ b/spec/frontend/security_configuration/components/auto_dev_ops_alert_spec.js
@@ -0,0 +1,55 @@
+import { GlAlert } from '@gitlab/ui';
+import { mount } from '@vue/test-utils';
+import AutoDevopsAlert from '~/security_configuration/components/auto_dev_ops_alert.vue';
+
+const autoDevopsHelpPagePath = '/autoDevopsHelpPagePath';
+const autoDevopsPath = '/enableAutoDevopsPath';
+
+describe('AutoDevopsAlert component', () => {
+ let wrapper;
+
+ const createComponent = () => {
+ wrapper = mount(AutoDevopsAlert, {
+ provide: {
+ autoDevopsHelpPagePath,
+ autoDevopsPath,
+ },
+ });
+ };
+
+ const findAlert = () => wrapper.findComponent(GlAlert);
+
+ beforeEach(() => {
+ createComponent();
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('contains correct body text', () => {
+ expect(wrapper.text()).toContain('Quickly enable all');
+ });
+
+ it('renders the link correctly', () => {
+ const link = wrapper.find('a');
+
+ expect(link.attributes('href')).toBe(autoDevopsHelpPagePath);
+ expect(link.text()).toBe('Auto DevOps');
+ });
+
+ it('bubbles up dismiss events from the GlAlert', () => {
+ expect(wrapper.emitted('dismiss')).toBe(undefined);
+
+ findAlert().vm.$emit('dismiss');
+
+ expect(wrapper.emitted('dismiss')).toEqual([[]]);
+ });
+
+ it('has a button pointing to autoDevopsPath', () => {
+ expect(findAlert().props()).toMatchObject({
+ primaryButtonText: 'Enable Auto DevOps',
+ primaryButtonLink: autoDevopsPath,
+ });
+ });
+});
diff --git a/spec/frontend/security_configuration/components/feature_card_spec.js b/spec/frontend/security_configuration/components/feature_card_spec.js
index c69e135012e..3658dbb5ef2 100644
--- a/spec/frontend/security_configuration/components/feature_card_spec.js
+++ b/spec/frontend/security_configuration/components/feature_card_spec.js
@@ -3,6 +3,7 @@ import { mount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import FeatureCard from '~/security_configuration/components/feature_card.vue';
import ManageViaMr from '~/vue_shared/security_configuration/components/manage_via_mr.vue';
+import { REPORT_TYPE_SAST } from '~/vue_shared/security_reports/constants';
import { makeFeature } from './utils';
describe('FeatureCard component', () => {
@@ -126,21 +127,23 @@ describe('FeatureCard component', () => {
describe('actions', () => {
describe.each`
- context | available | configured | configurationPath | canEnableByMergeRequest | action
- ${'unavailable'} | ${false} | ${false} | ${null} | ${false} | ${null}
- ${'available'} | ${true} | ${false} | ${null} | ${false} | ${'guide'}
- ${'configured'} | ${true} | ${true} | ${null} | ${false} | ${'guide'}
- ${'available, can enable by MR'} | ${true} | ${false} | ${null} | ${true} | ${'create-mr'}
- ${'configured, can enable by MR'} | ${true} | ${true} | ${null} | ${true} | ${'guide'}
- ${'available with config path'} | ${true} | ${false} | ${'foo'} | ${false} | ${'enable'}
- ${'available with config path, can enable by MR'} | ${true} | ${false} | ${'foo'} | ${true} | ${'enable'}
- ${'configured with config path'} | ${true} | ${true} | ${'foo'} | ${false} | ${'configure'}
- ${'configured with config path, can enable by MR'} | ${true} | ${true} | ${'foo'} | ${true} | ${'configure'}
+ context | type | available | configured | configurationPath | canEnableByMergeRequest | action
+ ${'unavailable'} | ${REPORT_TYPE_SAST} | ${false} | ${false} | ${null} | ${false} | ${null}
+ ${'available'} | ${REPORT_TYPE_SAST} | ${true} | ${false} | ${null} | ${false} | ${'guide'}
+ ${'configured'} | ${REPORT_TYPE_SAST} | ${true} | ${true} | ${null} | ${false} | ${'guide'}
+ ${'available, can enable by MR'} | ${REPORT_TYPE_SAST} | ${true} | ${false} | ${null} | ${true} | ${'create-mr'}
+ ${'available, can enable by MR, unknown type'} | ${'foo'} | ${true} | ${false} | ${null} | ${true} | ${'guide'}
+ ${'configured, can enable by MR'} | ${REPORT_TYPE_SAST} | ${true} | ${true} | ${null} | ${true} | ${'guide'}
+ ${'available with config path'} | ${REPORT_TYPE_SAST} | ${true} | ${false} | ${'foo'} | ${false} | ${'enable'}
+ ${'available with config path, can enable by MR'} | ${REPORT_TYPE_SAST} | ${true} | ${false} | ${'foo'} | ${true} | ${'enable'}
+ ${'configured with config path'} | ${REPORT_TYPE_SAST} | ${true} | ${true} | ${'foo'} | ${false} | ${'configure'}
+ ${'configured with config path, can enable by MR'} | ${REPORT_TYPE_SAST} | ${true} | ${true} | ${'foo'} | ${true} | ${'configure'}
`(
'given $context feature',
- ({ available, configured, configurationPath, canEnableByMergeRequest, action }) => {
+ ({ type, available, configured, configurationPath, canEnableByMergeRequest, action }) => {
beforeEach(() => {
feature = makeFeature({
+ type,
available,
configured,
configurationPath,
diff --git a/spec/frontend/security_configuration/components/redesigned_app_spec.js b/spec/frontend/security_configuration/components/redesigned_app_spec.js
index 7e27a3e1108..119a25a77c1 100644
--- a/spec/frontend/security_configuration/components/redesigned_app_spec.js
+++ b/spec/frontend/security_configuration/components/redesigned_app_spec.js
@@ -2,6 +2,7 @@ import { GlTab } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import { makeMockUserCalloutDismisser } from 'helpers/mock_user_callout_dismisser';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
+import AutoDevopsAlert from '~/security_configuration/components/auto_dev_ops_alert.vue';
import {
SAST_NAME,
SAST_SHORT_NAME,
@@ -13,6 +14,7 @@ import {
LICENSE_COMPLIANCE_HELP_PATH,
} from '~/security_configuration/components/constants';
import FeatureCard from '~/security_configuration/components/feature_card.vue';
+
import RedesignedSecurityConfigurationApp, {
i18n,
} from '~/security_configuration/components/redesigned_app.vue';
@@ -23,6 +25,9 @@ import {
} from '~/vue_shared/security_reports/constants';
const upgradePath = '/upgrade';
+const autoDevopsHelpPagePath = '/autoDevopsHelpPagePath';
+const autoDevopsPath = '/autoDevopsPath';
+const gitlabCiHistoryPath = 'test/historyPath';
describe('redesigned App component', () => {
let wrapper;
@@ -36,6 +41,8 @@ describe('redesigned App component', () => {
propsData,
provide: {
upgradePath,
+ autoDevopsHelpPagePath,
+ autoDevopsPath,
},
stubs: {
UserCalloutDismisser: makeMockUserCalloutDismisser({
@@ -52,9 +59,30 @@ describe('redesigned App component', () => {
const findTabs = () => wrapper.findAllComponents(GlTab);
const findByTestId = (id) => wrapper.findByTestId(id);
const findFeatureCards = () => wrapper.findAllComponents(FeatureCard);
- const findComplianceViewHistoryLink = () => findByTestId('compliance-view-history-link');
- const findSecurityViewHistoryLink = () => findByTestId('security-view-history-link');
+ const findLink = ({ href, text, container = wrapper }) => {
+ const selector = `a[href="${href}"]`;
+ const link = container.find(selector);
+
+ if (link.exists() && link.text() === text) {
+ return link;
+ }
+
+ return wrapper.find(`${selector} does not exist`);
+ };
+ const findSecurityViewHistoryLink = () =>
+ findLink({
+ href: gitlabCiHistoryPath,
+ text: i18n.configurationHistory,
+ container: findByTestId('security-testing-tab'),
+ });
+ const findComplianceViewHistoryLink = () =>
+ findLink({
+ href: gitlabCiHistoryPath,
+ text: i18n.configurationHistory,
+ container: findByTestId('compliance-testing-tab'),
+ });
const findUpgradeBanner = () => wrapper.findComponent(UpgradeBanner);
+ const findAutoDevopsAlert = () => wrapper.findComponent(AutoDevopsAlert);
const securityFeaturesMock = [
{
@@ -119,6 +147,10 @@ describe('redesigned App component', () => {
expect(cards.at(1).props()).toEqual({ feature: complianceFeaturesMock[0] });
});
+ it('renders a basic description', () => {
+ expect(wrapper.text()).toContain(i18n.description);
+ });
+
it('should not show latest pipeline link when latestPipelinePath is not defined', () => {
expect(findByTestId('latest-pipeline-info').exists()).toBe(false);
});
@@ -129,6 +161,44 @@ describe('redesigned App component', () => {
});
});
+ describe('autoDevOpsAlert', () => {
+ describe('given the right props', () => {
+ beforeEach(() => {
+ createComponent({
+ augmentedSecurityFeatures: securityFeaturesMock,
+ augmentedComplianceFeatures: complianceFeaturesMock,
+ autoDevopsEnabled: false,
+ gitlabCiPresent: false,
+ canEnableAutoDevops: true,
+ });
+ });
+
+ it('should show AutoDevopsAlert', () => {
+ expect(findAutoDevopsAlert().exists()).toBe(true);
+ });
+
+ it('calls the dismiss callback when closing the AutoDevopsAlert', () => {
+ expect(userCalloutDismissSpy).not.toHaveBeenCalled();
+
+ findAutoDevopsAlert().vm.$emit('dismiss');
+
+ expect(userCalloutDismissSpy).toHaveBeenCalledTimes(1);
+ });
+ });
+
+ describe('given the wrong props', () => {
+ beforeEach(() => {
+ createComponent({
+ augmentedSecurityFeatures: securityFeaturesMock,
+ augmentedComplianceFeatures: complianceFeaturesMock,
+ });
+ });
+ it('should not show AutoDevopsAlert', () => {
+ expect(findAutoDevopsAlert().exists()).toBe(false);
+ });
+ });
+ });
+
describe('upgrade banner', () => {
const makeAvailable = (available) => (feature) => ({ ...feature, available });
@@ -193,9 +263,8 @@ describe('redesigned App component', () => {
it('should show latest pipeline info on the security tab with correct link when latestPipelinePath is defined', () => {
const latestPipelineInfoSecurity = findByTestId('latest-pipeline-info-security');
- expect(latestPipelineInfoSecurity.exists()).toBe(true);
expect(latestPipelineInfoSecurity.text()).toMatchInterpolatedText(
- i18n.securityTestingDescription,
+ i18n.latestPipelineDescription,
);
expect(latestPipelineInfoSecurity.find('a').attributes('href')).toBe('test/path');
});
@@ -203,9 +272,8 @@ describe('redesigned App component', () => {
it('should show latest pipeline info on the compliance tab with correct link when latestPipelinePath is defined', () => {
const latestPipelineInfoCompliance = findByTestId('latest-pipeline-info-compliance');
- expect(latestPipelineInfoCompliance.exists()).toBe(true);
expect(latestPipelineInfoCompliance.text()).toMatchInterpolatedText(
- i18n.securityTestingDescription,
+ i18n.latestPipelineDescription,
);
expect(latestPipelineInfoCompliance.find('a').attributes('href')).toBe('test/path');
});
@@ -217,7 +285,7 @@ describe('redesigned App component', () => {
augmentedSecurityFeatures: securityFeaturesMock,
augmentedComplianceFeatures: complianceFeaturesMock,
gitlabCiPresent: true,
- gitlabCiHistoryPath: 'test/historyPath',
+ gitlabCiHistoryPath,
});
});