Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-03 09:19:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-03 09:19:54 +0300
commit74081733481d7d3d480a5e887ac768fe30f84055 (patch)
tree816e1fbfd090eaf05a2d16a711ff891cb0acbf08 /spec/frontend/security_configuration
parent8d94a37915dfc305c8217fe7e8e4d00928aa88cf (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/security_configuration')
-rw-r--r--spec/frontend/security_configuration/components/app_spec.js109
-rw-r--r--spec/frontend/security_configuration/components/upgrade_banner_spec.js106
-rw-r--r--spec/frontend/security_configuration/mock_data.js45
3 files changed, 51 insertions, 209 deletions
diff --git a/spec/frontend/security_configuration/components/app_spec.js b/spec/frontend/security_configuration/components/app_spec.js
index ec47cda1cb2..c4e6bef71eb 100644
--- a/spec/frontend/security_configuration/components/app_spec.js
+++ b/spec/frontend/security_configuration/components/app_spec.js
@@ -8,61 +8,21 @@ import { mountExtended } from 'helpers/vue_test_utils_helper';
import SecurityConfigurationApp, { i18n } from '~/security_configuration/components/app.vue';
import AutoDevopsAlert from '~/security_configuration/components/auto_dev_ops_alert.vue';
import AutoDevopsEnabledAlert from '~/security_configuration/components/auto_dev_ops_enabled_alert.vue';
-import {
- SAST_NAME,
- SAST_SHORT_NAME,
- SAST_DESCRIPTION,
- SAST_HELP_PATH,
- SAST_CONFIG_HELP_PATH,
- LICENSE_COMPLIANCE_NAME,
- LICENSE_COMPLIANCE_DESCRIPTION,
- LICENSE_COMPLIANCE_HELP_PATH,
- AUTO_DEVOPS_ENABLED_ALERT_DISMISSED_STORAGE_KEY,
-} from '~/security_configuration/components/constants';
+import { AUTO_DEVOPS_ENABLED_ALERT_DISMISSED_STORAGE_KEY } from '~/security_configuration/components/constants';
import FeatureCard from '~/security_configuration/components/feature_card.vue';
import TrainingProviderList from '~/security_configuration/components/training_provider_list.vue';
-import UpgradeBanner from '~/security_configuration/components/upgrade_banner.vue';
-import {
- REPORT_TYPE_LICENSE_COMPLIANCE,
- REPORT_TYPE_SAST,
-} from '~/vue_shared/security_reports/constants';
-
-const upgradePath = '/upgrade';
-const autoDevopsHelpPagePath = '/autoDevopsHelpPagePath';
-const autoDevopsPath = '/autoDevopsPath';
+import { complianceFeaturesMock, securityFeaturesMock, provideMock } from '../mock_data';
+
const gitlabCiHistoryPath = 'test/historyPath';
-const projectFullPath = 'namespace/project';
-const vulnerabilityTrainingDocsPath = 'user/application_security/vulnerabilities/index';
+const { vulnerabilityTrainingDocsPath, projectFullPath } = provideMock;
useLocalStorageSpy();
Vue.use(VueApollo);
-describe('App component', () => {
+describe('~/security_configuration/components/app', () => {
let wrapper;
let userCalloutDismissSpy;
- const securityFeaturesMock = [
- {
- name: SAST_NAME,
- shortName: SAST_SHORT_NAME,
- description: SAST_DESCRIPTION,
- helpPath: SAST_HELP_PATH,
- configurationHelpPath: SAST_CONFIG_HELP_PATH,
- type: REPORT_TYPE_SAST,
- available: true,
- },
- ];
-
- const complianceFeaturesMock = [
- {
- name: LICENSE_COMPLIANCE_NAME,
- description: LICENSE_COMPLIANCE_DESCRIPTION,
- helpPath: LICENSE_COMPLIANCE_HELP_PATH,
- type: REPORT_TYPE_LICENSE_COMPLIANCE,
- configurationHelpPath: LICENSE_COMPLIANCE_HELP_PATH,
- },
- ];
-
const createComponent = ({ shouldShowCallout = true, ...propsData } = {}) => {
userCalloutDismissSpy = jest.fn();
@@ -73,13 +33,7 @@ describe('App component', () => {
securityTrainingEnabled: true,
...propsData,
},
- provide: {
- upgradePath,
- autoDevopsHelpPagePath,
- autoDevopsPath,
- projectFullPath,
- vulnerabilityTrainingDocsPath,
- },
+ provide: provideMock,
stubs: {
...stubChildren(SecurityConfigurationApp),
GlLink: false,
@@ -124,7 +78,6 @@ describe('App component', () => {
text: i18n.configurationHistory,
container: findByTestId('compliance-testing-tab'),
});
- const findUpgradeBanner = () => wrapper.findComponent(UpgradeBanner);
const findAutoDevopsAlert = () => wrapper.findComponent(AutoDevopsAlert);
const findAutoDevopsEnabledAlert = () => wrapper.findComponent(AutoDevopsEnabledAlert);
const findVulnerabilityManagementTab = () => wrapper.findByTestId('vulnerability-management-tab');
@@ -326,56 +279,6 @@ describe('App component', () => {
});
});
- describe('upgrade banner', () => {
- const makeAvailable = (available) => (feature) => ({ ...feature, available });
-
- describe('given at least one unavailable feature', () => {
- beforeEach(() => {
- createComponent({
- augmentedComplianceFeatures: complianceFeaturesMock.map(makeAvailable(false)),
- });
- });
-
- it('renders the banner', () => {
- expect(findUpgradeBanner().exists()).toBe(true);
- });
-
- it('calls the dismiss callback when closing the banner', () => {
- expect(userCalloutDismissSpy).not.toHaveBeenCalled();
-
- findUpgradeBanner().vm.$emit('close');
-
- expect(userCalloutDismissSpy).toHaveBeenCalledTimes(1);
- });
- });
-
- describe('given at least one unavailable feature, but banner is already dismissed', () => {
- beforeEach(() => {
- createComponent({
- augmentedComplianceFeatures: complianceFeaturesMock.map(makeAvailable(false)),
- shouldShowCallout: false,
- });
- });
-
- it('does not render the banner', () => {
- expect(findUpgradeBanner().exists()).toBe(false);
- });
- });
-
- describe('given all features are available', () => {
- beforeEach(() => {
- createComponent({
- augmentedSecurityFeatures: securityFeaturesMock.map(makeAvailable(true)),
- augmentedComplianceFeatures: complianceFeaturesMock.map(makeAvailable(true)),
- });
- });
-
- it('does not render the banner', () => {
- expect(findUpgradeBanner().exists()).toBe(false);
- });
- });
- });
-
describe('when given latestPipelinePath props', () => {
beforeEach(() => {
createComponent({
diff --git a/spec/frontend/security_configuration/components/upgrade_banner_spec.js b/spec/frontend/security_configuration/components/upgrade_banner_spec.js
deleted file mode 100644
index 97087877224..00000000000
--- a/spec/frontend/security_configuration/components/upgrade_banner_spec.js
+++ /dev/null
@@ -1,106 +0,0 @@
-import { GlBanner } from '@gitlab/ui';
-import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
-import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
-import UpgradeBanner, {
- SECURITY_UPGRADE_BANNER,
- UPGRADE_OR_FREE_TRIAL,
-} from '~/security_configuration/components/upgrade_banner.vue';
-
-const upgradePath = '/upgrade';
-
-describe('UpgradeBanner component', () => {
- let wrapper;
- let closeSpy;
- let primarySpy;
- let trackingSpy;
-
- const createComponent = (propsData) => {
- closeSpy = jest.fn();
- primarySpy = jest.fn();
-
- wrapper = shallowMountExtended(UpgradeBanner, {
- provide: {
- upgradePath,
- },
- propsData,
- listeners: {
- close: closeSpy,
- primary: primarySpy,
- },
- });
- };
-
- const findGlBanner = () => wrapper.findComponent(GlBanner);
-
- const expectTracking = (action, label) => {
- return expect(trackingSpy).toHaveBeenCalledWith(undefined, action, {
- label,
- property: SECURITY_UPGRADE_BANNER,
- });
- };
-
- beforeEach(() => {
- trackingSpy = mockTracking(undefined, undefined, jest.spyOn);
- });
-
- afterEach(() => {
- unmockTracking();
- });
-
- describe('when the component renders', () => {
- it('tracks an event', () => {
- expect(trackingSpy).not.toHaveBeenCalled();
-
- createComponent();
-
- expectTracking('render', SECURITY_UPGRADE_BANNER);
- });
- });
-
- describe('when ready', () => {
- beforeEach(() => {
- createComponent();
- trackingSpy.mockClear();
- });
-
- it('passes the expected props to GlBanner', () => {
- expect(findGlBanner().props()).toMatchObject({
- title: UpgradeBanner.i18n.title,
- buttonText: UpgradeBanner.i18n.buttonText,
- buttonLink: upgradePath,
- });
- });
-
- it('renders the list of benefits', () => {
- const wrapperText = wrapper.text();
-
- expect(wrapperText).toContain('Immediately begin risk analysis and remediation');
- expect(wrapperText).toContain('statistics in the merge request');
- expect(wrapperText).toContain('statistics across projects');
- expect(wrapperText).toContain('Runtime security metrics');
- expect(wrapperText).toContain('More scan types, including DAST,');
- });
-
- describe('when user interacts', () => {
- it(`re-emits GlBanner's close event & tracks an event`, () => {
- expect(closeSpy).not.toHaveBeenCalled();
- expect(trackingSpy).not.toHaveBeenCalled();
-
- wrapper.findComponent(GlBanner).vm.$emit('close');
-
- expect(closeSpy).toHaveBeenCalledTimes(1);
- expectTracking('dismiss_banner', SECURITY_UPGRADE_BANNER);
- });
-
- it(`re-emits GlBanner's primary event & tracks an event`, () => {
- expect(primarySpy).not.toHaveBeenCalled();
- expect(trackingSpy).not.toHaveBeenCalled();
-
- wrapper.findComponent(GlBanner).vm.$emit('primary');
-
- expect(primarySpy).toHaveBeenCalledTimes(1);
- expectTracking('click_button', UPGRADE_OR_FREE_TRIAL);
- });
- });
- });
-});
diff --git a/spec/frontend/security_configuration/mock_data.js b/spec/frontend/security_configuration/mock_data.js
index 2fe3b59cea3..24ad8024b01 100644
--- a/spec/frontend/security_configuration/mock_data.js
+++ b/spec/frontend/security_configuration/mock_data.js
@@ -1,3 +1,18 @@
+import {
+ SAST_NAME,
+ SAST_SHORT_NAME,
+ SAST_DESCRIPTION,
+ SAST_HELP_PATH,
+ SAST_CONFIG_HELP_PATH,
+ LICENSE_COMPLIANCE_NAME,
+ LICENSE_COMPLIANCE_DESCRIPTION,
+ LICENSE_COMPLIANCE_HELP_PATH,
+} from '~/security_configuration/components/constants';
+import {
+ REPORT_TYPE_LICENSE_COMPLIANCE,
+ REPORT_TYPE_SAST,
+} from '~/vue_shared/security_reports/constants';
+
export const testProjectPath = 'foo/bar';
export const testProviderIds = [101, 102, 103];
export const testProviderName = ['Kontra', 'Secure Code Warrior', 'Other Vendor'];
@@ -100,3 +115,33 @@ export const updateSecurityTrainingProvidersErrorResponse = {
},
},
};
+
+export const securityFeaturesMock = [
+ {
+ name: SAST_NAME,
+ shortName: SAST_SHORT_NAME,
+ description: SAST_DESCRIPTION,
+ helpPath: SAST_HELP_PATH,
+ configurationHelpPath: SAST_CONFIG_HELP_PATH,
+ type: REPORT_TYPE_SAST,
+ available: true,
+ },
+];
+
+export const complianceFeaturesMock = [
+ {
+ name: LICENSE_COMPLIANCE_NAME,
+ description: LICENSE_COMPLIANCE_DESCRIPTION,
+ helpPath: LICENSE_COMPLIANCE_HELP_PATH,
+ type: REPORT_TYPE_LICENSE_COMPLIANCE,
+ configurationHelpPath: LICENSE_COMPLIANCE_HELP_PATH,
+ },
+];
+
+export const provideMock = {
+ upgradePath: '/upgrade',
+ autoDevopsHelpPagePath: '/autoDevopsHelpPagePath',
+ autoDevopsPath: '/autoDevopsPath',
+ projectFullPath: 'namespace/project',
+ vulnerabilityTrainingDocsPath: 'user/application_security/vulnerabilities/index',
+};