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

code_snippet_alert_spec.js « code_snippet_alert « components « pipeline_editor « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d03f12bc249a19af5dc2f469853a51278cb7fd4b (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { within } from '@testing-library/dom';
import { mount } from '@vue/test-utils';
import { merge } from 'lodash';
import { TEST_HOST } from 'helpers/test_constants';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import CodeSnippetAlert from '~/pipeline_editor/components/code_snippet_alert/code_snippet_alert.vue';
import { CODE_SNIPPET_SOURCE_API_FUZZING } from '~/pipeline_editor/components/code_snippet_alert/constants';

const apiFuzzingConfigurationPath = '/namespace/project/-/security/configuration/api_fuzzing';

describe('EE - CodeSnippetAlert', () => {
  let wrapper;

  const createWrapper = (options) => {
    wrapper = extendedWrapper(
      mount(
        CodeSnippetAlert,
        merge(
          {
            provide: {
              configurationPaths: {
                [CODE_SNIPPET_SOURCE_API_FUZZING]: apiFuzzingConfigurationPath,
              },
            },
            propsData: {
              source: CODE_SNIPPET_SOURCE_API_FUZZING,
            },
          },
          options,
        ),
      ),
    );
  };

  const withinComponent = () => within(wrapper.element);
  const findDocsLink = () => withinComponent().getByRole('link', { name: /read documentation/i });
  const findConfigurationLink = () =>
    withinComponent().getByRole('link', { name: /Go back to configuration/i });

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

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

  it("provides a link to the feature's documentation", () => {
    const docsLink = findDocsLink();

    expect(docsLink).not.toBe(null);
    expect(docsLink.href).toBe(`${TEST_HOST}/help/user/application_security/api_fuzzing/index`);
  });

  it("provides a link to the feature's configuration form", () => {
    const configurationLink = findConfigurationLink();

    expect(configurationLink).not.toBe(null);
    expect(configurationLink.href).toBe(TEST_HOST + apiFuzzingConfigurationPath);
  });
});