Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Relate-Bug: #1476413 1. file name changes for test, test suite…
…s, mock data - .test.js, .test.suite.js, .mock.data.js 2. adding infra for running library api tests. 3. new grunt target grunt api for starting api task. 4. updated test runner functions for common and lib tests. 5. TODO current GridView lib tests are not functoinal. needs update in *.lib.test.suite.js"
- Loading branch information
Showing
12 changed files
with
760 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
module.exports = function (grunt) { | ||
grunt.loadNpmTasks("grunt-contrib-jshint"); | ||
grunt.loadNpmTasks("grunt-contrib-qunit"); | ||
grunt.loadNpmTasks('grunt-qunit-junit'); | ||
grunt.loadNpmTasks('grunt-karma'); | ||
//this option is to avoid interruption of test case execution on failure of one in sequence | ||
//grunt.option('force',true); | ||
grunt.option('stack', true); | ||
|
||
var commonFiles = [ | ||
{pattern: 'contrail-web-core/webroot/assets/**/!(tests)/*.js', included: false}, | ||
{pattern: 'contrail-web-core/webroot/assets/**/*.css', included: false}, | ||
{pattern: 'contrail-web-core/webroot/css/**/*.css', included: false}, | ||
{pattern: 'contrail-web-core/webroot/test/ui/**/*.css', included: false}, | ||
|
||
{pattern: 'contrail-web-core/webroot/font/**/*.woff', included: false}, | ||
{pattern: 'contrail-web-core/webroot/assets/**/*.woff', included: false}, | ||
{pattern: 'contrail-web-core/webroot/assets/**/*.ttf', included: false}, | ||
|
||
{pattern: 'contrail-web-core/webroot/img/**/*.png', included: false}, | ||
{pattern: 'contrail-web-core/webroot/css/**/*.png', included: false}, | ||
{pattern: 'contrail-web-core/webroot/assets/select2/styles/**/*.png', included: false}, | ||
{pattern: 'contrail-web-core/webroot/css/**/*.gif', included: false}, | ||
|
||
{pattern: 'contrail-web-core/webroot/test/ui/js/co.test.app.js'}, | ||
{pattern: 'contrail-web-core/webroot/test/ui/js/**/co.test.*.js', included: false}, | ||
{pattern: 'contrail-web-core/webroot/test/ui/js/**/*.lib.test.suite.js', included: false}, | ||
{pattern: 'contrail-web-core/webroot/test/ui/js/**/*.lib.test.js', included: false}, | ||
//{pattern: 'contrail-web-core/webroot/test/ui/js/**/*.lib.test.js', included: false}, | ||
//{pattern: 'contrail-web-core/webroot/test/ui/js/**/*.lib.test.suite.js', included: false}, | ||
//{pattern: 'contrail-web-core/webroot/test/ui/js/**/{!(*.lib.test.js), !(*.test.suite.js)}', included: false}, | ||
//{pattern: 'contrail-web-core/webroot/test/ui/js/**/*.js', included: false}, | ||
|
||
{pattern: 'contrail-web-core/webroot/js/**/*.js', included: false}, | ||
{pattern: 'contrail-web-core/webroot/templates/*.tmpl', included: false} | ||
]; | ||
|
||
var karmaConfig = { | ||
options: { | ||
configFile: 'karma.config.js', | ||
}, | ||
grid: { | ||
options: { | ||
files: [ | ||
//{pattern: 'contrail-web-core/webroot/assets/slickgrid/js/slick.*.js'}, | ||
{pattern: 'contrail-web-core/webroot/test/ui/js/grid/GridView.lib.test.js', included: false} | ||
], | ||
preprocessors: { | ||
'contrail-web-core/webroot/assets/slickgrid/js/slick.*.js': ['coverage'] | ||
} | ||
} | ||
} | ||
}; | ||
|
||
for (var feature in karmaConfig) { | ||
if (feature != 'options') { | ||
karmaConfig[feature]['options']['files'] = commonFiles.concat(karmaConfig[feature]['options']['files']); | ||
} | ||
} | ||
|
||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON(__dirname + "/../../../../contrail-web-core/package.json"), | ||
karma: karmaConfig, | ||
jshint: { | ||
options: { | ||
jshintrc: ".jshintrc" | ||
}, | ||
files: ["Gruntfile.js"] | ||
}, | ||
api: { | ||
grid: 'grid' | ||
} | ||
|
||
}); | ||
|
||
grunt.registerMultiTask('api', 'Core libs API Test Cases', function () { | ||
if (this.target == 'grid') { | ||
grunt.task.run('karma:grid'); | ||
|
||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
|
||
var coreBaseDir = "/base/contrail-web-core/webroot", | ||
featurePkg = "testLibApi"; | ||
|
||
require([ | ||
coreBaseDir + '/js/core-app-utils.js', | ||
coreBaseDir + '/test/ui/js/co.test.app.utils.js' | ||
], function () { | ||
globalObj['env'] = "test"; | ||
|
||
|
||
requirejs.config({ | ||
baseUrl: coreBaseDir, | ||
paths: getCoreAppAndCoreTestAppPaths(coreBaseDir), | ||
map: coreAppMap, | ||
shim: getCoreAppAndCoreTestAppShims(), | ||
waitSeconds: 0 | ||
}); | ||
|
||
require(['co-test-init'], function () { | ||
setFeaturePkgAndInit(featurePkg); | ||
}); | ||
|
||
|
||
function getCoreAppAndCoreTestAppPaths(coreBaseDir) { | ||
var coreTestAppPathObj = {}; | ||
var coreAppPaths = getCoreAppPaths(coreBaseDir); | ||
var coreTestAppPaths = getCoreTestAppPaths(coreBaseDir); | ||
|
||
for (var key in coreAppPaths) { | ||
if (coreAppPaths.hasOwnProperty(key)) { | ||
var value = coreAppPaths[key]; | ||
coreTestAppPathObj[key] = value; | ||
} | ||
} | ||
|
||
for (var key in coreTestAppPaths) { | ||
if (coreTestAppPaths.hasOwnProperty(key)) { | ||
var value = coreTestAppPaths[key]; | ||
coreTestAppPathObj[key] = value; | ||
} | ||
} | ||
|
||
return coreTestAppPathObj; | ||
}; | ||
|
||
function getCoreAppAndCoreTestAppShims() { | ||
|
||
var coreTestAppShims = {}; | ||
|
||
for (var key in coreAppShim) { | ||
if (coreAppShim.hasOwnProperty(key)) { | ||
var value = coreAppShim[key]; | ||
coreTestAppShims[key] = value; | ||
} | ||
} | ||
|
||
for (var key in coreTestAppShim) { | ||
if (coreTestAppShim.hasOwnProperty(key)) { | ||
var value = coreTestAppShim[key]; | ||
coreTestAppShims[key] = value; | ||
} | ||
} | ||
|
||
return coreTestAppShims; | ||
}; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
define(['underscore'], function (_) { | ||
|
||
//Compares client UTC time with the server UTC time and display alert if mismatch exceeds the threshold | ||
var webServerInfoMockData = { | ||
"orchestrationModel": [ | ||
"openstack" | ||
], | ||
"serverUTCTime": 1436203008000, | ||
"hostName": "a7s14", | ||
"role": [ | ||
"superAdmin" | ||
], | ||
"featurePkg": { | ||
"webController": false, | ||
"webStorage": false, | ||
"serverManager": false | ||
}, | ||
"uiConfig": { | ||
"nodemanager": { | ||
"installed": true | ||
} | ||
}, | ||
"loggedInOrchestrationMode": "openstack" | ||
}; | ||
|
||
var disabledFeatureMockData = {"disabled":["config_alarms","mon_infra_mx"]}, | ||
webControllerMockData = {"webController":{"path":"/usr/src/contrail-web-controller","enable":true}}, | ||
ctWebServerInfoMockData = _.extend({}, webServerInfoMockData, {"featurePkg": { "webController": true }}), | ||
smWebServerInfoMockData = _.extend({}, webServerInfoMockData, {"featurePkg": { "serverManager": true }}), | ||
sWebServerInfoMockData = _.extend({}, webServerInfoMockData, {"featurePkg": { "webStorage": true }}); | ||
|
||
return { | ||
ctWebServerInfoMockData: ctWebServerInfoMockData, | ||
smWebServerInfoMockData: smWebServerInfoMockData, | ||
sWebServerInfoMockData: sWebServerInfoMockData, | ||
disabledFeatureMockData: disabledFeatureMockData, | ||
webControllerMockData: webControllerMockData | ||
} | ||
}); |
Oops, something went wrong.