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