mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 09:57:35 -02:30
Allow tests to run in Phantom via testem for CI
This commit is contained in:
5
Makefile
5
Makefile
@@ -3,6 +3,7 @@ SITELIB=$(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; pr
|
|||||||
OFFICIAL ?= no
|
OFFICIAL ?= no
|
||||||
PACKER ?= packer
|
PACKER ?= packer
|
||||||
GRUNT ?= $(shell [ -t 0 ] && echo "grunt" || echo "grunt --no-color")
|
GRUNT ?= $(shell [ -t 0 ] && echo "grunt" || echo "grunt --no-color")
|
||||||
|
TESTEM ?= ./node_modules/.bin/testem
|
||||||
BROCCOLI ?= ./node_modules/.bin/broccoli
|
BROCCOLI ?= ./node_modules/.bin/broccoli
|
||||||
NODE ?= node
|
NODE ?= node
|
||||||
|
|
||||||
@@ -293,8 +294,8 @@ reports/ui_code: node_modules clean-ui Brocfile.js bower.json Gruntfile.js
|
|||||||
$(BROCCOLI) build reports/ui_code -- --no-concat --no-tests --no-styles --no-sourcemaps
|
$(BROCCOLI) build reports/ui_code -- --no-concat --no-tests --no-styles --no-sourcemaps
|
||||||
|
|
||||||
# Run UI unit tests
|
# Run UI unit tests
|
||||||
test_ui: node_modules minjs_ci Gruntfile.js
|
test_ui: node_modules minjs_ci
|
||||||
$(GRUNT) karma:ci
|
$(TESTEM) ci --file testem.yml -R xunit
|
||||||
|
|
||||||
# Run API unit tests across multiple Python/Django versions with Tox.
|
# Run API unit tests across multiple Python/Django versions with Tox.
|
||||||
test_tox:
|
test_tox:
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import 'tower/shared/Utilities';
|
|||||||
import 'tower/shared/RestServices';
|
import 'tower/shared/RestServices';
|
||||||
import JobStatusGraph from 'tower/dashboard/graphs/job-status/main';
|
import JobStatusGraph from 'tower/dashboard/graphs/job-status/main';
|
||||||
|
|
||||||
var sinon = require('sinon');
|
|
||||||
|
|
||||||
var resizeHandler = sinon.spy();
|
var resizeHandler = sinon.spy();
|
||||||
|
|
||||||
window.$.fn.removeResize = angular.noop;
|
window.$.fn.removeResize = angular.noop;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import '../setup-browser';
|
|||||||
|
|
||||||
import {describeModule} from '../describe-module';
|
import {describeModule} from '../describe-module';
|
||||||
import mod from 'tower/shared/multi-select-list/main';
|
import mod from 'tower/shared/multi-select-list/main';
|
||||||
var sinon = require('sinon');
|
|
||||||
|
|
||||||
describeModule(mod.name)
|
describeModule(mod.name)
|
||||||
.testDirective('multiSelectList', function(test) {
|
.testDirective('multiSelectList', function(test) {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import '../setup-browser';
|
|||||||
import {describeModule} from '../describe-module';
|
import {describeModule} from '../describe-module';
|
||||||
import mod from 'tower/shared/multi-select-list/main';
|
import mod from 'tower/shared/multi-select-list/main';
|
||||||
|
|
||||||
var sinon = require('sinon');
|
|
||||||
|
|
||||||
var mockController = {
|
var mockController = {
|
||||||
selectAll: sinon.spy(),
|
selectAll: sinon.spy(),
|
||||||
deselectAll: sinon.spy(),
|
deselectAll: sinon.spy(),
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import '../setup-browser';
|
|||||||
import {describeModule} from '../describe-module';
|
import {describeModule} from '../describe-module';
|
||||||
import JobStatusGraph from 'tower/dashboard/graphs/job-status/main';
|
import JobStatusGraph from 'tower/dashboard/graphs/job-status/main';
|
||||||
|
|
||||||
var sinon = require('sinon');
|
|
||||||
|
|
||||||
var processErrors = sinon.spy();
|
var processErrors = sinon.spy();
|
||||||
|
|
||||||
describeModule(JobStatusGraph.name)
|
describeModule(JobStatusGraph.name)
|
||||||
|
|||||||
@@ -1,52 +1,68 @@
|
|||||||
/* jshint node: true */
|
/* jshint node: true */
|
||||||
|
|
||||||
var jsdom = require('jsdom').jsdom;
|
(function() {
|
||||||
var document = jsdom('tower');
|
var isNode = typeof window === 'undefined';
|
||||||
var window = document.parentWindow;
|
|
||||||
var mocha = require('mocha');
|
|
||||||
window.mocha = mocha;
|
|
||||||
window.beforeEach = beforeEach;
|
|
||||||
window.afterEach = afterEach;
|
|
||||||
|
|
||||||
global.document = document;
|
if (!isNode) {
|
||||||
global.window = window;
|
window.expect = chai.expect;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var jquery = require('jquery');
|
setupNode();
|
||||||
global.$ = window.$ = global.jQuery = window.jQuery = jquery;
|
|
||||||
|
|
||||||
require('angular/angular');
|
function setupNode() {
|
||||||
|
|
||||||
require('angular-mocks/angular-mocks');
|
var jsdom = require('jsdom').jsdom;
|
||||||
|
var document = jsdom('tower');
|
||||||
|
var window = document.parentWindow;
|
||||||
|
var mocha = require('mocha');
|
||||||
|
window.mocha = mocha;
|
||||||
|
window.beforeEach = beforeEach;
|
||||||
|
window.afterEach = afterEach;
|
||||||
|
|
||||||
var chai = require('chai');
|
global.document = document;
|
||||||
var expect = chai.expect;
|
global.window = window;
|
||||||
var sinonChai = require('sinon-chai');
|
|
||||||
var chaiAsPromised = require('chai-as-promised');
|
|
||||||
var sinon = require('sinon');
|
|
||||||
var chaiThings = require('chai-things');
|
|
||||||
|
|
||||||
chai.use(sinonChai);
|
var jquery = require('jquery');
|
||||||
chai.use(chaiAsPromised);
|
global.$ = window.$ = global.jQuery = window.jQuery = jquery;
|
||||||
chai.use(chaiThings);
|
|
||||||
|
|
||||||
global.angular = window.angular;
|
require('angular/angular');
|
||||||
global.inject = window.inject;
|
|
||||||
global.expect = chai.expect;
|
|
||||||
|
|
||||||
angular.module('templates', []);
|
require('angular-mocks/angular-mocks');
|
||||||
require('../../templates');
|
|
||||||
|
|
||||||
var d3 = require('d3');
|
var chai = require('chai');
|
||||||
global.d3 = d3;
|
var expect = chai.expect;
|
||||||
|
var sinonChai = require('sinon-chai');
|
||||||
|
var chaiAsPromised = require('chai-as-promised');
|
||||||
|
var sinon = require('sinon');
|
||||||
|
var chaiThings = require('chai-things');
|
||||||
|
|
||||||
var nv = require('nvd3');
|
chai.use(sinonChai);
|
||||||
global.nv = nv;
|
chai.use(chaiAsPromised);
|
||||||
|
chai.use(chaiThings);
|
||||||
|
|
||||||
var lodash = require('lodash');
|
global.angular = window.angular;
|
||||||
global._ = lodash;
|
global.inject = window.inject;
|
||||||
|
global.expect = chai.expect;
|
||||||
|
global.sinon = require('sinon');
|
||||||
|
|
||||||
var LocalStorage = require('node-localstorage').LocalStorage;
|
angular.module('templates', []);
|
||||||
global.localStorage = window.localStorage = new LocalStorage('./scratch');
|
require('../../templates');
|
||||||
|
|
||||||
var moment = require('moment');
|
var d3 = require('d3');
|
||||||
window.moment = moment;
|
global.d3 = d3;
|
||||||
|
|
||||||
|
var nv = require('nvd3');
|
||||||
|
global.nv = nv;
|
||||||
|
|
||||||
|
var lodash = require('lodash');
|
||||||
|
global._ = lodash;
|
||||||
|
|
||||||
|
var LocalStorage = require('node-localstorage').LocalStorage;
|
||||||
|
global.localStorage = window.localStorage = new LocalStorage('./scratch');
|
||||||
|
|
||||||
|
var moment = require('moment');
|
||||||
|
window.moment = moment;
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
|
|||||||
25
testem.yml
25
testem.yml
@@ -1,25 +1,30 @@
|
|||||||
---
|
---
|
||||||
# before_tests: cd ../../.. && sudo make devjs
|
|
||||||
framework: mocha
|
framework: mocha
|
||||||
cwd: awx/ui/dist/node-tests
|
cwd: awx/ui/
|
||||||
|
port: 7358
|
||||||
src_files:
|
src_files:
|
||||||
- tests/**.js
|
|
||||||
- static/js/**/*.js
|
- static/js/**/*.js
|
||||||
- static/lib/**/*.js
|
- static/lib/**/*.js
|
||||||
disable_watching: true
|
- tests/**/*.js
|
||||||
serve_files:
|
serve_files:
|
||||||
- ../tower.concat.js
|
- dist/tower.concat.js
|
||||||
- tests/templates.js
|
- dist/tests/**/*.js
|
||||||
- tests/test-support.js
|
- dist/tests/unit.js
|
||||||
- tests/unit/**/*.js
|
|
||||||
- tests/unit.js
|
|
||||||
unsafe_file_serving: true
|
unsafe_file_serving: true
|
||||||
|
test_page: tests.html
|
||||||
|
disable_watching: true
|
||||||
routes:
|
routes:
|
||||||
/awx/ui/dist: /static
|
/awx/ui/dist: /static
|
||||||
|
/tests.html: ../../packaging/grunt/testem.mustache
|
||||||
|
/test-loader.js: static/lib/ember-cli-test-loader/test-loader.js
|
||||||
|
/vendor: ../../node_modules
|
||||||
|
/angular-mocks.js: dist/lib/angular-mocks/angular-mocks.js
|
||||||
|
/templates.js: dist/node-tests/templates.js
|
||||||
|
reporter: xunit
|
||||||
launch_in_dev:
|
launch_in_dev:
|
||||||
- Mocha
|
- Mocha
|
||||||
launch_in_ci:
|
launch_in_ci:
|
||||||
- PhantomJS
|
- PhantomJS
|
||||||
launchers:
|
launchers:
|
||||||
Mocha:
|
Mocha:
|
||||||
command: NODE_PATH=awx/ui/dist/node-tests ./node_modules/.bin/mocha awx/ui/dist/node-tests/tests/unit/**/*.js
|
command: NODE_PATH=awx/ui/dist/node-tests ./node_modules/.bin/mocha $(find awx/ui/dist/node-tests/tests/ -name '*-test.js')
|
||||||
|
|||||||
Reference in New Issue
Block a user