Skip to content

Commit dd372aa

Browse files
Update unit test dependencies
1 parent 08814ee commit dd372aa

File tree

8 files changed

+237
-112
lines changed

8 files changed

+237
-112
lines changed

Gruntfile.js

+16-10
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,9 +603,8 @@ 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
@@ -613,36 +613,38 @@ module.exports = function (grunt) {
613613
browsers: grunt.option('browsers') ?
614614
grunt.option('browsers').split(',') :
615615
['Firefox']
616+
},
617+
unit: {
618+
singleRun: true,
616619
}
617620
},
618621

619622
protractor: {
620623
options: {
621-
configFile: "test/protractor.conf.js", // Default config file
624+
configFile: "test/protractor.conf.js",
622625
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.
626+
noColor: false,
624627
args: {
625-
// Arguments passed to the command
626628
suite: grunt.option('suite') || 'full',
627629
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/")
628630
}
629631
},
630632
default: {
631633
options: {
632-
configFile: "test/protractor.conf.js", // Target-specific config file
634+
configFile: "test/protractor.conf.js",
633635
args: {
634636
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
635637
browser: grunt.option('browser') || "firefox"
636-
} // Target-specific arguments
638+
}
637639
}
638640
},
639641
mac: {
640642
options: {
641-
configFile: "test/protractor-mac.conf.js", // Target-specific config file
643+
configFile: "test/protractor-mac.conf.js",
642644
args: {
643645
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
644646
browser: grunt.option('browser') || "firefox"
645-
} // Target-specific arguments
647+
}
646648
}
647649
}
648650
},
@@ -728,7 +730,7 @@ module.exports = function (grunt) {
728730
grunt.loadNpmTasks('grunt-angular-templates');
729731

730732
// karma must run prior to coverage since karma will generate the coverage results
731-
grunt.registerTask('test', [
733+
grunt.registerTask('test-unit', [
732734
'clean:server',
733735
'concurrent:test',
734736
'postcss',
@@ -737,6 +739,10 @@ module.exports = function (grunt) {
737739
// 'coverage' - add back if we want to enforce coverage percentages
738740
]);
739741

742+
// test as an alias to unit. after updating protractor,
743+
// will make test an alias for both unit & e2e
744+
grunt.registerTask('test', ['test-unit']);
745+
740746
grunt.registerTask('test-integration',
741747
grunt.option('baseUrl') ?
742748
[isMac ? 'protractor:mac' : 'protractor:default'] : // if a baseUrl is defined assume we dont want to run the local grunt server

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

+19-7
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,19 +46,25 @@
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",
5262
"karma-phantomjs-launcher": "^1.0.4",
63+
5364
"less": "2.6.1",
5465
"load-grunt-tasks": "0.4.0",
5566
"lodash": "3.10.1",
67+
5668
"protractor": "1.7.0",
5769
"protractor-screenshot-reporter": "0.0.5",
5870
"serve-static": "1.10.2",

test/karma.conf.js

+16-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
@@ -128,18 +134,12 @@ module.exports = function(config) {
128134

129135
// Continuous Integration mode
130136
// if true, it capture browsers, run tests and exit
131-
singleRun: false,
132-
133-
colors: true,
137+
singleRun: false,
134138

135139
// level of logging
136140
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
137-
logLevel: config.LOG_DEBUG,
141+
logLevel: config.LOG_ERROR,
138142

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

@@ -153,18 +153,16 @@ module.exports = function(config) {
153153

154154
ngHtml2JsPreprocessor: {
155155
moduleName: 'openshiftConsoleTemplates',
156-
cacheIdFromPath: function(filepath) {
157-
return filepath.replace('app/', '');
158-
},
156+
stripPrefix: '/app',
159157
},
160158

159+
// order of reporters matters, input/output may break
161160
reporters: ['progress', 'coverage'],
162161

163162
coverageReporter: {
164-
reporters:[
165-
{type: 'json', dir:'test/coverage/'},
166-
{type: 'text-summary', dir:'test/coverage/'}
167-
]
168-
}
163+
type: 'text',
164+
// outputs the results of coverage reporter to this dir
165+
dir: 'test-results/coverage/'
166+
},
169167
});
170168
};

0 commit comments

Comments
 (0)