From 265e10a036b545d9d4e15bebef17e38e4b013af3 Mon Sep 17 00:00:00 2001 From: thuva4 Date: Tue, 14 Nov 2017 15:38:56 +0530 Subject: Create functionality and e2e tests for project Implemented the create function for the projects. Wrote the e2e tests for the create function. Change-Id: Iceac650573ca31b6246350c4d60033b42e0ffb0f Signed-off-by: thuva4 --- testapi/3rd_party/static/testapi-ui/Gruntfile.js | 38 ++-- testapi/3rd_party/static/testapi-ui/app.js | 19 ++ testapi/3rd_party/static/testapi-ui/index.html | 1 + .../static/testapi-ui/shared/header/header.html | 1 + testapi/opnfv_testapi/common/check.py | 8 +- testapi/opnfv_testapi/common/message.py | 4 + testapi/opnfv_testapi/handlers/base_handlers.py | 2 +- .../tests/UI/e2e/podsControllerSpec.js | 23 ++- .../tests/UI/e2e/projectControllerSpec.js | 224 +++++++++++++++++++++ .../opnfv_testapi/tests/unit/handlers/test_base.py | 8 + .../tests/unit/handlers/test_project.py | 30 ++- .../tests/unit/handlers/test_result.py | 6 +- .../tests/unit/handlers/test_testcase.py | 11 +- testapi/opnfv_testapi/ui/projects/projects.html | 38 ++++ .../ui/projects/projectsController.js | 74 +++++++ 15 files changed, 444 insertions(+), 43 deletions(-) create mode 100644 testapi/opnfv_testapi/tests/UI/e2e/projectControllerSpec.js create mode 100644 testapi/opnfv_testapi/ui/projects/projects.html create mode 100644 testapi/opnfv_testapi/ui/projects/projectsController.js diff --git a/testapi/3rd_party/static/testapi-ui/Gruntfile.js b/testapi/3rd_party/static/testapi-ui/Gruntfile.js index 8ff2802..f82269e 100644 --- a/testapi/3rd_party/static/testapi-ui/Gruntfile.js +++ b/testapi/3rd_party/static/testapi-ui/Gruntfile.js @@ -30,6 +30,12 @@ module.exports = function (grunt) { dest: 'testapi-ui/assets', }, components: { + expand: true, + cwd: '../../../opnfv_testapi/ui', + src: '**', + dest: 'components', + }, + copyComponents: { expand: true, cwd: 'components', src: '**', @@ -82,6 +88,12 @@ module.exports = function (grunt) { async: true } }, + deleteFiles: { + command: 'rm -r testapi-ui && rm -r components', + options: { + async: false + } + }, options: { stdout: false, stderr: false @@ -90,8 +102,8 @@ module.exports = function (grunt) { instrument: { files: ['components/**/*.js'], options: { - lazy: false, - basePath: "./testapi-ui/" + lazy: false, + basePath: "./testapi-ui/" } }, karma: { @@ -105,7 +117,8 @@ module.exports = function (grunt) { noColor: false, coverageDir: '../../../opnfv_testapi/tests/UI/coverage', args: { - specs: ['../../../opnfv_testapi/tests/UI/e2e/podsControllerSpec.js'] + specs: ['../../../opnfv_testapi/tests/UI/e2e/podsControllerSpec.js', + '../../../opnfv_testapi/tests/UI/e2e/projectControllerSpec.js'] } }, local: { @@ -119,18 +132,7 @@ module.exports = function (grunt) { options: { print: 'detail' } - }, - protractor: { - e2e: { - options: { - args: { - specs: ['../../../opnfv_testapi/tests/UI/e2e/podsControllerSpec.js'] - }, - configFile: '../../../opnfv_testapi/tests/UI/protractor-conf.js', - keepAlive: true - } - } - } + } }); grunt.registerTask('test', [ 'karma:unit' @@ -138,6 +140,7 @@ module.exports = function (grunt) { grunt.registerTask('e2e', [ 'copy:assets', 'copy:components', + 'copy:copyComponents', 'copy:shared', 'copy:filesPng', 'copy:filesIco', @@ -149,7 +152,8 @@ module.exports = function (grunt) { 'shell:startSelenium', 'wait:default', 'protractor_coverage', - 'makeReport' - // 'protractor' + 'makeReport', + 'shell:deleteFiles' + ]); } diff --git a/testapi/3rd_party/static/testapi-ui/app.js b/testapi/3rd_party/static/testapi-ui/app.js index 5f5b861..0b35162 100644 --- a/testapi/3rd_party/static/testapi-ui/app.js +++ b/testapi/3rd_party/static/testapi-ui/app.js @@ -64,6 +64,11 @@ templateUrl: 'testapi-ui/components/pods/pods.html', controller: 'PodsController as ctrl' }). + state('projects', { + url: '/projects', + templateUrl: 'testapi-ui/components/projects/projects.html', + controller: 'ProjectsController as ctrl' + }). state('communityResults', { url: '/community_results', templateUrl: 'testapi-ui/components/results/results.html', @@ -168,6 +173,7 @@ $rootScope.auth.doSignIn = doSignIn; $rootScope.auth.doSignOut = doSignOut; $rootScope.auth.doSignCheck = doSignCheck; + $rootScope.auth.doSubmitterCheck = doSubmitterCheck; var sign_in_url = testapiApiUrl + '/auth/signin'; var sign_out_url = testapiApiUrl + '/auth/signout'; @@ -182,6 +188,7 @@ function doSignOut() { $rootScope.auth.currentUser = null; $rootScope.auth.isAuthenticated = false; + $rootScope.auth.projectNames = []; $window.location.href = sign_out_url; } @@ -194,13 +201,25 @@ success(function (data) { $rootScope.auth.currentUser = data; $rootScope.auth.isAuthenticated = true; + $rootScope.auth.projectNames = $rootScope.auth.doSubmitterCheck(data.groups); }). error(function () { $rootScope.auth.currentUser = null; $rootScope.auth.isAuthenticated = false; + $rootScope.auth.projectNames = []; }); } + function doSubmitterCheck(groups){ + var projectNames = [] + for(var index=0;index=0){ + projectNames.push(groups[index].split('-')[2]) + } + } + return projectNames; + } + $rootScope.auth.doSignCheck(); } diff --git a/testapi/3rd_party/static/testapi-ui/index.html b/testapi/3rd_party/static/testapi-ui/index.html index 2d7399f..45162dc 100644 --- a/testapi/3rd_party/static/testapi-ui/index.html +++ b/testapi/3rd_party/static/testapi-ui/index.html @@ -46,6 +46,7 @@ + diff --git a/testapi/3rd_party/static/testapi-ui/shared/header/header.html b/testapi/3rd_party/static/testapi-ui/shared/header/header.html index f5b2414..4b3f8dd 100644 --- a/testapi/3rd_party/static/testapi-ui/shared/header/header.html +++ b/testapi/3rd_party/static/testapi-ui/shared/header/header.html @@ -19,6 +19,7 @@ TestAPI
  • About
  • Pods
  • Community Results
  • +
  • Projects