From fa5eed71553f2fa8c8ed5e47e068051b440addb2 Mon Sep 17 00:00:00 2001 From: David Dieulivol <ddieulivol@gitlab.com> Date: Thu, 6 Apr 2023 04:01:37 +0000 Subject: [PATCH] Remove loadHTMLFixture from spec - Add 'html' as module in Jest so that `--findRelatedTests` will work - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/116427 --- jest.config.base.js | 10 +++++++--- .../ci_variable_list/ci_variable_list_spec.js | 10 ++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/jest.config.base.js b/jest.config.base.js index 08ee2d87a60d1..8c063e7173fc5 100644 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -88,6 +88,9 @@ module.exports = (path, options = {}) => { } const TEST_FIXTURES_PATTERN = 'test_fixtures(/.*)$'; + const TEST_FIXTURES_HOME = '/tmp/tests/frontend/fixtures'; + const TEST_FIXTURES_HOME_EE = '/tmp/tests/frontend/fixtures-ee'; + const TEST_FIXTURES_RAW_LOADER_PATTERN = `${TEST_FIXTURES_HOME}.*\\.html$`; const moduleNameMapper = { '^~(/.*)\\?(worker|raw)$': '<rootDir>/app/assets/javascripts$1', @@ -103,7 +106,7 @@ module.exports = (path, options = {}) => { '^any_else_ce(/.*)$': '<rootDir>/app/assets/javascripts$1', '^helpers(/.*)$': '<rootDir>/spec/frontend/__helpers__$1', '^vendor(/.*)$': '<rootDir>/vendor/assets/javascripts$1', - [TEST_FIXTURES_PATTERN]: '<rootDir>/tmp/tests/frontend/fixtures$1', + [TEST_FIXTURES_PATTERN]: `<rootDir>${TEST_FIXTURES_HOME}$1`, '^test_fixtures_static(/.*)$': '<rootDir>/spec/frontend/fixtures/static$1', '\\.(jpg|jpeg|png|svg|css)$': '<rootDir>/spec/frontend/__mocks__/file_mock.js', '\\.svg\\?url$': '<rootDir>/spec/frontend/__mocks__/file_mock.js', @@ -132,7 +135,7 @@ module.exports = (path, options = {}) => { '^ee_else_ce_jest/(.*)$': specDirEE, '^any_else_ce(/.*)$': rootDirEE, '^jh_else_ee(/.*)$': rootDirEE, - [TEST_FIXTURES_PATTERN]: '<rootDir>/tmp/tests/frontend/fixtures-ee$1', + [TEST_FIXTURES_PATTERN]: `<rootDir>${TEST_FIXTURES_HOME_EE}$1`, ...extModuleNameMapperEE, }); @@ -216,7 +219,7 @@ module.exports = (path, options = {}) => { globals, clearMocks: true, testMatch, - moduleFileExtensions: ['js', 'json', 'vue', 'gql', 'graphql', 'yaml', 'yml'], + moduleFileExtensions: ['js', 'json', 'vue', 'gql', 'graphql', 'yaml', 'yml', 'html'], moduleNameMapper, collectCoverageFrom, coverageDirectory: coverageDirectory(), @@ -238,6 +241,7 @@ module.exports = (path, options = {}) => { 'spec/frontend/editor/schema/ci/yaml_tests/.+\\.(yml|yaml)$': './spec/frontend/__helpers__/yaml_transformer.js', '^.+\\.(md|zip|png|yml|yaml|sh|ps1)$': './spec/frontend/__helpers__/raw_transformer.js', + [TEST_FIXTURES_RAW_LOADER_PATTERN]: './spec/frontend/__helpers__/raw_transformer.js', }, transformIgnorePatterns: [`node_modules/(?!(${transformIgnoreNodeModules.join('|')}))`], fakeTimers: { diff --git a/spec/frontend/ci/ci_variable_list/ci_variable_list/ci_variable_list_spec.js b/spec/frontend/ci/ci_variable_list/ci_variable_list/ci_variable_list_spec.js index e4abedb412f21..8990a70d4efca 100644 --- a/spec/frontend/ci/ci_variable_list/ci_variable_list/ci_variable_list_spec.js +++ b/spec/frontend/ci/ci_variable_list/ci_variable_list/ci_variable_list_spec.js @@ -1,5 +1,7 @@ import $ from 'jquery'; -import { loadHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; +import htmlPipelineSchedulesEdit from 'test_fixtures/pipeline_schedules/edit.html'; +import htmlPipelineSchedulesEditWithVariables from 'test_fixtures/pipeline_schedules/edit_with_variables.html'; +import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; import VariableList from '~/ci/ci_variable_list/ci_variable_list'; const HIDE_CLASS = 'hide'; @@ -11,7 +13,7 @@ describe('VariableList', () => { describe('with only key/value inputs', () => { describe('with no variables', () => { beforeEach(() => { - loadHTMLFixture('pipeline_schedules/edit.html'); + setHTMLFixture(htmlPipelineSchedulesEdit); $wrapper = $('.js-ci-variable-list-section'); variableList = new VariableList({ @@ -69,7 +71,7 @@ describe('VariableList', () => { describe('with persisted variables', () => { beforeEach(() => { - loadHTMLFixture('pipeline_schedules/edit_with_variables.html'); + setHTMLFixture(htmlPipelineSchedulesEditWithVariables); $wrapper = $('.js-ci-variable-list-section'); variableList = new VariableList({ @@ -106,7 +108,7 @@ describe('VariableList', () => { describe('toggleEnableRow method', () => { beforeEach(() => { - loadHTMLFixture('pipeline_schedules/edit_with_variables.html'); + setHTMLFixture(htmlPipelineSchedulesEditWithVariables); $wrapper = $('.js-ci-variable-list-section'); variableList = new VariableList({ -- GitLab