Commit 3f211bc2 authored by Mark Florian's avatar Mark Florian

Merge branch '339346-change-get-json-4bdcd073241' into 'master'

Use import for json fixture - 5/7

See merge request gitlab-org/gitlab!71902
parents b3cb3e7b 6d48f5fc
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import fixture from 'test_fixtures/pipelines/pipelines.json';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import PipelinesTable from '~/pipelines/components/pipelines_list/pipelines_table.vue'; import PipelinesTable from '~/pipelines/components/pipelines_list/pipelines_table.vue';
import { PipelineKeyOptions } from '~/pipelines/constants'; import { PipelineKeyOptions } from '~/pipelines/constants';
...@@ -11,8 +12,6 @@ describe('Pipelines Table', () => { ...@@ -11,8 +12,6 @@ describe('Pipelines Table', () => {
let pipeline; let pipeline;
let wrapper; let wrapper;
const jsonFixtureName = 'pipelines/pipelines.json';
const defaultProps = { const defaultProps = {
pipelines: [], pipelines: [],
viewType: 'root', viewType: 'root',
...@@ -20,7 +19,8 @@ describe('Pipelines Table', () => { ...@@ -20,7 +19,8 @@ describe('Pipelines Table', () => {
}; };
const createMockPipeline = () => { const createMockPipeline = () => {
const { pipelines } = getJSONFixture(jsonFixtureName); // Clone fixture as it could be modified by tests
const { pipelines } = JSON.parse(JSON.stringify(fixture));
return pipelines.find((p) => p.user !== null && p.commit !== null); return pipelines.find((p) => p.user !== null && p.commit !== null);
}; };
......
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Visibility from 'visibilityjs'; import Visibility from 'visibilityjs';
import { getJSONFixture } from 'helpers/fixtures'; import fixture from 'test_fixtures/pipelines/pipelines.json';
import createFlash from '~/flash'; import createFlash from '~/flash';
import Poll from '~/lib/utils/poll'; import Poll from '~/lib/utils/poll';
import CommitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue'; import CommitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue';
...@@ -20,7 +20,7 @@ jest.mock('~/projects/tree/services/commit_pipeline_service', () => ...@@ -20,7 +20,7 @@ jest.mock('~/projects/tree/services/commit_pipeline_service', () =>
describe('Commit pipeline status component', () => { describe('Commit pipeline status component', () => {
let wrapper; let wrapper;
const { pipelines } = getJSONFixture('pipelines/pipelines.json'); const { pipelines } = fixture;
const { status: mockCiStatus } = pipelines[0].details; const { status: mockCiStatus } = pipelines[0].details;
const defaultProps = { const defaultProps = {
......
import { GlEmptyState, GlLoadingIcon, GlModal, GlTable } from '@gitlab/ui'; import { GlEmptyState, GlLoadingIcon, GlModal, GlTable } from '@gitlab/ui';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import fixture from 'test_fixtures/pipelines/pipelines.json';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import Api from '~/api'; import Api from '~/api';
...@@ -8,7 +9,6 @@ import PipelinesTable from '~/commit/pipelines/pipelines_table.vue'; ...@@ -8,7 +9,6 @@ import PipelinesTable from '~/commit/pipelines/pipelines_table.vue';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
describe('Pipelines table in Commits and Merge requests', () => { describe('Pipelines table in Commits and Merge requests', () => {
const jsonFixtureName = 'pipelines/pipelines.json';
let wrapper; let wrapper;
let pipeline; let pipeline;
let mock; let mock;
...@@ -37,7 +37,7 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -37,7 +37,7 @@ describe('Pipelines table in Commits and Merge requests', () => {
beforeEach(() => { beforeEach(() => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
const { pipelines } = getJSONFixture(jsonFixtureName); const { pipelines } = fixture;
pipeline = pipelines.find((p) => p.user !== null && p.commit !== null); pipeline = pipelines.find((p) => p.user !== null && p.commit !== null);
}); });
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { pipelines } from 'test_fixtures/pipelines/pipelines.json';
import PipelineMiniGraph from '~/pipelines/components/pipelines_list/pipeline_mini_graph.vue'; import PipelineMiniGraph from '~/pipelines/components/pipelines_list/pipeline_mini_graph.vue';
import PipelineStage from '~/pipelines/components/pipelines_list/pipeline_stage.vue'; import PipelineStage from '~/pipelines/components/pipelines_list/pipeline_stage.vue';
const { pipelines } = getJSONFixture('pipelines/pipelines.json');
const mockStages = pipelines[0].details.stages; const mockStages = pipelines[0].details.stages;
describe('Pipeline Mini Graph', () => { describe('Pipeline Mini Graph', () => {
......
...@@ -4,6 +4,7 @@ import { mount } from '@vue/test-utils'; ...@@ -4,6 +4,7 @@ import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { chunk } from 'lodash'; import { chunk } from 'lodash';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import mockPipelinesResponse from 'test_fixtures/pipelines/pipelines.json';
import setWindowLocation from 'helpers/set_window_location_helper'; import setWindowLocation from 'helpers/set_window_location_helper';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
...@@ -33,7 +34,6 @@ jest.mock('~/experimentation/utils', () => ({ ...@@ -33,7 +34,6 @@ jest.mock('~/experimentation/utils', () => ({
const mockProjectPath = 'twitter/flight'; const mockProjectPath = 'twitter/flight';
const mockProjectId = '21'; const mockProjectId = '21';
const mockPipelinesEndpoint = `/${mockProjectPath}/pipelines.json`; const mockPipelinesEndpoint = `/${mockProjectPath}/pipelines.json`;
const mockPipelinesResponse = getJSONFixture('pipelines/pipelines.json');
const mockPipelinesIds = mockPipelinesResponse.pipelines.map(({ id }) => id); const mockPipelinesIds = mockPipelinesResponse.pipelines.map(({ id }) => id);
const mockPipelineWithStages = mockPipelinesResponse.pipelines.find( const mockPipelineWithStages = mockPipelinesResponse.pipelines.find(
(p) => p.details.stages && p.details.stages.length, (p) => p.details.stages && p.details.stages.length,
......
import '~/commons'; import '~/commons';
import { GlTable } from '@gitlab/ui'; import { GlTable } from '@gitlab/ui';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import fixture from 'test_fixtures/pipelines/pipelines.json';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import PipelineMiniGraph from '~/pipelines/components/pipelines_list/pipeline_mini_graph.vue'; import PipelineMiniGraph from '~/pipelines/components/pipelines_list/pipeline_mini_graph.vue';
import PipelineOperations from '~/pipelines/components/pipelines_list/pipeline_operations.vue'; import PipelineOperations from '~/pipelines/components/pipelines_list/pipeline_operations.vue';
...@@ -20,8 +21,6 @@ describe('Pipelines Table', () => { ...@@ -20,8 +21,6 @@ describe('Pipelines Table', () => {
let pipeline; let pipeline;
let wrapper; let wrapper;
const jsonFixtureName = 'pipelines/pipelines.json';
const defaultProps = { const defaultProps = {
pipelines: [], pipelines: [],
viewType: 'root', viewType: 'root',
...@@ -29,7 +28,8 @@ describe('Pipelines Table', () => { ...@@ -29,7 +28,8 @@ describe('Pipelines Table', () => {
}; };
const createMockPipeline = () => { const createMockPipeline = () => {
const { pipelines } = getJSONFixture(jsonFixtureName); // Clone fixture as it could be modified by tests
const { pipelines } = JSON.parse(JSON.stringify(fixture));
return pipelines.find((p) => p.user !== null && p.commit !== null); return pipelines.find((p) => p.user !== null && p.commit !== null);
}; };
......
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { getJSONFixture } from 'helpers/fixtures'; import testReports from 'test_fixtures/pipelines/test_report.json';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import createFlash from '~/flash'; import createFlash from '~/flash';
...@@ -13,7 +13,6 @@ describe('Actions TestReports Store', () => { ...@@ -13,7 +13,6 @@ describe('Actions TestReports Store', () => {
let mock; let mock;
let state; let state;
const testReports = getJSONFixture('pipelines/test_report.json');
const summary = { total_count: 1 }; const summary = { total_count: 1 };
const suiteEndpoint = `${TEST_HOST}/tests/suite.json`; const suiteEndpoint = `${TEST_HOST}/tests/suite.json`;
......
import { getJSONFixture } from 'helpers/fixtures'; import testReports from 'test_fixtures/pipelines/test_report.json';
import * as getters from '~/pipelines/stores/test_reports/getters'; import * as getters from '~/pipelines/stores/test_reports/getters';
import { import {
iconForTestStatus, iconForTestStatus,
...@@ -9,8 +9,6 @@ import { ...@@ -9,8 +9,6 @@ import {
describe('Getters TestReports Store', () => { describe('Getters TestReports Store', () => {
let state; let state;
const testReports = getJSONFixture('pipelines/test_report.json');
const defaultState = { const defaultState = {
blobPath: '/test/blob/path', blobPath: '/test/blob/path',
testReports, testReports,
......
import { getJSONFixture } from 'helpers/fixtures'; import testReports from 'test_fixtures/pipelines/test_report.json';
import * as types from '~/pipelines/stores/test_reports/mutation_types'; import * as types from '~/pipelines/stores/test_reports/mutation_types';
import mutations from '~/pipelines/stores/test_reports/mutations'; import mutations from '~/pipelines/stores/test_reports/mutations';
describe('Mutations TestReports Store', () => { describe('Mutations TestReports Store', () => {
let mockState; let mockState;
const testReports = getJSONFixture('pipelines/test_report.json');
const defaultState = { const defaultState = {
endpoint: '', endpoint: '',
testReports: {}, testReports: {},
......
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { getJSONFixture } from 'helpers/fixtures'; import testReports from 'test_fixtures/pipelines/test_report.json';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import EmptyState from '~/pipelines/components/test_reports/empty_state.vue'; import EmptyState from '~/pipelines/components/test_reports/empty_state.vue';
import TestReports from '~/pipelines/components/test_reports/test_reports.vue'; import TestReports from '~/pipelines/components/test_reports/test_reports.vue';
...@@ -16,8 +16,6 @@ describe('Test reports app', () => { ...@@ -16,8 +16,6 @@ describe('Test reports app', () => {
let wrapper; let wrapper;
let store; let store;
const testReports = getJSONFixture('pipelines/test_report.json');
const loadingSpinner = () => wrapper.findComponent(GlLoadingIcon); const loadingSpinner = () => wrapper.findComponent(GlLoadingIcon);
const testsDetail = () => wrapper.findByTestId('tests-detail'); const testsDetail = () => wrapper.findByTestId('tests-detail');
const emptyState = () => wrapper.findComponent(EmptyState); const emptyState = () => wrapper.findComponent(EmptyState);
......
import { GlButton, GlFriendlyWrap, GlLink, GlPagination } from '@gitlab/ui'; import { GlButton, GlFriendlyWrap, GlLink, GlPagination } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { getJSONFixture } from 'helpers/fixtures'; import testReports from 'test_fixtures/pipelines/test_report.json';
import SuiteTable from '~/pipelines/components/test_reports/test_suite_table.vue'; import SuiteTable from '~/pipelines/components/test_reports/test_suite_table.vue';
import { TestStatus } from '~/pipelines/constants'; import { TestStatus } from '~/pipelines/constants';
import * as getters from '~/pipelines/stores/test_reports/getters'; import * as getters from '~/pipelines/stores/test_reports/getters';
...@@ -17,7 +17,7 @@ describe('Test reports suite table', () => { ...@@ -17,7 +17,7 @@ describe('Test reports suite table', () => {
const { const {
test_suites: [testSuite], test_suites: [testSuite],
} = getJSONFixture('pipelines/test_report.json'); } = testReports;
testSuite.test_cases = [...testSuite.test_cases, ...skippedTestCases]; testSuite.test_cases = [...testSuite.test_cases, ...skippedTestCases];
const testCases = testSuite.test_cases; const testCases = testSuite.test_cases;
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { getJSONFixture } from 'helpers/fixtures'; import testReports from 'test_fixtures/pipelines/test_report.json';
import Summary from '~/pipelines/components/test_reports/test_summary.vue'; import Summary from '~/pipelines/components/test_reports/test_summary.vue';
import { formattedTime } from '~/pipelines/stores/test_reports/utils'; import { formattedTime } from '~/pipelines/stores/test_reports/utils';
...@@ -8,7 +8,7 @@ describe('Test reports summary', () => { ...@@ -8,7 +8,7 @@ describe('Test reports summary', () => {
const { const {
test_suites: [testSuite], test_suites: [testSuite],
} = getJSONFixture('pipelines/test_report.json'); } = testReports;
const backButton = () => wrapper.find('.js-back-button'); const backButton = () => wrapper.find('.js-back-button');
const totalTests = () => wrapper.find('.js-total-tests'); const totalTests = () => wrapper.find('.js-total-tests');
......
import { mount, createLocalVue } from '@vue/test-utils'; import { mount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { getJSONFixture } from 'helpers/fixtures'; import testReports from 'test_fixtures/pipelines/test_report.json';
import SummaryTable from '~/pipelines/components/test_reports/test_summary_table.vue'; import SummaryTable from '~/pipelines/components/test_reports/test_summary_table.vue';
import * as getters from '~/pipelines/stores/test_reports/getters'; import * as getters from '~/pipelines/stores/test_reports/getters';
...@@ -11,8 +11,6 @@ describe('Test reports summary table', () => { ...@@ -11,8 +11,6 @@ describe('Test reports summary table', () => {
let wrapper; let wrapper;
let store; let store;
const testReports = getJSONFixture('pipelines/test_report.json');
const allSuitesRows = () => wrapper.findAll('.js-suite-row'); const allSuitesRows = () => wrapper.findAll('.js-suite-row');
const noSuitesToShow = () => wrapper.find('.js-no-tests-suites'); const noSuitesToShow = () => wrapper.find('.js-no-tests-suites');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment