2021-03-11 19:13:27 +05:30
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
|
|
|
|
import ConfigurationTable from '~/security_configuration/components/configuration_table.vue';
|
2021-04-17 20:07:23 +05:30
|
|
|
import { scanners, UPGRADE_CTA } from '~/security_configuration/components/scanners_constants';
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
import {
|
|
|
|
REPORT_TYPE_SAST,
|
2021-04-17 20:07:23 +05:30
|
|
|
REPORT_TYPE_SECRET_DETECTION,
|
2021-03-11 19:13:27 +05:30
|
|
|
} from '~/vue_shared/security_reports/constants';
|
|
|
|
|
|
|
|
describe('Configuration Table Component', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const createComponent = () => {
|
|
|
|
wrapper = extendedWrapper(mount(ConfigurationTable, {}));
|
|
|
|
};
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
const findHelpLinks = () => wrapper.findAll('[data-testid="help-link"]');
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
describe.each(scanners.map((scanner, i) => [scanner, i]))('given scanner %s', (scanner, i) => {
|
|
|
|
it('should match strings', () => {
|
|
|
|
expect(wrapper.text()).toContain(scanner.name);
|
|
|
|
expect(wrapper.text()).toContain(scanner.description);
|
|
|
|
if (scanner.type === REPORT_TYPE_SAST) {
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(wrapper.findByTestId(scanner.type).text()).toBe('Configure via merge request');
|
2021-04-17 20:07:23 +05:30
|
|
|
} else if (scanner.type !== REPORT_TYPE_SECRET_DETECTION) {
|
|
|
|
expect(wrapper.findByTestId(scanner.type).text()).toMatchInterpolatedText(UPGRADE_CTA);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should show expected help link', () => {
|
|
|
|
const helpLink = findHelpLinks().at(i);
|
|
|
|
expect(helpLink.attributes('href')).toBe(scanner.helpPath);
|
|
|
|
});
|
2021-03-11 19:13:27 +05:30
|
|
|
});
|
|
|
|
});
|