2022-07-16 23:28:13 +05:30
|
|
|
import Vue, { nextTick } from 'vue';
|
|
|
|
import VueApollo from 'vue-apollo';
|
2022-06-21 17:19:12 +05:30
|
|
|
import { GlTab, GlTabs, GlLink } from '@gitlab/ui';
|
2021-10-27 15:23:28 +05:30
|
|
|
import { useLocalStorageSpy } from 'helpers/local_storage_helper';
|
2021-09-04 01:27:46 +05:30
|
|
|
import { makeMockUserCalloutDismisser } from 'helpers/mock_user_callout_dismisser';
|
2021-10-27 15:23:28 +05:30
|
|
|
import stubChildren from 'helpers/stub_children';
|
2022-08-13 15:12:31 +05:30
|
|
|
import { mountExtended } from 'helpers/vue_test_utils_helper';
|
2021-10-27 15:23:28 +05:30
|
|
|
import SecurityConfigurationApp, { i18n } from '~/security_configuration/components/app.vue';
|
2021-09-30 23:02:18 +05:30
|
|
|
import AutoDevopsAlert from '~/security_configuration/components/auto_dev_ops_alert.vue';
|
2021-10-27 15:23:28 +05:30
|
|
|
import AutoDevopsEnabledAlert from '~/security_configuration/components/auto_dev_ops_enabled_alert.vue';
|
2021-09-04 01:27:46 +05:30
|
|
|
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,
|
2021-10-27 15:23:28 +05:30
|
|
|
AUTO_DEVOPS_ENABLED_ALERT_DISMISSED_STORAGE_KEY,
|
2021-09-04 01:27:46 +05:30
|
|
|
} from '~/security_configuration/components/constants';
|
|
|
|
import FeatureCard from '~/security_configuration/components/feature_card.vue';
|
2022-01-26 12:08:38 +05:30
|
|
|
import TrainingProviderList from '~/security_configuration/components/training_provider_list.vue';
|
2021-09-04 01:27:46 +05:30
|
|
|
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';
|
2021-09-30 23:02:18 +05:30
|
|
|
const autoDevopsHelpPagePath = '/autoDevopsHelpPagePath';
|
|
|
|
const autoDevopsPath = '/autoDevopsPath';
|
|
|
|
const gitlabCiHistoryPath = 'test/historyPath';
|
2022-04-04 11:22:00 +05:30
|
|
|
const projectFullPath = 'namespace/project';
|
2022-06-21 17:19:12 +05:30
|
|
|
const vulnerabilityTrainingDocsPath = 'user/application_security/vulnerabilities/index';
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
useLocalStorageSpy();
|
2022-07-16 23:28:13 +05:30
|
|
|
Vue.use(VueApollo);
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
describe('App component', () => {
|
2021-09-04 01:27:46 +05:30
|
|
|
let wrapper;
|
|
|
|
let userCalloutDismissSpy;
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
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 } = {}) => {
|
2021-09-04 01:27:46 +05:30
|
|
|
userCalloutDismissSpy = jest.fn();
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
wrapper = mountExtended(SecurityConfigurationApp, {
|
|
|
|
propsData: {
|
|
|
|
augmentedSecurityFeatures: securityFeaturesMock,
|
|
|
|
augmentedComplianceFeatures: complianceFeaturesMock,
|
|
|
|
securityTrainingEnabled: true,
|
|
|
|
...propsData,
|
|
|
|
},
|
|
|
|
provide: {
|
|
|
|
upgradePath,
|
|
|
|
autoDevopsHelpPagePath,
|
|
|
|
autoDevopsPath,
|
|
|
|
projectFullPath,
|
|
|
|
vulnerabilityTrainingDocsPath,
|
|
|
|
},
|
|
|
|
stubs: {
|
|
|
|
...stubChildren(SecurityConfigurationApp),
|
|
|
|
GlLink: false,
|
|
|
|
GlSprintf: false,
|
|
|
|
LocalStorageSync: false,
|
|
|
|
SectionLayout: false,
|
|
|
|
UserCalloutDismisser: makeMockUserCalloutDismisser({
|
|
|
|
dismiss: userCalloutDismissSpy,
|
|
|
|
shouldShowCallout,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
});
|
2021-09-04 01:27:46 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
const findMainHeading = () => wrapper.find('h1');
|
|
|
|
const findTab = () => wrapper.findComponent(GlTab);
|
|
|
|
const findTabs = () => wrapper.findAllComponents(GlTab);
|
2022-03-02 08:16:31 +05:30
|
|
|
const findGlTabs = () => wrapper.findComponent(GlTabs);
|
2021-09-04 01:27:46 +05:30
|
|
|
const findByTestId = (id) => wrapper.findByTestId(id);
|
|
|
|
const findFeatureCards = () => wrapper.findAllComponents(FeatureCard);
|
2022-01-26 12:08:38 +05:30
|
|
|
const findTrainingProviderList = () => wrapper.findComponent(TrainingProviderList);
|
2021-12-11 22:18:48 +05:30
|
|
|
const findManageViaMRErrorAlert = () => wrapper.findByTestId('manage-via-mr-error-alert');
|
2021-09-30 23:02:18 +05:30
|
|
|
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'),
|
|
|
|
});
|
2021-09-04 01:27:46 +05:30
|
|
|
const findUpgradeBanner = () => wrapper.findComponent(UpgradeBanner);
|
2021-09-30 23:02:18 +05:30
|
|
|
const findAutoDevopsAlert = () => wrapper.findComponent(AutoDevopsAlert);
|
2021-10-27 15:23:28 +05:30
|
|
|
const findAutoDevopsEnabledAlert = () => wrapper.findComponent(AutoDevopsEnabledAlert);
|
2022-06-21 17:19:12 +05:30
|
|
|
const findVulnerabilityManagementTab = () => wrapper.findByTestId('vulnerability-management-tab');
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
describe('basic structure', () => {
|
2022-08-13 15:12:31 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
2021-09-04 01:27:46 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders main-heading with correct text', () => {
|
|
|
|
const mainHeading = findMainHeading();
|
2021-12-11 22:18:48 +05:30
|
|
|
expect(mainHeading.exists()).toBe(true);
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(mainHeading.text()).toContain('Security configuration');
|
2021-09-04 01:27:46 +05:30
|
|
|
});
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
describe('tabs', () => {
|
|
|
|
const expectedTabs = ['security-testing', 'compliance-testing', 'vulnerability-management'];
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
it('renders GlTab Component', () => {
|
|
|
|
expect(findTab().exists()).toBe(true);
|
|
|
|
});
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
it('passes the `sync-active-tab-with-query-params` prop', () => {
|
|
|
|
expect(findGlTabs().props('syncActiveTabWithQueryParams')).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('lazy loads each tab', () => {
|
|
|
|
expect(findGlTabs().attributes('lazy')).not.toBe(undefined);
|
|
|
|
});
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
it('renders correct amount of tabs', () => {
|
|
|
|
expect(findTabs()).toHaveLength(expectedTabs.length);
|
|
|
|
});
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
it.each(expectedTabs)('renders the %s tab', (tabName) => {
|
|
|
|
expect(findByTestId(`${tabName}-tab`).exists()).toBe(true);
|
|
|
|
});
|
2022-03-02 08:16:31 +05:30
|
|
|
|
|
|
|
it.each(expectedTabs)('has the %s query-param-value', (tabName) => {
|
|
|
|
expect(findByTestId(`${tabName}-tab`).props('queryParamValue')).toBe(tabName);
|
|
|
|
});
|
2021-09-04 01:27:46 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders right amount of feature cards for given props with correct props', () => {
|
|
|
|
const cards = findFeatureCards();
|
|
|
|
expect(cards).toHaveLength(2);
|
|
|
|
expect(cards.at(0).props()).toEqual({ feature: securityFeaturesMock[0] });
|
|
|
|
expect(cards.at(1).props()).toEqual({ feature: complianceFeaturesMock[0] });
|
|
|
|
});
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
it('renders a basic description', () => {
|
|
|
|
expect(wrapper.text()).toContain(i18n.description);
|
|
|
|
});
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it('should not show latest pipeline link when latestPipelinePath is not defined', () => {
|
|
|
|
expect(findByTestId('latest-pipeline-info').exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not show configuration History Link when gitlabCiPresent & gitlabCiHistoryPath are not defined', () => {
|
|
|
|
expect(findComplianceViewHistoryLink().exists()).toBe(false);
|
|
|
|
expect(findSecurityViewHistoryLink().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
describe('Manage via MR Error Alert', () => {
|
|
|
|
beforeEach(() => {
|
2022-08-13 15:12:31 +05:30
|
|
|
createComponent();
|
2021-12-11 22:18:48 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('on initial load', () => {
|
|
|
|
it('should not show Manage via MR Error Alert', () => {
|
|
|
|
expect(findManageViaMRErrorAlert().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
describe('when error occurs', () => {
|
|
|
|
const errorMessage = 'There was a manage via MR error';
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
it('should show Alert with error Message', async () => {
|
|
|
|
expect(findManageViaMRErrorAlert().exists()).toBe(false);
|
2023-06-20 00:43:36 +05:30
|
|
|
findFeatureCards().at(1).vm.$emit('error', errorMessage);
|
2021-12-11 22:18:48 +05:30
|
|
|
|
|
|
|
await nextTick();
|
|
|
|
expect(findManageViaMRErrorAlert().exists()).toBe(true);
|
2023-06-20 00:43:36 +05:30
|
|
|
expect(findManageViaMRErrorAlert().text()).toBe(errorMessage);
|
2021-12-11 22:18:48 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should hide Alert when it is dismissed', async () => {
|
2023-06-20 00:43:36 +05:30
|
|
|
findFeatureCards().at(1).vm.$emit('error', errorMessage);
|
2021-12-11 22:18:48 +05:30
|
|
|
|
|
|
|
await nextTick();
|
|
|
|
expect(findManageViaMRErrorAlert().exists()).toBe(true);
|
|
|
|
|
|
|
|
findManageViaMRErrorAlert().vm.$emit('dismiss');
|
|
|
|
await nextTick();
|
|
|
|
expect(findManageViaMRErrorAlert().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
describe('Auto DevOps hint alert', () => {
|
2021-09-30 23:02:18 +05:30
|
|
|
describe('given the right props', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({
|
|
|
|
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(() => {
|
2022-08-13 15:12:31 +05:30
|
|
|
createComponent();
|
2021-09-30 23:02:18 +05:30
|
|
|
});
|
|
|
|
it('should not show AutoDevopsAlert', () => {
|
|
|
|
expect(findAutoDevopsAlert().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
describe('Auto DevOps enabled alert', () => {
|
|
|
|
describe.each`
|
2022-04-04 11:22:00 +05:30
|
|
|
context | autoDevopsEnabled | localStorageValue | shouldRender
|
|
|
|
${'enabled'} | ${true} | ${null} | ${true}
|
|
|
|
${'enabled, alert dismissed on other project'} | ${true} | ${['foo/bar']} | ${true}
|
|
|
|
${'enabled, alert dismissed on this project'} | ${true} | ${[projectFullPath]} | ${false}
|
|
|
|
${'not enabled'} | ${false} | ${null} | ${false}
|
2021-10-27 15:23:28 +05:30
|
|
|
`('given Auto DevOps is $context', ({ autoDevopsEnabled, localStorageValue, shouldRender }) => {
|
|
|
|
beforeEach(() => {
|
|
|
|
if (localStorageValue !== null) {
|
|
|
|
window.localStorage.setItem(
|
|
|
|
AUTO_DEVOPS_ENABLED_ALERT_DISMISSED_STORAGE_KEY,
|
|
|
|
JSON.stringify(localStorageValue),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
createComponent({
|
|
|
|
autoDevopsEnabled,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
it(`${shouldRender ? 'renders' : 'does not render'}`, () => {
|
2021-10-27 15:23:28 +05:30
|
|
|
expect(findAutoDevopsEnabledAlert().exists()).toBe(shouldRender);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('dismissing', () => {
|
|
|
|
describe.each`
|
2022-04-04 11:22:00 +05:30
|
|
|
dismissedProjects | expectedWrittenValue
|
|
|
|
${null} | ${[projectFullPath]}
|
|
|
|
${[]} | ${[projectFullPath]}
|
|
|
|
${['foo/bar']} | ${['foo/bar', projectFullPath]}
|
|
|
|
${[projectFullPath]} | ${[projectFullPath]}
|
2021-10-27 15:23:28 +05:30
|
|
|
`(
|
|
|
|
'given dismissed projects $dismissedProjects',
|
|
|
|
({ dismissedProjects, expectedWrittenValue }) => {
|
|
|
|
beforeEach(() => {
|
|
|
|
if (dismissedProjects !== null) {
|
|
|
|
window.localStorage.setItem(
|
|
|
|
AUTO_DEVOPS_ENABLED_ALERT_DISMISSED_STORAGE_KEY,
|
|
|
|
JSON.stringify(dismissedProjects),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
createComponent({
|
|
|
|
augmentedSecurityFeatures: securityFeaturesMock,
|
|
|
|
augmentedComplianceFeatures: complianceFeaturesMock,
|
|
|
|
autoDevopsEnabled: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
findAutoDevopsEnabledAlert().vm.$emit('dismiss');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('adds current project to localStorage value', () => {
|
|
|
|
expect(window.localStorage.setItem).toHaveBeenLastCalledWith(
|
|
|
|
AUTO_DEVOPS_ENABLED_ALERT_DISMISSED_STORAGE_KEY,
|
|
|
|
JSON.stringify(expectedWrittenValue),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('hides the alert', () => {
|
|
|
|
expect(findAutoDevopsEnabledAlert().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
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({
|
|
|
|
latestPipelinePath: 'test/path',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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.text()).toMatchInterpolatedText(
|
2021-09-30 23:02:18 +05:30
|
|
|
i18n.latestPipelineDescription,
|
2021-09-04 01:27:46 +05:30
|
|
|
);
|
|
|
|
expect(latestPipelineInfoSecurity.find('a').attributes('href')).toBe('test/path');
|
|
|
|
});
|
|
|
|
|
|
|
|
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.text()).toMatchInterpolatedText(
|
2021-09-30 23:02:18 +05:30
|
|
|
i18n.latestPipelineDescription,
|
2021-09-04 01:27:46 +05:30
|
|
|
);
|
|
|
|
expect(latestPipelineInfoCompliance.find('a').attributes('href')).toBe('test/path');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('given gitlabCiPresent & gitlabCiHistoryPath props', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({
|
|
|
|
gitlabCiPresent: true,
|
2021-09-30 23:02:18 +05:30
|
|
|
gitlabCiHistoryPath,
|
2021-09-04 01:27:46 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should show configuration History Link', () => {
|
|
|
|
expect(findComplianceViewHistoryLink().exists()).toBe(true);
|
|
|
|
expect(findSecurityViewHistoryLink().exists()).toBe(true);
|
|
|
|
|
|
|
|
expect(findComplianceViewHistoryLink().attributes('href')).toBe('test/historyPath');
|
|
|
|
expect(findSecurityViewHistoryLink().attributes('href')).toBe('test/historyPath');
|
|
|
|
});
|
|
|
|
});
|
2022-01-26 12:08:38 +05:30
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
describe('Vulnerability management', () => {
|
2022-08-13 15:12:31 +05:30
|
|
|
const props = { securityTrainingEnabled: true };
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
beforeEach(() => {
|
2022-03-02 08:16:31 +05:30
|
|
|
createComponent({
|
2022-08-13 15:12:31 +05:30
|
|
|
...props,
|
2022-03-02 08:16:31 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
it('shows the tab', () => {
|
|
|
|
expect(findVulnerabilityManagementTab().exists()).toBe(true);
|
|
|
|
});
|
2022-07-23 23:45:48 +05:30
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
it('renders TrainingProviderList component', () => {
|
|
|
|
expect(findTrainingProviderList().props()).toMatchObject(props);
|
|
|
|
});
|
2022-07-23 23:45:48 +05:30
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
it('renders security training description', () => {
|
|
|
|
expect(findVulnerabilityManagementTab().text()).toContain(i18n.securityTrainingDescription);
|
|
|
|
});
|
2022-07-23 23:45:48 +05:30
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
it('renders link to help docs', () => {
|
|
|
|
const trainingLink = findVulnerabilityManagementTab().findComponent(GlLink);
|
2022-07-23 23:45:48 +05:30
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
expect(trainingLink.text()).toBe('Learn more about vulnerability training');
|
|
|
|
expect(trainingLink.attributes('href')).toBe(vulnerabilityTrainingDocsPath);
|
2022-07-23 23:45:48 +05:30
|
|
|
});
|
2022-01-26 12:08:38 +05:30
|
|
|
});
|
2021-09-04 01:27:46 +05:30
|
|
|
});
|