From 89142f985deaff5cd60db0a95f05b646641f6f04 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Wed, 17 Jul 2019 17:47:33 -0500 Subject: Move frontend fixtures to tmp/tests --- config/karma.config.js | 10 ++++++++-- spec/frontend/environment.js | 3 ++- spec/frontend/helpers/fixtures.js | 5 ++++- spec/javascripts/test_constants.js | 4 +--- spec/support/helpers/javascript_fixtures_helpers.rb | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/config/karma.config.js b/config/karma.config.js index 2a5bf3581e0..4aaa773d6cc 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -107,7 +107,8 @@ if (specFilters.length) { module.exports = function(config) { process.env.TZ = 'Etc/UTC'; - const fixturesPath = `${IS_EE ? 'ee/' : ''}spec/javascripts/fixtures`; + const fixturesPath = `tmp/tests/frontend/fixtures${IS_EE ? '-ee' : ''}`; + const staticFixturesPath = 'spec/javascripts/fixtures/static'; const karmaConfig = { basePath: ROOT_PATH, @@ -131,8 +132,13 @@ module.exports = function(config) { frameworks: ['jasmine'], files: [ { pattern: 'spec/javascripts/test_bundle.js', watched: false }, - { pattern: `${fixturesPath}/**/*@(.json|.html|.png|.bmpr|.pdf)`, included: false }, + { pattern: `${fixturesPath}/**/*`, included: false }, + { pattern: `${staticFixturesPath}/**/*`, included: false }, ], + proxies: { + '/fixtures/': `/base/${fixturesPath}/`, + '/fixtures/static/': `/base/${staticFixturesPath}/`, + }, preprocessors: { 'spec/javascripts/**/*.js': ['webpack', 'sourcemap'], 'ee/spec/javascripts/**/*.js': ['webpack', 'sourcemap'], diff --git a/spec/frontend/environment.js b/spec/frontend/environment.js index 8fd39201d39..3486d7769c1 100644 --- a/spec/frontend/environment.js +++ b/spec/frontend/environment.js @@ -38,7 +38,8 @@ class CustomEnvironment extends JSDOMEnvironment { this.rejectedPromises.push(error); }; - this.global.fixturesBasePath = `${ROOT_PATH}/${IS_EE ? 'ee/' : ''}spec/javascripts/fixtures`; + this.global.fixturesBasePath = `${ROOT_PATH}/tmp/tests/frontend/fixtures${IS_EE ? '-ee' : ''}`; + this.global.staticFixturesBasePath = `${ROOT_PATH}/spec/javascripts/fixtures`; // Not yet supported by JSDOM: https://github.com/jsdom/jsdom/issues/317 this.global.document.createRange = () => ({ diff --git a/spec/frontend/helpers/fixtures.js b/spec/frontend/helpers/fixtures.js index 09d91e963fd..778196843db 100644 --- a/spec/frontend/helpers/fixtures.js +++ b/spec/frontend/helpers/fixtures.js @@ -4,7 +4,10 @@ import path from 'path'; import { ErrorWithStack } from 'jest-util'; export function getFixture(relativePath) { - const absolutePath = path.join(global.fixturesBasePath, relativePath); + const basePath = relativePath.startsWith('static/') + ? global.staticFixturesBasePath + : global.fixturesBasePath; + const absolutePath = path.join(basePath, relativePath); if (!fs.existsSync(absolutePath)) { throw new ErrorWithStack( `Fixture file ${relativePath} does not exist. diff --git a/spec/javascripts/test_constants.js b/spec/javascripts/test_constants.js index 77c206585fe..c97d47a6406 100644 --- a/spec/javascripts/test_constants.js +++ b/spec/javascripts/test_constants.js @@ -1,6 +1,4 @@ -export const FIXTURES_PATH = `/base/${ - process.env.IS_GITLAB_EE ? 'ee/' : '' -}spec/javascripts/fixtures`; +export const FIXTURES_PATH = `/fixtures`; export const TEST_HOST = 'http://test.host'; export const DUMMY_IMAGE_URL = `${FIXTURES_PATH}/static/images/one_white_pixel.png`; diff --git a/spec/support/helpers/javascript_fixtures_helpers.rb b/spec/support/helpers/javascript_fixtures_helpers.rb index cdd7724cc13..e9129bd263e 100644 --- a/spec/support/helpers/javascript_fixtures_helpers.rb +++ b/spec/support/helpers/javascript_fixtures_helpers.rb @@ -19,7 +19,7 @@ module JavaScriptFixturesHelpers end def fixture_root_path - (Gitlab.ee? ? 'ee/' : '') + 'spec/javascripts/fixtures' + 'tmp/tests/frontend/fixtures' + (Gitlab.ee? ? '-ee' : '') end # Public: Removes all fixture files from given directory -- cgit v1.2.1