Commit 537f4c2b authored by Illya Klymov's avatar Illya Klymov

Merge branch '339346-deprecate-get-json-fixture' into 'master'

Deprecate getJSONFixture

See merge request gitlab-org/gitlab!71808
parents ac6d25e8 b2becf16
/* eslint-disable import/no-deprecated */
import { uniq } from 'lodash';
import tasksByType from 'test_fixtures/analytics/charts/type_of_work/tasks_by_type.json';
import {
......
import json from 'test_fixtures/graphql/analytics/devops_report/devops_adoption/graphql/queries/devops_adoption_enabled_namespaces.query.graphql.json';
import devopsAdoptionOverviewChartJson from 'test_fixtures/graphql/analytics/devops_report/devops_adoption/graphql/queries/devops_adoption_overview_chart.query.graphql.json';
import devopsAdoptionEnabledNamespacesJson from 'test_fixtures/graphql/analytics/devops_report/devops_adoption/graphql/queries/devops_adoption_enabled_namespaces.query.graphql.json';
import { DEVOPS_ADOPTION_TABLE_CONFIGURATION } from 'ee/analytics/devops_report/devops_adoption/constants';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
export const namespaceWithSnapotsData = getJSONFixture(
'graphql/analytics/devops_report/devops_adoption/graphql/queries/devops_adoption_overview_chart.query.graphql.json',
);
export const namespaceWithSnapotsData = devopsAdoptionOverviewChartJson;
export const devopsAdoptionNamespaceData = json.data.devopsAdoptionEnabledNamespaces;
export const devopsAdoptionNamespaceData =
devopsAdoptionEnabledNamespacesJson.data.devopsAdoptionEnabledNamespaces;
export const groupData = devopsAdoptionNamespaceData.nodes.map((node) => {
return {
......
......@@ -11,6 +11,8 @@ import {
import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
// eslint-disable-next-line import/no-deprecated
import { getJSONFixture } from 'helpers/fixtures';
import CreateIssueForm from 'ee/related_items_tree/components/create_issue_form.vue';
import createDefaultStore from 'ee/related_items_tree/store';
import ProjectAvatar from '~/vue_shared/components/project_avatar.vue';
......@@ -22,6 +24,7 @@ import {
mockMixedFrequentlyUsedProjects,
} from '../mock_data';
// eslint-disable-next-line import/no-deprecated
const mockProjects = getJSONFixture('static/projects.json');
const localVue = createLocalVue();
......
......@@ -9,12 +9,14 @@ import SlotSwitch from '~/vue_shared/components/slot_switch.vue';
import RelatedItemsTreeApp from 'ee/related_items_tree/components/related_items_tree_app.vue';
import RelatedItemsTreeHeader from 'ee/related_items_tree/components/related_items_tree_header.vue';
import createDefaultStore from 'ee/related_items_tree/store';
// eslint-disable-next-line import/no-deprecated
import { getJSONFixture } from 'helpers/fixtures';
import axios from '~/lib/utils/axios_utils';
import { issuableTypesMap } from '~/related_issues/constants';
import { mockInitialConfig, mockParentItem, mockEpics, mockIssues } from '../mock_data';
// eslint-disable-next-line import/no-deprecated
const mockProjects = getJSONFixture('static/projects.json');
const localVue = createLocalVue();
......
import MockAdapter from 'axios-mock-adapter';
// eslint-disable-next-line import/no-deprecated
import { getJSONFixture } from 'helpers/fixtures';
import { ChildType, ChildState } from 'ee/related_items_tree/constants';
import * as actions from 'ee/related_items_tree/store/actions';
import * as types from 'ee/related_items_tree/store/mutation_types';
......@@ -28,6 +31,7 @@ import {
mockEpic1,
} from '../mock_data';
// eslint-disable-next-line import/no-deprecated
const mockProjects = getJSONFixture('static/projects.json');
jest.mock('~/flash');
......
......@@ -12,7 +12,6 @@ settings:
jest:
jestConfigFile: 'jest.config.js'
globals:
getJSONFixture: false
loadFixtures: false
setFixtures: false
rules:
......
......@@ -20,6 +20,11 @@ Did you run bin/rake frontend:fixtures?`,
return fs.readFileSync(absolutePath, 'utf8');
}
/**
* @deprecated Use `import` to load a JSON fixture instead.
* See https://docs.gitlab.com/ee/development/testing_guide/frontend_testing.html#use-fixtures,
* https://gitlab.com/gitlab-org/gitlab/-/issues/339346.
*/
export const getJSONFixture = (relativePath) => JSON.parse(getFixture(relativePath));
export const resetHTMLFixture = () => {
......
import fs from 'fs';
import path from 'path';
import jsYaml from 'js-yaml';
// eslint-disable-next-line import/no-deprecated
import { getJSONFixture } from 'helpers/fixtures';
export const loadMarkdownApiResult = (testName) => {
const fixturePathPrefix = `api/markdown/${testName}.json`;
// eslint-disable-next-line import/no-deprecated
const fixture = getJSONFixture(fixturePathPrefix);
return fixture.body || fixture.html;
};
......
/* eslint-disable import/no-deprecated */
import { getJSONFixture } from 'helpers/fixtures';
import { TEST_HOST } from 'helpers/test_constants';
import {
......
......@@ -3,6 +3,8 @@
import $ from 'jquery';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import '~/lib/utils/common_utils';
// eslint-disable-next-line import/no-deprecated
import { getJSONFixture } from 'helpers/fixtures';
import { visitUrl } from '~/lib/utils/url_utility';
jest.mock('~/lib/utils/url_utility', () => ({
......@@ -66,6 +68,7 @@ describe('deprecatedJQueryDropdown', () => {
loadFixtures('static/deprecated_jquery_dropdown.html');
test.dropdownContainerElement = $('.dropdown.inline');
test.$dropdownMenuElement = $('.dropdown-menu', test.dropdownContainerElement);
// eslint-disable-next-line import/no-deprecated
test.projectsData = getJSONFixture('static/projects.json');
});
......
// eslint-disable-next-line import/no-deprecated
import { getJSONFixture, setHTMLFixture } from 'helpers/fixtures';
import FilterableList from '~/filterable_list';
......@@ -14,6 +15,7 @@ describe('FilterableList', () => {
</div>
<div class="js-projects-list-holder"></div>
`);
// eslint-disable-next-line import/no-deprecated
getJSONFixture('static/projects.json');
form = document.querySelector('form#project-filter-form');
filter = document.querySelector('.js-projects-list-filter');
......
// eslint-disable-next-line import/no-deprecated
import { getJSONFixture, setHTMLFixture } from 'helpers/fixtures';
import ProjectsFilterableList from '~/projects/projects_filterable_list';
......@@ -14,6 +15,7 @@ describe('ProjectsFilterableList', () => {
</div>
<div class="js-projects-list-holder"></div>
`);
// eslint-disable-next-line import/no-deprecated
getJSONFixture('static/projects.json');
form = document.querySelector('form#project-filter-form');
filter = document.querySelector('.js-projects-list-filter');
......
......@@ -6,7 +6,7 @@ import { setGlobalDateToFakeDate } from 'helpers/fake_date';
import setWindowLocation from 'helpers/set_window_location_helper';
import { TEST_HOST } from 'helpers/test_constants';
import Translate from '~/vue_shared/translate';
import { getJSONFixture, loadHTMLFixture, setHTMLFixture } from './__helpers__/fixtures';
import { loadHTMLFixture, setHTMLFixture } from './__helpers__/fixtures';
import { initializeTestTimeout } from './__helpers__/timeout';
import customMatchers from './matchers';
import { setupManualMocks } from './mocks/mocks_helper';
......@@ -43,7 +43,6 @@ Vue.use(Translate);
// convenience wrapper for migration from Karma
Object.assign(global, {
getJSONFixture,
loadFixtures: loadHTMLFixture,
setFixtures: setHTMLFixture,
});
......
import { shallowMount, createLocalVue } from '@vue/test-utils';
// eslint-disable-next-line import/no-deprecated
import { getJSONFixture } from 'helpers/fixtures';
import { trimText } from 'helpers/text_helper';
import ProjectAvatar from '~/vue_shared/components/deprecated_project_avatar/default.vue';
import ProjectListItem from '~/vue_shared/components/project_selector/project_list_item.vue';
......@@ -11,6 +13,7 @@ describe('ProjectListItem component', () => {
let vm;
let options;
// eslint-disable-next-line import/no-deprecated
const project = getJSONFixture('static/projects.json')[0];
beforeEach(() => {
......
......@@ -2,6 +2,8 @@ import { GlSearchBoxByType, GlInfiniteScroll } from '@gitlab/ui';
import { mount, createLocalVue } from '@vue/test-utils';
import { head } from 'lodash';
import Vue from 'vue';
// eslint-disable-next-line import/no-deprecated
import { getJSONFixture } from 'helpers/fixtures';
import { trimText } from 'helpers/text_helper';
import ProjectListItem from '~/vue_shared/components/project_selector/project_list_item.vue';
import ProjectSelector from '~/vue_shared/components/project_selector/project_selector.vue';
......@@ -11,6 +13,7 @@ const localVue = createLocalVue();
describe('ProjectSelector component', () => {
let wrapper;
let vm;
// eslint-disable-next-line import/no-deprecated
const allProjects = getJSONFixture('static/projects.json');
const searchResults = allProjects.slice(0, 5);
let selected = [];
......
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