Skip to content

Commit 91fe691

Browse files
Update unit test dependencies
1 parent 5bf079c commit 91fe691

File tree

9 files changed

+175
-128
lines changed

9 files changed

+175
-128
lines changed

.travis.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
language: node_js
22
node_js:
3-
- "4"
3+
- "6"
44
before_script:
5-
- make build
5+
- make build
6+
# FIXME:
7+
# This needs to be enabled again when we eliminate PhantomJS for Firefox
8+
# Even the unit tests require a browser
9+
# - export DISPLAY=:99.0
10+
# - sh -e /etc/init.d/xvfb start
11+
# - sleep 3 # give xvfb some time to start
612
script:
7-
- grunt test --browsers=PhantomJS
13+
- grunt test
814
- hack/verify-dist.sh

Gruntfile.js

+34-21
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = function (grunt) {
1515
var contextRoot = grunt.option('contextRoot') || "dev-console";
1616
var isMac = /^darwin/.test(process.platform) || grunt.option('mac');
1717

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

603604
// Test settings
604605
karma: {
605-
unit: {
606+
options: {
606607
configFile: 'test/karma.conf.js',
607-
singleRun: true,
608608
// default in karma.conf.js is Firefox, however, Chrome has much better
609609
// error messages when writing tests. Call like this:
610610
// grunt test
611611
// grunt test --browsers=Chrome
612612
// grunt test --browsers=Chrome,Firefox,Safari (be sure karma-<browser_name>-launcher is installed)
613613
browsers: grunt.option('browsers') ?
614614
grunt.option('browsers').split(',') :
615-
['Firefox']
615+
// if running locally on mac, we can test both FF & Chrome,
616+
// in Travis, just FF
617+
// ['Nightmare'] is a good alt for a current headless
618+
// FIXME: fix this, PhantomJS is deprecated
619+
isMac ?
620+
['Firefox', 'Chrome'] :
621+
['PhantomJS']
622+
},
623+
unit: {
624+
singleRun: true,
616625
}
617626
},
618627

619628
protractor: {
620629
options: {
621-
configFile: "test/protractor.conf.js", // Default config file
630+
configFile: "test/protractor.conf.js",
622631
keepAlive: false, // If false, the grunt process stops when the test fails.
623-
noColor: false, // If true, protractor will not use colors in its output.
632+
noColor: false,
624633
args: {
625-
// Arguments passed to the command
626634
suite: grunt.option('suite') || 'full',
627635
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/")
628636
}
629637
},
630638
default: {
631639
options: {
632-
configFile: "test/protractor.conf.js", // Target-specific config file
640+
configFile: "test/protractor.conf.js",
633641
args: {
634642
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
635643
browser: grunt.option('browser') || "firefox"
636-
} // Target-specific arguments
644+
}
637645
}
638646
},
639647
mac: {
640648
options: {
641-
configFile: "test/protractor-mac.conf.js", // Target-specific config file
649+
configFile: "test/protractor-mac.conf.js",
642650
args: {
643651
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
644652
browser: grunt.option('browser') || "firefox"
645-
} // Target-specific arguments
653+
}
646654
}
647655
}
648656
},
@@ -728,7 +736,7 @@ module.exports = function (grunt) {
728736
grunt.loadNpmTasks('grunt-angular-templates');
729737

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

748+
// test as an alias to unit. after updating protractor,
749+
// will make test an alias for both unit & e2e
750+
grunt.registerTask('test', ['test-unit']);
751+
740752
grunt.registerTask('test-integration',
753+
// if a baseUrl is defined assume we dont want to run the local grunt server
741754
grunt.option('baseUrl') ?
742-
[isMac ? 'protractor:mac' : 'protractor:default'] : // if a baseUrl is defined assume we dont want to run the local grunt server
743-
[
744-
'clean:server',
745-
'development-build',
746-
'postcss',
747-
'connect:test',
748-
'add-redirect-uri',
749-
(isMac ? 'protractor:mac' : 'protractor:default'),
750-
'clean:server'
751-
]
755+
[isMac ? 'protractor:mac' : 'protractor:default'] :
756+
[
757+
'clean:server',
758+
'development-build',
759+
'postcss',
760+
'connect:test',
761+
'add-redirect-uri',
762+
(isMac ? 'protractor:mac' : 'protractor:default'),
763+
'clean:server'
764+
]
752765
);
753766

754767
grunt.registerTask('build', [

app/scripts/services/applicationGenerator.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,17 @@ angular.module("openshiftConsole")
351351
sourceStrategy: {
352352
from: {
353353
kind: "ImageStreamTag",
354-
name: input.imageName + ":" + input.imageTag,
355-
namespace: input.namespace
354+
name: input.imageName + ":" + input.imageTag
356355
},
357356
env: env
358357
}
359358
},
360359
triggers: triggers
361360
}
362361
};
362+
if(input.namespace) {
363+
bc.spec.strategy.namespace = input.namespace;
364+
}
363365
if (_.get(input, 'buildConfig.secrets.gitSecret[0].name')) {
364366
bc.spec.source.sourceSecret = _.head(input.buildConfig.secrets.gitSecret);
365367
}

app/scripts/services/membership/membership.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,16 @@ angular
9696
if(!result[subject.kind].subjects[subjectKey]) {
9797
result[subject.kind].subjects[subjectKey] = {
9898
name: subject.name,
99-
namespace: subject.namespace,
10099
roles: {}
101100
};
101+
if(subject.namespace) {
102+
result[subject.kind].subjects[subjectKey].namespace = subject.namespace;
103+
}
102104
}
103105
if(!_.includes(result[subject.kind].subjects[subjectKey].roles, roleKey)) {
104-
result[subject.kind].subjects[subjectKey].roles[roleKey] = roles[roleKey];
106+
if(roles[roleKey]) {
107+
result[subject.kind].subjects[subjectKey].roles[roleKey] = roles[roleKey];
108+
}
105109
}
106110
});
107111
return result;

dist/scripts/scripts.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1479,16 +1479,15 @@ type: "Source",
14791479
sourceStrategy: {
14801480
from: {
14811481
kind: "ImageStreamTag",
1482-
name: e.imageName + ":" + e.imageTag,
1483-
namespace: e.namespace
1482+
name: e.imageName + ":" + e.imageTag
14841483
},
14851484
env: n
14861485
}
14871486
},
14881487
triggers: a
14891488
}
14901489
};
1491-
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;
1490+
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;
14921491
}, o._generateImageStream = function(e) {
14931492
return {
14941493
apiVersion: "v1",
@@ -2324,9 +2323,8 @@ return _.each(a.subjects, function(a) {
23242323
var o = n(a.namespace, a.name);
23252324
e[a.kind].subjects[o] || (e[a.kind].subjects[o] = {
23262325
name: a.name,
2327-
namespace: a.namespace,
23282326
roles: {}
2329-
}), _.includes(e[a.kind].subjects[o].roles, r) || (e[a.kind].subjects[o].roles[r] = t[r]);
2327+
}, 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]);
23302328
}), e;
23312329
}, {
23322330
User: {

package.json

+23-8
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
"clean-css": "3.4.12",
1313
"connect-modrewrite": "0.7.9",
1414
"geckodriver": "1.3.0",
15+
1516
"grunt": "0.4.5",
17+
1618
"grunt-angular-templates": "1.0.3",
1719
"grunt-cli": "1.1.0",
1820
"grunt-concurrent": "2.3.1",
1921
"grunt-contrib-clean": "1.0.0",
2022
"grunt-contrib-concat": "1.0.0",
23+
2124
"grunt-contrib-connect": "1.0.2",
25+
2226
"grunt-contrib-copy": "1.0.0",
2327
"grunt-contrib-cssmin": "1.0.1",
2428
"grunt-contrib-htmlmin": "1.3.0",
@@ -29,7 +33,9 @@
2933
"grunt-contrib-watch": "1.0.0",
3034
"grunt-htmlhint": "0.4.1",
3135
"grunt-istanbul-coverage": "0.0.5",
32-
"grunt-karma": "0.9.0",
36+
37+
"grunt-karma": "^2.0.0",
38+
3339
"grunt-newer": "0.7.0",
3440
"grunt-ng-annotate": "0.3.2",
3541
"grunt-postcss": "^0.8.0",
@@ -40,21 +46,30 @@
4046
"grunt-wiredep": "3.0.0",
4147
"html-minifier": "1.1.1",
4248
"imagemin": "1.0.5",
49+
50+
"jasmine-core": "^2.8.0",
4351
"jasmine-beforeall": "0.1.1",
4452
"jasmine-spec-reporter": "1.1.2",
53+
4554
"jshint-stylish": "0.2.0",
46-
"karma": "0.12.23",
47-
"karma-chrome-launcher": "^2.0.0",
48-
"karma-coverage": "0.2.6",
49-
"karma-firefox-launcher": "^1.0.0",
50-
"karma-jasmine": "0.1.5",
51-
"karma-ng-html2js-preprocessor": "1.0.0",
55+
56+
"karma": "^1.7.1",
57+
"karma-chrome-launcher": "^2.2.0",
58+
"karma-coverage": "^1.1.1",
59+
"karma-firefox-launcher": "^1.0.1",
60+
"karma-jasmine": "^1.1.0",
61+
"karma-ng-html2js-preprocessor": "^1.0.0",
62+
"karma-jasmine-diff-reporter": "^1.1.0",
5263
"karma-phantomjs-launcher": "^1.0.4",
64+
"karma-nightmare": "^0.4.10",
65+
5366
"less": "2.6.1",
5467
"load-grunt-tasks": "0.4.0",
5568
"lodash": "3.10.1",
69+
5670
"protractor": "1.7.0",
57-
"protractor-screenshot-reporter": "0.0.5",
71+
"protractor-screenshot-reporter": "^0.0.5",
72+
5873
"serve-static": "1.10.2",
5974
"time-grunt": "0.3.2"
6075
},

test/karma.conf.js

+32-18
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ module.exports = function(config) {
77
'use strict';
88

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

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

109115
// web server port
110-
port: 8443,
116+
// port: 8443,
111117

112118
// Start these browsers, currently available:
113119
// - Chrome
@@ -121,25 +127,23 @@ module.exports = function(config) {
121127
'karma-firefox-launcher',
122128
'karma-chrome-launcher',
123129
'karma-phantomjs-launcher',
130+
'karma-nightmare',
124131
'karma-ng-html2js-preprocessor',
125132
'karma-jasmine',
126-
'karma-coverage'
133+
'karma-coverage',
134+
'karma-jasmine-diff-reporter'
127135
],
128136

129137
// Continuous Integration mode
130138
// if true, it capture browsers, run tests and exit
131-
singleRun: false,
139+
singleRun: false,
132140

133-
colors: true,
141+
colors: true,
134142

135143
// level of logging
136144
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
137-
logLevel: config.LOG_DEBUG,
145+
logLevel: config.LOG_ERROR,
138146

139-
// Help karma find the views on disk in the app subdirectory
140-
proxies: {
141-
'/views/': '/app/views/'
142-
},
143147
// URL root prevent conflicts with the site root
144148
// urlRoot: '_karma_'
145149

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

154158
ngHtml2JsPreprocessor: {
155159
moduleName: 'openshiftConsoleTemplates',
156-
cacheIdFromPath: function(filepath) {
157-
return filepath.replace('app/', '');
158-
},
160+
stripPrefix: '/app',
159161
},
160162

161-
reporters: ['progress', 'coverage'],
163+
// order of reporters matters, input/output may break
164+
reporters: ['jasmine-diff', 'progress', 'coverage'],
162165

163166
coverageReporter: {
164-
reporters:[
165-
{type: 'json', dir:'test/coverage/'},
166-
{type: 'text-summary', dir:'test/coverage/'}
167-
]
167+
type: 'text',
168+
// outputs the results of coverage reporter to this dir
169+
dir: 'test-results/coverage/'
170+
},
171+
172+
jasmineDiffReporter: {
173+
// jasmine kinda has its own diff now, but its sub-par.
174+
legacy: true
175+
},
176+
177+
nightmareOptions: {
178+
width: 1048,
179+
height: 600,
180+
show: false,
168181
}
182+
169183
});
170184
};

0 commit comments

Comments
 (0)