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