Skip to content

Commit

Permalink
Update unit test dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminapetersen committed Sep 16, 2017
1 parent 5bf079c commit 91fe691
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 128 deletions.
12 changes: 9 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
language: node_js
node_js:
- "4"
- "6"
before_script:
- make build
- make build
# FIXME:
# This needs to be enabled again when we eliminate PhantomJS for Firefox
# Even the unit tests require a browser
# - export DISPLAY=:99.0
# - sh -e /etc/init.d/xvfb start
# - sleep 3 # give xvfb some time to start
script:
- grunt test --browsers=PhantomJS
- grunt test
- hack/verify-dist.sh
55 changes: 34 additions & 21 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = function (grunt) {
var contextRoot = grunt.option('contextRoot') || "dev-console";
var isMac = /^darwin/.test(process.platform) || grunt.option('mac');


// Load grunt tasks automatically
require('load-grunt-tasks')(grunt, {
pattern: ['grunt-*', '!grunt-template-jasmine-istanbul']
Expand Down Expand Up @@ -602,47 +603,54 @@ module.exports = function (grunt) {

// Test settings
karma: {
unit: {
options: {
configFile: 'test/karma.conf.js',
singleRun: true,
// default in karma.conf.js is Firefox, however, Chrome has much better
// error messages when writing tests. Call like this:
// grunt test
// grunt test --browsers=Chrome
// grunt test --browsers=Chrome,Firefox,Safari (be sure karma-<browser_name>-launcher is installed)
browsers: grunt.option('browsers') ?
grunt.option('browsers').split(',') :
['Firefox']
// if running locally on mac, we can test both FF & Chrome,
// in Travis, just FF
// ['Nightmare'] is a good alt for a current headless
// FIXME: fix this, PhantomJS is deprecated
isMac ?
['Firefox', 'Chrome'] :
['PhantomJS']
},
unit: {
singleRun: true,
}
},

protractor: {
options: {
configFile: "test/protractor.conf.js", // Default config file
configFile: "test/protractor.conf.js",
keepAlive: false, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
noColor: false,
args: {
// Arguments passed to the command
suite: grunt.option('suite') || 'full',
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/")
}
},
default: {
options: {
configFile: "test/protractor.conf.js", // Target-specific config file
configFile: "test/protractor.conf.js",
args: {
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
browser: grunt.option('browser') || "firefox"
} // Target-specific arguments
}
}
},
mac: {
options: {
configFile: "test/protractor-mac.conf.js", // Target-specific config file
configFile: "test/protractor-mac.conf.js",
args: {
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
browser: grunt.option('browser') || "firefox"
} // Target-specific arguments
}
}
}
},
Expand Down Expand Up @@ -728,7 +736,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-angular-templates');

// karma must run prior to coverage since karma will generate the coverage results
grunt.registerTask('test', [
grunt.registerTask('test-unit', [
'clean:server',
'concurrent:test',
'postcss',
Expand All @@ -737,18 +745,23 @@ module.exports = function (grunt) {
// 'coverage' - add back if we want to enforce coverage percentages
]);

// test as an alias to unit. after updating protractor,
// will make test an alias for both unit & e2e
grunt.registerTask('test', ['test-unit']);

grunt.registerTask('test-integration',
// if a baseUrl is defined assume we dont want to run the local grunt server
grunt.option('baseUrl') ?
[isMac ? 'protractor:mac' : 'protractor:default'] : // if a baseUrl is defined assume we dont want to run the local grunt server
[
'clean:server',
'development-build',
'postcss',
'connect:test',
'add-redirect-uri',
(isMac ? 'protractor:mac' : 'protractor:default'),
'clean:server'
]
[isMac ? 'protractor:mac' : 'protractor:default'] :
[
'clean:server',
'development-build',
'postcss',
'connect:test',
'add-redirect-uri',
(isMac ? 'protractor:mac' : 'protractor:default'),
'clean:server'
]
);

grunt.registerTask('build', [
Expand Down
6 changes: 4 additions & 2 deletions app/scripts/services/applicationGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,17 @@ angular.module("openshiftConsole")
sourceStrategy: {
from: {
kind: "ImageStreamTag",
name: input.imageName + ":" + input.imageTag,
namespace: input.namespace
name: input.imageName + ":" + input.imageTag
},
env: env
}
},
triggers: triggers
}
};
if(input.namespace) {
bc.spec.strategy.namespace = input.namespace;
}
if (_.get(input, 'buildConfig.secrets.gitSecret[0].name')) {
bc.spec.source.sourceSecret = _.head(input.buildConfig.secrets.gitSecret);
}
Expand Down
8 changes: 6 additions & 2 deletions app/scripts/services/membership/membership.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,16 @@ angular
if(!result[subject.kind].subjects[subjectKey]) {
result[subject.kind].subjects[subjectKey] = {
name: subject.name,
namespace: subject.namespace,
roles: {}
};
if(subject.namespace) {
result[subject.kind].subjects[subjectKey].namespace = subject.namespace;
}
}
if(!_.includes(result[subject.kind].subjects[subjectKey].roles, roleKey)) {
result[subject.kind].subjects[subjectKey].roles[roleKey] = roles[roleKey];
if(roles[roleKey]) {
result[subject.kind].subjects[subjectKey].roles[roleKey] = roles[roleKey];
}
}
});
return result;
Expand Down
8 changes: 3 additions & 5 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1479,16 +1479,15 @@ type: "Source",
sourceStrategy: {
from: {
kind: "ImageStreamTag",
name: e.imageName + ":" + e.imageTag,
namespace: e.namespace
name: e.imageName + ":" + e.imageTag
},
env: n
}
},
triggers: a
}
};
return _.get(e, "buildConfig.secrets.gitSecret[0].name") && (l.spec.source.sourceSecret = _.head(e.buildConfig.secrets.gitSecret)), e.buildConfig.contextDir && (l.spec.source.contextDir = e.buildConfig.contextDir), l;
return e.namespace && (l.spec.strategy.namespace = e.namespace), _.get(e, "buildConfig.secrets.gitSecret[0].name") && (l.spec.source.sourceSecret = _.head(e.buildConfig.secrets.gitSecret)), e.buildConfig.contextDir && (l.spec.source.contextDir = e.buildConfig.contextDir), l;
}, o._generateImageStream = function(e) {
return {
apiVersion: "v1",
Expand Down Expand Up @@ -2324,9 +2323,8 @@ return _.each(a.subjects, function(a) {
var o = n(a.namespace, a.name);
e[a.kind].subjects[o] || (e[a.kind].subjects[o] = {
name: a.name,
namespace: a.namespace,
roles: {}
}), _.includes(e[a.kind].subjects[o].roles, r) || (e[a.kind].subjects[o].roles[r] = t[r]);
}, a.namespace && (e[a.kind].subjects[o].namespace = a.namespace)), _.includes(e[a.kind].subjects[o].roles, r) || t[r] && (e[a.kind].subjects[o].roles[r] = t[r]);
}), e;
}, {
User: {
Expand Down
31 changes: 23 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
"clean-css": "3.4.12",
"connect-modrewrite": "0.7.9",
"geckodriver": "1.3.0",

"grunt": "0.4.5",

"grunt-angular-templates": "1.0.3",
"grunt-cli": "1.1.0",
"grunt-concurrent": "2.3.1",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-concat": "1.0.0",

"grunt-contrib-connect": "1.0.2",

"grunt-contrib-copy": "1.0.0",
"grunt-contrib-cssmin": "1.0.1",
"grunt-contrib-htmlmin": "1.3.0",
Expand All @@ -29,7 +33,9 @@
"grunt-contrib-watch": "1.0.0",
"grunt-htmlhint": "0.4.1",
"grunt-istanbul-coverage": "0.0.5",
"grunt-karma": "0.9.0",

"grunt-karma": "^2.0.0",

"grunt-newer": "0.7.0",
"grunt-ng-annotate": "0.3.2",
"grunt-postcss": "^0.8.0",
Expand All @@ -40,21 +46,30 @@
"grunt-wiredep": "3.0.0",
"html-minifier": "1.1.1",
"imagemin": "1.0.5",

"jasmine-core": "^2.8.0",
"jasmine-beforeall": "0.1.1",
"jasmine-spec-reporter": "1.1.2",

"jshint-stylish": "0.2.0",
"karma": "0.12.23",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "0.2.6",
"karma-firefox-launcher": "^1.0.0",
"karma-jasmine": "0.1.5",
"karma-ng-html2js-preprocessor": "1.0.0",

"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-ng-html2js-preprocessor": "^1.0.0",
"karma-jasmine-diff-reporter": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-nightmare": "^0.4.10",

"less": "2.6.1",
"load-grunt-tasks": "0.4.0",
"lodash": "3.10.1",

"protractor": "1.7.0",
"protractor-screenshot-reporter": "0.0.5",
"protractor-screenshot-reporter": "^0.0.5",

"serve-static": "1.10.2",
"time-grunt": "0.3.2"
},
Expand Down
50 changes: 32 additions & 18 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ module.exports = function(config) {
'use strict';

config.set({
// maximum boot-up time allowed for a browser to start and connect to Karma
// a browser gets 3x changes within this timeout range to connect to Karma
// there are other timeouts as well, consult the config file
// docs: https://karma-runner.github.io/1.0/config/configuration-file.html
captureTimeout: 3000,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// why set to true when we have grunt watch?
autoWatch: false,

// base path, that will be used to resolve files and exclude
basePath: '../',
Expand Down Expand Up @@ -107,7 +113,7 @@ module.exports = function(config) {
exclude: [],

// web server port
port: 8443,
// port: 8443,

// Start these browsers, currently available:
// - Chrome
Expand All @@ -121,25 +127,23 @@ module.exports = function(config) {
'karma-firefox-launcher',
'karma-chrome-launcher',
'karma-phantomjs-launcher',
'karma-nightmare',
'karma-ng-html2js-preprocessor',
'karma-jasmine',
'karma-coverage'
'karma-coverage',
'karma-jasmine-diff-reporter'
],

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,
singleRun: false,

colors: true,
colors: true,

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_DEBUG,
logLevel: config.LOG_ERROR,

// Help karma find the views on disk in the app subdirectory
proxies: {
'/views/': '/app/views/'
},
// URL root prevent conflicts with the site root
// urlRoot: '_karma_'

Expand All @@ -153,18 +157,28 @@ module.exports = function(config) {

ngHtml2JsPreprocessor: {
moduleName: 'openshiftConsoleTemplates',
cacheIdFromPath: function(filepath) {
return filepath.replace('app/', '');
},
stripPrefix: '/app',
},

reporters: ['progress', 'coverage'],
// order of reporters matters, input/output may break
reporters: ['jasmine-diff', 'progress', 'coverage'],

coverageReporter: {
reporters:[
{type: 'json', dir:'test/coverage/'},
{type: 'text-summary', dir:'test/coverage/'}
]
type: 'text',
// outputs the results of coverage reporter to this dir
dir: 'test-results/coverage/'
},

jasmineDiffReporter: {
// jasmine kinda has its own diff now, but its sub-par.
legacy: true
},

nightmareOptions: {
width: 1048,
height: 600,
show: false,
}

});
};
Loading

0 comments on commit 91fe691

Please sign in to comment.