Commit 06b06736 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'winh-separate-frontend-fixtures' into 'master'

Generate EE-specific JavaScript fixtures into ee/ directory  (CE-backport)

See merge request gitlab-org/gitlab-ce!28032
parents 2cbfd5c5 fbac16b2
......@@ -59,8 +59,6 @@ eslint-report.html
/public/uploads.*
/public/uploads/
/shared/artifacts/
/spec/javascripts/fixtures/blob/pdf/
/spec/javascripts/fixtures/blob/balsamiq/
/rails_best_practices_output.html
/tags
/tmp/*
......
......@@ -4,6 +4,7 @@ const chalk = require('chalk');
const webpack = require('webpack');
const argumentsParser = require('commander');
const webpackConfig = require('./webpack.config.js');
const IS_EE = require('./helpers/is_ee_env');
const ROOT_PATH = path.resolve(__dirname, '..');
const SPECS_PATH = /^(?:\.[\\\/])?(ee[\\\/])?spec[\\\/]javascripts[\\\/]/;
......@@ -90,6 +91,8 @@ if (specFilters.length) {
module.exports = function(config) {
process.env.TZ = 'Etc/UTC';
const fixturesPath = `${IS_EE ? 'ee/' : ''}spec/javascripts/fixtures`;
const karmaConfig = {
basePath: ROOT_PATH,
browsers: ['ChromeHeadlessCustom'],
......@@ -110,7 +113,7 @@ module.exports = function(config) {
frameworks: ['jasmine'],
files: [
{ pattern: 'spec/javascripts/test_bundle.js', watched: false },
{ pattern: `spec/javascripts/fixtures/**/*@(.json|.html|.png|.bmpr|.pdf)`, included: false },
{ pattern: `${fixturesPath}/**/*@(.json|.html|.png|.bmpr|.pdf)`, included: false },
],
preprocessors: {
'spec/javascripts/**/*.js': ['webpack', 'sourcemap'],
......
......@@ -59,7 +59,11 @@ module Gitlab
end
def self.ee?
Object.const_defined?(:License)
if ENV['IS_GITLAB_EE'].present?
Gitlab::Utils.to_boolean(ENV['IS_GITLAB_EE'])
else
Object.const_defined?(:License)
end
end
def self.process_name
......
......@@ -24,8 +24,9 @@ class CustomEnvironment extends JSDOMEnvironment {
});
const { testEnvironmentOptions } = config;
const { IS_EE } = testEnvironmentOptions;
this.global.gon = {
ee: testEnvironmentOptions.IS_EE,
ee: IS_EE,
};
this.rejectedPromises = [];
......@@ -33,6 +34,10 @@ class CustomEnvironment extends JSDOMEnvironment {
this.global.promiseRejectionHandler = error => {
this.rejectedPromises.push(error);
};
this.global.fixturesBasePath = `${process.cwd()}/${
IS_EE ? 'ee/' : ''
}spec/javascripts/fixtures`;
}
async teardown() {
......
......@@ -3,10 +3,8 @@ import path from 'path';
import { ErrorWithStack } from 'jest-util';
const fixturesBasePath = path.join(process.cwd(), 'spec', 'javascripts', 'fixtures');
export function getFixture(relativePath) {
const absolutePath = path.join(fixturesBasePath, relativePath);
const absolutePath = path.join(global.fixturesBasePath, relativePath);
if (!fs.existsSync(absolutePath)) {
throw new ErrorWithStack(
`Fixture file ${relativePath} does not exist.
......
export const FIXTURES_PATH = '/base/spec/javascripts/fixtures';
export const FIXTURES_PATH = `/base/${
process.env.IS_GITLAB_EE ? 'ee/' : ''
}spec/javascripts/fixtures`;
export const TEST_HOST = 'http://test.host';
export const DUMMY_IMAGE_URL = `${FIXTURES_PATH}/static/images/one_white_pixel.png`;
......
......@@ -15,7 +15,7 @@ module JavaScriptFixturesHelpers
end
def fixture_root_path
'spec/javascripts/fixtures'
(Gitlab.ee? ? 'ee/' : '') + 'spec/javascripts/fixtures'
end
# Public: Removes all fixture files from given directory
......
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