Commit 40c0337d authored by Phil Hughes's avatar Phil Hughes

Merge branch '3871-move-ee-specific-javascript-tests-to-ee-part-1' into 'master'

Part 1 of "Move EE JavaScript tests to their own respective directory"

See merge request gitlab-org/gitlab-ee!6184
parents d0a81caf 9145daf6
...@@ -103,6 +103,7 @@ module.exports = function(config) { ...@@ -103,6 +103,7 @@ module.exports = function(config) {
], ],
preprocessors: { preprocessors: {
'spec/javascripts/**/*.js': ['webpack', 'sourcemap'], 'spec/javascripts/**/*.js': ['webpack', 'sourcemap'],
'ee/spec/javascripts/**/*.js': ['webpack', 'sourcemap'],
}, },
reporters: [progressReporter], reporters: [progressReporter],
webpack: webpackConfig, webpack: webpackConfig,
......
...@@ -107,6 +107,7 @@ module.exports = { ...@@ -107,6 +107,7 @@ module.exports = {
ee_empty_states: path.join(ROOT_PATH, 'ee/app/views/shared/empty_states'), ee_empty_states: path.join(ROOT_PATH, 'ee/app/views/shared/empty_states'),
ee_icons: path.join(ROOT_PATH, 'ee/app/views/shared/icons'), ee_icons: path.join(ROOT_PATH, 'ee/app/views/shared/icons'),
ee_images: path.join(ROOT_PATH, 'ee/app/assets/images'), ee_images: path.join(ROOT_PATH, 'ee/app/assets/images'),
ee_spec: path.join(ROOT_PATH, 'ee/spec/javascripts'),
}, },
}, },
......
<script> <script>
import ReportSection from 'ee/vue_shared/security_reports/components/report_section.vue';
import GroupedSecurityReportsApp from 'ee/vue_shared/security_reports/grouped_security_reports_app.vue';
import reportsMixin from 'ee/vue_shared/security_reports/mixins/reports_mixin';
import { n__, s__, __, sprintf } from '~/locale'; import { n__, s__, __, sprintf } from '~/locale';
import CEWidgetOptions from '~/vue_merge_request_widget/mr_widget_options.vue'; import CEWidgetOptions from '~/vue_merge_request_widget/mr_widget_options.vue';
import WidgetApprovals from './components/approvals/mr_widget_approvals.vue'; import WidgetApprovals from './components/approvals/mr_widget_approvals.vue';
import GeoSecondaryNode from './components/states/mr_widget_secondary_geo_node.vue'; import GeoSecondaryNode from './components/states/mr_widget_secondary_geo_node.vue';
import ReportSection from '../vue_shared/security_reports/components/report_section.vue';
import GroupedSecurityReportsApp from '../vue_shared/security_reports/grouped_security_reports_app.vue';
import reportsMixin from '../vue_shared/security_reports/mixins/reports_mixin';
export default { export default {
components: { components: {
......
import CEMergeRequestStore from '~/vue_merge_request_widget/stores/mr_widget_store'; import CEMergeRequestStore from '~/vue_merge_request_widget/stores/mr_widget_store';
import { filterByKey } from '../../vue_shared/security_reports/store/utils'; import { filterByKey } from 'ee/vue_shared/security_reports/store/utils';
export default class MergeRequestStore extends CEMergeRequestStore { export default class MergeRequestStore extends CEMergeRequestStore {
constructor(data) { constructor(data) {
......
---
env:
jasmine: true
extends: plugin:jasmine/recommended
globals:
appendLoadFixtures: false
appendLoadStyleFixtures: false
appendSetFixtures: false
appendSetStyleFixtures: false
getJSONFixture: false
loadFixtures: false
loadJSONFixtures: false
loadStyleFixtures: false
preloadFixtures: false
preloadStyleFixtures: false
readFixtures: false
sandbox: false
setFixtures: false
setStyleFixtures: false
spyOnDependency: false
spyOnEvent: false
ClassSpecHelper: false
plugins:
- jasmine
rules:
func-names: off
jasmine/no-suite-dupes:
- warn
- branch
jasmine/no-spec-dupes:
- warn
- branch
no-console: off
prefer-arrow-callback: off
import/no-extraneous-dependencies:
- error
- devDependencies:
- ee/spec/**/*.js
...@@ -85,19 +85,25 @@ beforeEach(() => { ...@@ -85,19 +85,25 @@ beforeEach(() => {
const axiosDefaultAdapter = getDefaultAdapter(); const axiosDefaultAdapter = getDefaultAdapter();
// render all of our tests // render all of our tests
const testsContext = require.context('.', true, /_spec$/); const testContexts = [
testsContext.keys().forEach(function(path) { require.context('spec', true, /_spec$/),
try { require.context('ee_spec', true, /_spec$/),
testsContext(path); ];
} catch (err) {
console.log(err); testContexts.forEach(context => {
console.error('[GL SPEC RUNNER ERROR] Unable to load spec: ', path); context.keys().forEach(path => {
describe('Test bundle', function() { try {
it(`includes '${path}'`, function() { context(path);
expect(err).toBeNull(); } catch (err) {
console.log(err);
console.error('[GL SPEC RUNNER ERROR] Unable to load spec: ', path);
describe('Test bundle', function() {
it(`includes '${path}'`, function() {
expect(err).toBeNull();
});
}); });
}); }
} });
}); });
describe('test errors', () => { describe('test errors', () => {
...@@ -166,24 +172,31 @@ if (process.env.BABEL_ENV === 'coverage') { ...@@ -166,24 +172,31 @@ if (process.env.BABEL_ENV === 'coverage') {
]; ];
describe('Uncovered files', function() { describe('Uncovered files', function() {
const sourceFiles = require.context('~', true, /\.js$/); const sourceFilesContexts = [
require.context('~', true, /\.js$/),
require.context('ee', true, /\.js$/),
];
const allTestFiles = testContexts.reduce((accumulator, context) =>
accumulator.concat(context.keys()), []);
$.holdReady(true); $.holdReady(true);
sourceFiles.keys().forEach(function(path) { sourceFilesContexts.forEach(context => {
// ignore if there is a matching spec file context.keys().forEach(path => {
if (testsContext.keys().indexOf(`${path.replace(/\.js$/, '')}_spec`) > -1) { // ignore if there is a matching spec file
return; if (allTestFiles.indexOf(`${path.replace(/\.js$/, '')}_spec`) > -1) {
} return;
it(`includes '${path}'`, function() {
try {
sourceFiles(path);
} catch (err) {
if (troubleMakers.indexOf(path) === -1) {
expect(err).toBeNull();
}
} }
it(`includes '${path}'`, function() {
try {
context(path);
} catch (err) {
if (troubleMakers.indexOf(path) === -1) {
expect(err).toBeNull();
}
}
});
}); });
}); });
}); });
......
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