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:
Diffstat (limited to 'spec/frontend/ci_lint')
-rw-r--r--spec/frontend/ci_lint/components/ci_lint_results_spec.js129
-rw-r--r--spec/frontend/ci_lint/components/ci_lint_spec.js4
-rw-r--r--spec/frontend/ci_lint/components/ci_lint_warnings_spec.js54
-rw-r--r--spec/frontend/ci_lint/graphql/__snapshots__/resolvers_spec.js.snap73
-rw-r--r--spec/frontend/ci_lint/graphql/resolvers_spec.js38
-rw-r--r--spec/frontend/ci_lint/mock_data.js84
6 files changed, 3 insertions, 379 deletions
diff --git a/spec/frontend/ci_lint/components/ci_lint_results_spec.js b/spec/frontend/ci_lint/components/ci_lint_results_spec.js
deleted file mode 100644
index 93c2d2dbcf3..00000000000
--- a/spec/frontend/ci_lint/components/ci_lint_results_spec.js
+++ /dev/null
@@ -1,129 +0,0 @@
-import { shallowMount, mount } from '@vue/test-utils';
-import { GlTable, GlLink } from '@gitlab/ui';
-import CiLintResults from '~/ci_lint/components/ci_lint_results.vue';
-import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
-import { mockJobs, mockErrors, mockWarnings } from '../mock_data';
-
-describe('CI Lint Results', () => {
- let wrapper;
- const defaultProps = {
- valid: true,
- jobs: mockJobs,
- errors: [],
- warnings: [],
- dryRun: false,
- lintHelpPagePath: '/help',
- };
-
- const createComponent = (props = {}, mountFn = shallowMount) => {
- wrapper = mountFn(CiLintResults, {
- propsData: {
- ...defaultProps,
- ...props,
- },
- });
- };
-
- const findTable = () => wrapper.find(GlTable);
- const findByTestId = selector => () => wrapper.find(`[data-testid="ci-lint-${selector}"]`);
- const findAllByTestId = selector => () => wrapper.findAll(`[data-testid="ci-lint-${selector}"]`);
- const findLinkToDoc = () => wrapper.find(GlLink);
- const findErrors = findByTestId('errors');
- const findWarnings = findByTestId('warnings');
- const findStatus = findByTestId('status');
- const findOnlyExcept = findByTestId('only-except');
- const findLintParameters = findAllByTestId('parameter');
- const findBeforeScripts = findAllByTestId('before-script');
- const findScripts = findAllByTestId('script');
- const findAfterScripts = findAllByTestId('after-script');
- const filterEmptyScripts = property => mockJobs.filter(job => job[property].length !== 0);
-
- afterEach(() => {
- wrapper.destroy();
- wrapper = null;
- });
-
- describe('Invalid results', () => {
- beforeEach(() => {
- createComponent({ valid: false, errors: mockErrors, warnings: mockWarnings }, mount);
- });
-
- it('does not display the table', () => {
- expect(findTable().exists()).toBe(false);
- });
-
- it('displays the invalid status', () => {
- expect(findStatus().text()).toContain(`Status: ${wrapper.vm.$options.incorrect.text}`);
- expect(findStatus().props('variant')).toBe(wrapper.vm.$options.incorrect.variant);
- });
-
- it('contains the link to documentation', () => {
- expect(findLinkToDoc().text()).toBe('More information');
- expect(findLinkToDoc().attributes('href')).toBe(defaultProps.lintHelpPagePath);
- });
-
- it('displays the error message', () => {
- const [expectedError] = mockErrors;
-
- expect(findErrors().text()).toBe(expectedError);
- });
-
- it('displays the warning message', () => {
- const [expectedWarning] = mockWarnings;
-
- expect(findWarnings().exists()).toBe(true);
- expect(findWarnings().text()).toContain(expectedWarning);
- });
- });
-
- describe('Valid results with dry run', () => {
- beforeEach(() => {
- createComponent({ dryRun: true }, mount);
- });
-
- it('displays table', () => {
- expect(findTable().exists()).toBe(true);
- });
-
- it('displays the valid status', () => {
- expect(findStatus().text()).toContain(wrapper.vm.$options.correct.text);
- expect(findStatus().props('variant')).toBe(wrapper.vm.$options.correct.variant);
- });
-
- it('does not display only/expect values with dry run', () => {
- expect(findOnlyExcept().exists()).toBe(false);
- });
-
- it('contains the link to documentation', () => {
- expect(findLinkToDoc().text()).toBe('More information');
- expect(findLinkToDoc().attributes('href')).toBe(defaultProps.lintHelpPagePath);
- });
- });
-
- describe('Lint results', () => {
- beforeEach(() => {
- createComponent({}, mount);
- });
-
- it('formats parameter value', () => {
- findLintParameters().wrappers.forEach((job, index) => {
- const { stage } = mockJobs[index];
- const { name } = mockJobs[index];
-
- expect(job.text()).toBe(`${capitalizeFirstCharacter(stage)} Job - ${name}`);
- });
- });
-
- it('only shows before scripts when data is present', () => {
- expect(findBeforeScripts()).toHaveLength(filterEmptyScripts('beforeScript').length);
- });
-
- it('only shows script when data is present', () => {
- expect(findScripts()).toHaveLength(filterEmptyScripts('script').length);
- });
-
- it('only shows after script when data is present', () => {
- expect(findAfterScripts()).toHaveLength(filterEmptyScripts('afterScript').length);
- });
- });
-});
diff --git a/spec/frontend/ci_lint/components/ci_lint_spec.js b/spec/frontend/ci_lint/components/ci_lint_spec.js
index b353da5910d..1c99fdb3505 100644
--- a/spec/frontend/ci_lint/components/ci_lint_spec.js
+++ b/spec/frontend/ci_lint/components/ci_lint_spec.js
@@ -3,8 +3,8 @@ import { shallowMount } from '@vue/test-utils';
import waitForPromises from 'helpers/wait_for_promises';
import EditorLite from '~/vue_shared/components/editor_lite.vue';
import CiLint from '~/ci_lint/components/ci_lint.vue';
-import CiLintResults from '~/ci_lint/components/ci_lint_results.vue';
-import lintCIMutation from '~/ci_lint/graphql/mutations/lint_ci.mutation.graphql';
+import CiLintResults from '~/pipeline_editor/components/lint/ci_lint_results.vue';
+import lintCIMutation from '~/pipeline_editor/graphql/mutations/lint_ci.mutation.graphql';
import { mockLintDataValid } from '../mock_data';
describe('CI Lint', () => {
diff --git a/spec/frontend/ci_lint/components/ci_lint_warnings_spec.js b/spec/frontend/ci_lint/components/ci_lint_warnings_spec.js
deleted file mode 100644
index 6e0a4881e14..00000000000
--- a/spec/frontend/ci_lint/components/ci_lint_warnings_spec.js
+++ /dev/null
@@ -1,54 +0,0 @@
-import { mount } from '@vue/test-utils';
-import { GlAlert, GlSprintf } from '@gitlab/ui';
-import { trimText } from 'helpers/text_helper';
-import CiLintWarnings from '~/ci_lint/components/ci_lint_warnings.vue';
-
-const warnings = ['warning 1', 'warning 2', 'warning 3'];
-
-describe('CI lint warnings', () => {
- let wrapper;
-
- const createComponent = (limit = 25) => {
- wrapper = mount(CiLintWarnings, {
- propsData: {
- warnings,
- maxWarnings: limit,
- },
- });
- };
-
- const findWarningAlert = () => wrapper.find(GlAlert);
- const findWarnings = () => wrapper.findAll('[data-testid="ci-lint-warning"]');
- const findWarningMessage = () => trimText(wrapper.find(GlSprintf).text());
-
- afterEach(() => {
- wrapper.destroy();
- wrapper = null;
- });
-
- it('displays the warning alert', () => {
- createComponent();
-
- expect(findWarningAlert().exists()).toBe(true);
- });
-
- it('displays all the warnings', () => {
- createComponent();
-
- expect(findWarnings()).toHaveLength(warnings.length);
- });
-
- it('shows the correct message when the limit is not passed', () => {
- createComponent();
-
- expect(findWarningMessage()).toBe(`${warnings.length} warnings found:`);
- });
-
- it('shows the correct message when the limit is passed', () => {
- const limit = 2;
-
- createComponent(limit);
-
- expect(findWarningMessage()).toBe(`${warnings.length} warnings found: showing first ${limit}`);
- });
-});
diff --git a/spec/frontend/ci_lint/graphql/__snapshots__/resolvers_spec.js.snap b/spec/frontend/ci_lint/graphql/__snapshots__/resolvers_spec.js.snap
deleted file mode 100644
index 87bec82e350..00000000000
--- a/spec/frontend/ci_lint/graphql/__snapshots__/resolvers_spec.js.snap
+++ /dev/null
@@ -1,73 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`~/ci_lint/graphql/resolvers Mutation lintCI resolves lint data with type names 1`] = `
-Object {
- "__typename": "CiLintContent",
- "errors": Array [],
- "jobs": Array [
- Object {
- "__typename": "CiLintJob",
- "afterScript": Array [
- "echo 'after script 1",
- ],
- "allowFailure": false,
- "beforeScript": Array [
- "echo 'before script 1'",
- ],
- "environment": "prd",
- "except": Object {
- "refs": Array [
- "master@gitlab-org/gitlab",
- "/^release/.*$/@gitlab-org/gitlab",
- ],
- },
- "name": "job_1",
- "only": null,
- "script": Array [
- "echo 'script 1'",
- ],
- "stage": "test",
- "tagList": Array [
- "tag 1",
- ],
- "when": "on_success",
- },
- Object {
- "__typename": "CiLintJob",
- "afterScript": Array [
- "echo 'after script 2",
- ],
- "allowFailure": true,
- "beforeScript": Array [
- "echo 'before script 2'",
- ],
- "environment": "stg",
- "except": Object {
- "refs": Array [
- "master@gitlab-org/gitlab",
- "/^release/.*$/@gitlab-org/gitlab",
- ],
- },
- "name": "job_2",
- "only": Object {
- "__typename": "CiLintJobOnlyPolicy",
- "refs": Array [
- "web",
- "chat",
- "pushes",
- ],
- },
- "script": Array [
- "echo 'script 2'",
- ],
- "stage": "test",
- "tagList": Array [
- "tag 2",
- ],
- "when": "on_success",
- },
- ],
- "valid": true,
- "warnings": Array [],
-}
-`;
diff --git a/spec/frontend/ci_lint/graphql/resolvers_spec.js b/spec/frontend/ci_lint/graphql/resolvers_spec.js
deleted file mode 100644
index 437c52cf6b4..00000000000
--- a/spec/frontend/ci_lint/graphql/resolvers_spec.js
+++ /dev/null
@@ -1,38 +0,0 @@
-import MockAdapter from 'axios-mock-adapter';
-import axios from '~/lib/utils/axios_utils';
-import httpStatus from '~/lib/utils/http_status';
-
-import resolvers from '~/ci_lint/graphql/resolvers';
-import { mockLintResponse } from '../mock_data';
-
-describe('~/ci_lint/graphql/resolvers', () => {
- let mock;
-
- beforeEach(() => {
- mock = new MockAdapter(axios);
- });
-
- afterEach(() => {
- mock.restore();
- });
-
- describe('Mutation', () => {
- describe('lintCI', () => {
- const endpoint = '/ci/lint';
-
- beforeEach(() => {
- mock.onPost(endpoint).reply(httpStatus.OK, mockLintResponse);
- });
-
- it('resolves lint data with type names', async () => {
- const result = resolvers.Mutation.lintCI(null, {
- endpoint,
- content: 'content',
- dry_run: true,
- });
-
- await expect(result).resolves.toMatchSnapshot();
- });
- });
- });
-});
diff --git a/spec/frontend/ci_lint/mock_data.js b/spec/frontend/ci_lint/mock_data.js
index b87c9f8413b..28ea0f55bf8 100644
--- a/spec/frontend/ci_lint/mock_data.js
+++ b/spec/frontend/ci_lint/mock_data.js
@@ -1,86 +1,4 @@
-export const mockLintResponse = {
- valid: true,
- errors: [],
- warnings: [],
- jobs: [
- {
- name: 'job_1',
- stage: 'test',
- before_script: ["echo 'before script 1'"],
- script: ["echo 'script 1'"],
- after_script: ["echo 'after script 1"],
- tag_list: ['tag 1'],
- environment: 'prd',
- when: 'on_success',
- allow_failure: false,
- only: null,
- except: { refs: ['master@gitlab-org/gitlab', '/^release/.*$/@gitlab-org/gitlab'] },
- },
- {
- name: 'job_2',
- stage: 'test',
- before_script: ["echo 'before script 2'"],
- script: ["echo 'script 2'"],
- after_script: ["echo 'after script 2"],
- tag_list: ['tag 2'],
- environment: 'stg',
- when: 'on_success',
- allow_failure: true,
- only: { refs: ['web', 'chat', 'pushes'] },
- except: { refs: ['master@gitlab-org/gitlab', '/^release/.*$/@gitlab-org/gitlab'] },
- },
- ],
-};
-
-export const mockJobs = [
- {
- name: 'job_1',
- stage: 'build',
- beforeScript: [],
- script: ["echo 'Building'"],
- afterScript: [],
- tagList: [],
- environment: null,
- when: 'on_success',
- allowFailure: true,
- only: { refs: ['web', 'chat', 'pushes'] },
- except: null,
- },
- {
- name: 'multi_project_job',
- stage: 'test',
- beforeScript: [],
- script: [],
- afterScript: [],
- tagList: [],
- environment: null,
- when: 'on_success',
- allowFailure: false,
- only: { refs: ['branches', 'tags'] },
- except: null,
- },
- {
- name: 'job_2',
- stage: 'test',
- beforeScript: ["echo 'before script'"],
- script: ["echo 'script'"],
- afterScript: ["echo 'after script"],
- tagList: [],
- environment: null,
- when: 'on_success',
- allowFailure: false,
- only: { refs: ['branches@gitlab-org/gitlab'] },
- except: { refs: ['master@gitlab-org/gitlab', '/^release/.*$/@gitlab-org/gitlab'] },
- },
-];
-
-export const mockErrors = [
- '"job_1 job: chosen stage does not exist; available stages are .pre, build, test, deploy, .post"',
-];
-
-export const mockWarnings = [
- '"jobs:multi_project_job may allow multiple pipelines to run for a single action due to `rules:when` clause with no `workflow:rules` - read more: https://docs.gitlab.com/ee/ci/troubleshooting.html#pipeline-warnings"',
-];
+import { mockJobs } from 'jest/pipeline_editor/mock_data';
export const mockLintDataValid = {
data: {