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

configuration_table_spec.js « security_configuration « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b8a574dc4e0c74bb376d4929a33259b7be8617cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { mount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import ConfigurationTable from '~/security_configuration/components/configuration_table.vue';
import { scanners, UPGRADE_CTA } from '~/security_configuration/components/scanners_constants';

import {
  REPORT_TYPE_SAST,
  REPORT_TYPE_SECRET_DETECTION,
} from '~/vue_shared/security_reports/constants';

describe('Configuration Table Component', () => {
  let wrapper;

  const createComponent = () => {
    wrapper = extendedWrapper(mount(ConfigurationTable, {}));
  };

  const findHelpLinks = () => wrapper.findAll('[data-testid="help-link"]');

  afterEach(() => {
    wrapper.destroy();
  });

  beforeEach(() => {
    createComponent();
  });

  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) {
        expect(wrapper.findByTestId(scanner.type).text()).toBe('Configure via Merge Request');
      } 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);
    });
  });
});