diff options
author | thuva4 <tharma.thuva@gmail.com> | 2017-11-16 14:51:29 +0530 |
---|---|---|
committer | thuva4 <tharma.thuva@gmail.com> | 2017-11-16 16:31:55 +0530 |
commit | 141e16fcbdcacc02ff30d861bf76082b51d4c287 (patch) | |
tree | af8f398f254d9e1ba27b392b9e36957a75af77b9 /testapi/opnfv_testapi/tests | |
parent | 265e10a036b545d9d4e15bebef17e38e4b013af3 (diff) |
Update and Delete functionalities for projects
Implemented the update and delete functions for the
projects and wrote the e2e tests for the both
functions.
Change-Id: I917dd9503f145b0dde61dd9970bd855f9711335e
Signed-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/opnfv_testapi/tests')
5 files changed, 569 insertions, 154 deletions
diff --git a/testapi/opnfv_testapi/tests/UI/e2e/podsControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/podsControllerSpec.js index 8cf7467..cb1d95d 100644 --- a/testapi/opnfv_testapi/tests/UI/e2e/podsControllerSpec.js +++ b/testapi/opnfv_testapi/tests/UI/e2e/podsControllerSpec.js @@ -20,6 +20,10 @@ describe('testing the Pods page for anonymous user', function () { }]); }); + afterEach(function(){ + mock.teardown(); + }); + it( 'should navigate to pods link ', function() { browser.get(baseURL); var podslink = element(by.linkText('Pods')).click(); @@ -128,6 +132,10 @@ describe('testing the Pods page for authorized user', function () { ]); }); + afterEach(function(){ + mock.teardown(); + }); + it('create button is visible for authorized user', function () { browser.get(baseURL + '/#/pods'); var buttonCreate = element(by.buttonText('Create')); diff --git a/testapi/opnfv_testapi/tests/UI/e2e/projectControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/projectControllerSpec.js index 921625d..475e037 100644 --- a/testapi/opnfv_testapi/tests/UI/e2e/projectControllerSpec.js +++ b/testapi/opnfv_testapi/tests/UI/e2e/projectControllerSpec.js @@ -1,224 +1,354 @@ 'use strict'; var mock = require('protractor-http-mock'); -var baseURL = "http://localhost:8000" +var baseURL = "http://localhost:8000/#/" describe('testing the Project Link for anonymous user', function () { - - it( 'should not show the Project Link for anonymous user', function() { - mock.teardown(); - browser.get(baseURL); - var projectslink = element(by.linkText('Projects')); - expect(projectslink.isPresent()).toBe(true); + beforeEach(function(){ + mock([ + { + request: { + path: '/api/v1/projects/testproject', + method: 'GET' + }, + response: { + data: { + "owner": "thuva4", + "_id": "5a0c022f9a07c846d3c2cc94", + "creation_date": "2017-11-15 14:30:31.200259", + "description": "dsfsd", + "name": "testproject" + } + } + } + ]); }); - it( 'navigate anonymous user to project page', function() { - browser.get(baseURL+'#/projects'); + afterEach(function(){ + mock.teardown(); + }); + + it( 'navigate to the project page', function() { + browser.get(baseURL+"projects/testproject"); var EC = browser.ExpectedConditions; - browser.wait(EC.urlContains(baseURL+ '/#/projects'), 10000); + browser.wait(EC.urlContains(baseURL+ 'projects/testproject'), 10000); + }); + + it('show the project details for anonymous user ', function(){ + var table = $$('.projects-table.ng-scope tr'); + var projectDetailsLable = ['Name','Description','Creation date'] + var projectDetails = ['testproject', 'dsfsd','2017-11-15 14:30:31.200259'] + table.each(function(row,index) { + var rowElems = row.$$('td'); + expect(rowElems.count()).toBe(2); + expect(rowElems.get(0).getText()).toMatch(projectDetailsLable[index]); + expect(rowElems.get(1).getText()).toMatch(projectDetails[index]); + }); }); - it('create button is not visible for anonymous user ', function () { - browser.get(baseURL+'#/projects'); - var buttonCreate = element(by.buttonText('Create')); - expect(buttonCreate.isDisplayed()).toBeFalsy(); + it('should not show the update & delete button', function(){ + var buttonUpdate = element(by.buttonText('Update Project')); + var buttonDelete = element(by.buttonText('Delete Project')); + expect(buttonUpdate.isDisplayed()).toBeFalsy(); + expect(buttonDelete.isDisplayed()).toBeFalsy(); }); }); -describe('testing the Project Link for user who is not in submitter group', function () { - beforeEach(function(){ - mock([ - { - request: { - path: '/api/v1/profile', + +describe('testing the Project Link for authorized user(not a submitter)', function () { + beforeEach(function(){ + mock([ + { + request: { + path: '/api/v1/projects/testproject', method: 'GET' - }, - response: { - data: { - "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", - "user": "testUser", "groups": ["opnfv-testapi-users"], - "email": "testuser@test.com" - } + }, + response: { + data: { + "owner": "thuva4", + "_id": "5a0c022f9a07c846d3c2cc94", + "creation_date": "2017-11-15 14:30:31.200259", + "description": "dsfsd", + "name": "testproject" } } - ]); - }); - - it( 'should show the Project Link for user', function() { - browser.get(baseURL); - var projectslink = element(by.linkText('Projects')); - expect(projectslink.isPresent()).toBe(true); - }); - - it( 'should navigate the user to the Project page', function() { - browser.get(baseURL); - var projectslink = element(by.linkText('Projects')).click(); - var EC = browser.ExpectedConditions; - browser.wait(EC.urlContains(baseURL+ '/#/projects'), 10000); - }); - - it('create button is not visible for user', function () { - browser.get(baseURL+'#/projects'); - var buttonCreate = element(by.buttonText('Create')); - expect(buttonCreate.isDisplayed()).toBeFalsy(); - }); -}) - -describe('testing the Project Link for user who is in submitter group', function () { + }, + { + request: { + path: '/api/v1/profile', + method: 'GET' + }, + response: { + data: { + "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", + "user": "testUser", "groups": ["opnfv-testapi-users"], + "email": "testuser@test.com" + } + } + } + ]); + }); + + afterEach(function(){ + mock.teardown(); + }); + + it( 'navigate to the project page', function() { + browser.get(baseURL+"projects/testproject"); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains(baseURL+ 'projects/testproject'), 10000); + }); + + it('show the project details for user ', function(){ + var table = $$('.projects-table.ng-scope tr'); + var projectDetailsLable = ['Name','Description','Creation date'] + var projectDetails = ['testproject', 'dsfsd','2017-11-15 14:30:31.200259'] + table.each(function(row,index) { + var rowElems = row.$$('td'); + expect(rowElems.count()).toBe(2); + expect(rowElems.get(0).getText()).toMatch(projectDetailsLable[index]); + expect(rowElems.get(1).getText()).toMatch(projectDetails[index]); + }); + }); + + it('should not show the update & delete button', function(){ + var buttonUpdate = element(by.buttonText('Update Project')); + var buttonDelete = element(by.buttonText('Delete Project')); + expect(buttonUpdate.isDisplayed()).toBeFalsy(); + expect(buttonDelete.isDisplayed()).toBeFalsy(); + }); + +}); + +describe('testing the Project Link for authorized user(a submitter)', function () { beforeEach(function(){ mock([ { request: { - path: '/api/v1/profile', + path: '/api/v1/projects/testproject', method: 'GET' }, response: { data: { - "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", - "user": "testUser", "groups": ["opnfv-testapi-users", - "opnfv-gerrit-testProject1-submitters", - "opnfv-gerrit-testProject2-submitters" ], - "email": "testuser@test.com" + "owner": "thuva4", + "_id": "5a0c022f9a07c846d3c2cc94", + "creation_date": "2017-11-15 14:30:31.200259", + "description": "dsfsd", + "name": "testproject" } } }, { request: { - path: '/api/v1/projects', - method: 'POST' + path: '/api/v1/projects/testproject1', + method: 'GET' }, response: { data: { - href: baseURL+"/api/v1/projects/testProject1" + "owner": "thuva4", + "_id": "5a0c022f9a07c846d3c2cc94", + "creation_date": "2017-11-15 14:30:31.200259", + "description": "dsfsd", + "name": "testproject1" } } }, { request: { path: '/api/v1/projects', - method: 'POST', + method: 'GET' + }, + response: { + data: { + "projects": [ + { + "owner": "thuva4", + "_id": "5a0c022f9a07c846d3c2cc94", + "creation_date": "2017-11-15 14:30:31.200259", + "description": "dsfsd", + "name": "testproject" + } + ] + } + } + }, + { + request: { + path: '/api/v1/projects/testproject', + method: 'DELETE' + }, + response: { + status : 200 + } + }, + { + request: { + path: '/api/v1/projects/testproject1', + method: 'DELETE' + }, + response: { + status : 403 + } + }, + { + request: { + path: '/api/v1/projects/testproject', + method: 'PUT', data: { name: 'testProject2', description : 'demoDescription', } }, response: { - status : 403 + status : 200, + data : { + "owner": "thuva4", + "_id": "5a0c022f9a07c846d3c2cc94", + "creation_date": "2017-11-15 14:30:31.200259", + "description": "dsfsd", + "name": "testproject2" + } } }, { request: { - path: '/api/v1/projects', - method: 'POST', + path: '/api/v1/projects/testproject', + method: 'PUT', data: { - name: 'testProject3', + name: 'testProject1', description : 'demoDescription', } }, response: { - status : 403, - data : 'You do not have permission to perform this action' + status : 403 } - } + }, + { + request: { + path: '/api/v1/profile', + method: 'GET' + }, + response: { + data: { + "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", + "user": "testUser", "groups": ["opnfv-testapi-users", + "opnfv-gerrit-testProject-submitters", + "opnfv-gerrit-testProject2-submitters" ], + "email": "testuser@test.com" + } + } + }, ]); }); - it( 'should show the Project Link for user', function() { - browser.get(baseURL); - var projectslink = element(by.linkText('Projects')); - expect(projectslink.isPresent()).toBe(true); - }); + afterEach(function(){ + mock.teardown(); + }); - it( 'should navigate the user to the Project page', function() { - browser.get(baseURL); - var projectslink = element(by.linkText('Projects')).click(); + it( 'navigate to the project page', function() { + browser.get(baseURL+"projects/testproject"); var EC = browser.ExpectedConditions; - browser.wait(EC.urlContains(baseURL+ '/#/projects'), 10000); + browser.wait(EC.urlContains(baseURL+ 'projects/testproject'), 10000); }); - it('create button is visible for user', function () { - browser.get(baseURL+'#/projects'); - var buttonCreate = element(by.buttonText('Create')); - expect(buttonCreate.isDisplayed()).toBe(true); + it('show the project details for user ', function(){ + var table = $$('.projects-table.ng-scope tr'); + var projectDetailsLable = ['Name','Description','Creation date'] + var projectDetails = ['testproject', 'dsfsd','2017-11-15 14:30:31.200259'] + table.each(function(row,index) { + var rowElems = row.$$('td'); + expect(rowElems.count()).toBe(2); + expect(rowElems.get(0).getText()).toMatch(projectDetailsLable[index]); + expect(rowElems.get(1).getText()).toMatch(projectDetails[index]); + }); }); - it('Show error when user click the create button with a empty name', function () { - browser.get(baseURL+ '/#/projects'); - var description = element(by.model('ctrl.description')); - description.sendKeys('DemoDescription'); - var buttonCreate = element(by.buttonText('Create')); - buttonCreate.click(); - expect(element(by.cssContainingText(".alert","Name is missing.")) - .isDisplayed()).toBe(true); - }); + it('should show the update & delete button', function(){ + var buttonUpdate = element(by.buttonText('Update Project')); + var buttonDelete = element(by.buttonText('Delete Project')); + expect(buttonUpdate.isDisplayed()).toBe(true); + expect(buttonDelete.isDisplayed()).toBe(true); + }); - it('Show error when user click the create button with an already existing name', function () { - browser.get(baseURL+ '/#/projects'); - var name = element(by.model('ctrl.name')); - var details = element(by.model('ctrl.description')); - name.sendKeys('testProject2'); - details.sendKeys('demoDescription'); - var buttonCreate = element(by.buttonText('Create')); - buttonCreate.click(); - expect(element(by.cssContainingText(".alert", - "Error creating the new Project from server:undefined")) - .isDisplayed()).toBe(true); + it('show the update modal when user clicks the update button', function(){ + browser.get(baseURL+"projects/testproject"); + var buttonDelete = element(by.buttonText('Update Project')).click(); + var EC = protractor.ExpectedConditions; + var elm = element(by.css(".modal-body")); + browser.wait(EC.textToBePresentInElement(elm, "Update"), 5000); + expect(elm.isDisplayed()).toBe(true); + var buttonCancel = element(by.buttonText('Cancel')).click(); + expect(elm.isPresent()).toEqual(false); }); - it('Show error when user try to create a project which he is not belonged to ', function () { - browser.get(baseURL+ '/#/projects'); - var name = element(by.model('ctrl.name')); - var details = element(by.model('ctrl.description')); - name.sendKeys('testProject3'); - details.sendKeys('demoDescription'); - var buttonCreate = element(by.buttonText('Create')); - buttonCreate.click(); + it('send a update request to server and show success when we click ok', function(){ + browser.get(baseURL+"projects/testproject"); + var buttonUpdate = element(by.buttonText('Update Project')).click(); + var EC = protractor.ExpectedConditions; + var elm = element(by.css(".modal-body")); + browser.wait(EC.textToBePresentInElement(elm, "Update"), 5000); + expect(elm.isDisplayed()).toBe(true); + var name = element(by.model('updateModal.name')); + var description = element(by.model('updateModal.description')); + name.click().clear().sendKeys('testProject2'); + description.click().clear().sendKeys('demoDescription'); + var buttonOk = element(by.buttonText('Ok')).click(); + expect(element(by.cssContainingText(".alert.alert-success", + "Update Success")) + .isDisplayed()).toBe(true); + }); + + it('show error when server send a error response when we click ok', function(){ + browser.get(baseURL+"projects/testproject"); + var buttonUpdate = element(by.buttonText('Update Project')).click(); + var EC = protractor.ExpectedConditions; + var elm = element(by.css(".modal-body")); + browser.wait(EC.textToBePresentInElement(elm, "Update"), 5000); + expect(elm.isDisplayed()).toBe(true); + var name = element(by.model('updateModal.name')); + var description = element(by.model('updateModal.description')); + name.click().clear().sendKeys('testProject1'); + description.click().clear().sendKeys('demoDescription'); + var buttonOk = element(by.buttonText('Ok')).click(); expect(element(by.cssContainingText(".alert", - 'Error creating the new Project from server:"You do not have permission to perform this action"')).isDisplayed()) - .toBe(true); + "Error updating the existing Project from server: undefined")) + .isDisplayed()).toBe(true); }); - it('Do not show error if input is acceptable', function () { - var name = element(by.model('ctrl.name')); - var details = element(by.model('ctrl.description')); - name.sendKeys('testProject1'); - details.sendKeys('demoDescription'); - var buttonCreate = element(by.buttonText('Create')); - buttonCreate.click().then(function(){ - expect(element(by.cssContainingText(".alert", - "Create Success")) - .isDisplayed()).toBe(true); - }); + it('show the confirm modal when user clicks the delete button', function(){ + var buttonDelete = element(by.buttonText('Delete Project')).click(); + var EC = protractor.ExpectedConditions; + var elm = element(by.css(".modal-body")); + browser.wait(EC.textToBePresentInElement(elm, "You are about to delete."), 5000); + expect(elm.isDisplayed()).toBe(true); + var buttonCancel = element(by.buttonText('Cancel')).click(); + expect(elm.isPresent()).toEqual(false); }); - it('If backend is not responding then show error when user click the create button',function(){ - mock.teardown(); - mock([ - { - request: { - path: '/api/v1/profile', - method: 'GET' - }, - response: { - data: { - "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", - "user": "testUser", "groups": ["opnfv-testapi-users", - "opnfv-gerrit-testProject1-submitters", - "opnfv-gerrit-testProject2-submitters" ], - "email": "testuser@test.com" - } - } - } - ]); - browser.get(baseURL+ '/#/projects'); - var name = element(by.model('ctrl.name')); - var details = element(by.model('ctrl.description')); - name.sendKeys('testProject1'); - details.sendKeys('demoDescription'); - var buttonCreate = element(by.buttonText('Create')); - buttonCreate.click().then(function(){ - expect(element(by.css(".alert.alert-danger.ng-binding.ng-scope")).isDisplayed()).toBe(true); - }); - }); -}) + it('send a delete request to server when we click ok', function(){ + var buttonDelete = element(by.buttonText('Delete Project')).click(); + var EC = protractor.ExpectedConditions; + var elm = element(by.css(".modal-body")); + browser.wait(EC.textToBePresentInElement(elm, "You are about to delete."), 5000); + expect(elm.isDisplayed()).toBe(true); + var buttonCancel = element(by.buttonText('Ok')).click(); + browser.wait(EC.urlContains(baseURL+ 'projects'), 10000); + }); + + it('show the error message when we click ok', function(){ + browser.get(baseURL+"projects/testproject1"); + var buttonDelete = element(by.buttonText('Delete Project')).click(); + var EC = protractor.ExpectedConditions; + var elm = element(by.css(".modal-body")); + browser.wait(EC.textToBePresentInElement(elm, "You are about to delete."), 5000); + expect(elm.isDisplayed()).toBe(true); + var buttonCancel = element(by.buttonText('Ok')).click(); + // browser.wait(EC.urlContains(baseURL+ 'projects'), 10000); + expect(element(by.cssContainingText(".alert", + "Error deleting project from server: undefined")) + .isDisplayed()).toBe(true); + // browser.pause(); + }); + +});
\ No newline at end of file diff --git a/testapi/opnfv_testapi/tests/UI/e2e/projectsControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/projectsControllerSpec.js new file mode 100644 index 0000000..64a5aeb --- /dev/null +++ b/testapi/opnfv_testapi/tests/UI/e2e/projectsControllerSpec.js @@ -0,0 +1,271 @@ +'use strict'; + +var mock = require('protractor-http-mock'); +var baseURL = "http://localhost:8000" + +describe('testing the Projects Link for anonymous user', function () { + beforeEach(function(){ + mock([ + { + request: { + path: '/api/v1/projects', + method: 'GET' + }, + response: { + data: { + "projects": [ + { + "owner": "thuva4", + "_id": "5a0c022f9a07c846d3c2cc94", + "creation_date": "2017-11-15 14:30:31.200259", + "description": "dsfsd", + "name": "testproject" + } + ] + } + } + } + ]); + }); + + afterEach(function(){ + mock.teardown(); + }); + + it( 'should show the Projects Link for anonymous user', function() { + mock.teardown(); + browser.get(baseURL); + var projectslink = element(by.linkText('Projects')); + expect(projectslink.isPresent()).toBe(true); + }); + + it( 'navigate anonymous user to project page', function() { + browser.get(baseURL+'#/projects'); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains(baseURL+ '/#/projects'), 10000); + }); + + it('create button is not visible for anonymous user ', function () { + browser.get(baseURL+'#/projects'); + var buttonCreate = element(by.buttonText('Create')); + expect(buttonCreate.isDisplayed()).toBeFalsy(); + }); + + it('Show projects list when user comes to the projects page', function () { + var firstBookName = element(by.repeater('(index, project) in ctrl.data.projects'). + row(0).column('{{project.name}}')); + expect(firstBookName).toBeDefined(); + }); + + it('redirect to project page when user clicks a project',function(){ + var projectlink = element(by.linkText('testproject')).click(); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains(baseURL+ '/#/projects/testproject'), 10000); + }); + +}); + +describe('testing the Project Link for user who is not in submitter group', function () { + beforeEach(function(){ + mock([ + { + request: { + path: '/api/v1/profile', + method: 'GET' + }, + response: { + data: { + "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", + "user": "testUser", "groups": ["opnfv-testapi-users"], + "email": "testuser@test.com" + } + } + } + ]); + }); + + afterEach(function(){ + mock.teardown(); + }); + + it( 'should show the Project Link for user', function() { + browser.get(baseURL); + var projectslink = element(by.linkText('Projects')); + expect(projectslink.isPresent()).toBe(true); + }); + + it( 'should navigate the user to the Project page', function() { + browser.get(baseURL); + var projectslink = element(by.linkText('Projects')).click(); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains(baseURL+ '/#/projects'), 10000); + }); + + it('create button is not visible for user', function () { + browser.get(baseURL+'#/projects'); + var buttonCreate = element(by.buttonText('Create')); + expect(buttonCreate.isDisplayed()).toBeFalsy(); + }); +}) + +describe('testing the Project Link for user who is in submitter group', function () { + beforeEach(function(){ + mock([ + { + request: { + path: '/api/v1/profile', + method: 'GET' + }, + response: { + data: { + "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", + "user": "testUser", "groups": ["opnfv-testapi-users", + "opnfv-gerrit-testProject1-submitters", + "opnfv-gerrit-testProject2-submitters" ], + "email": "testuser@test.com" + } + } + }, + { + request: { + path: '/api/v1/projects', + method: 'POST' + }, + response: { + data: { + href: baseURL+"/api/v1/projects/testProject1" + } + } + }, + { + request: { + path: '/api/v1/projects', + method: 'POST', + data: { + name: 'testProject2', + description : 'demoDescription', + } + }, + response: { + status : 403 + } + }, + { + request: { + path: '/api/v1/projects', + method: 'POST', + data: { + name: 'testProject3', + description : 'demoDescription', + } + }, + response: { + status : 403, + data : 'You do not have permission to perform this action' + } + } + ]); + }); + + afterEach(function(){ + mock.teardown(); + }); + + it( 'should show the Project Link for user', function() { + browser.get(baseURL); + var projectslink = element(by.linkText('Projects')); + expect(projectslink.isPresent()).toBe(true); + }); + + it( 'should navigate the user to the Project page', function() { + browser.get(baseURL); + var projectslink = element(by.linkText('Projects')).click(); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains(baseURL+ '/#/projects'), 10000); + }); + + it('create button is visible for user', function () { + browser.get(baseURL+'#/projects'); + var buttonCreate = element(by.buttonText('Create')); + expect(buttonCreate.isDisplayed()).toBe(true); + }); + + it('Show error when user click the create button with a empty name', function () { + browser.get(baseURL+ '/#/projects'); + var description = element(by.model('ctrl.description')); + description.sendKeys('DemoDescription'); + var buttonCreate = element(by.buttonText('Create')); + buttonCreate.click(); + expect(element(by.cssContainingText(".alert","Name is missing.")) + .isDisplayed()).toBe(true); + }); + + it('Show error when user click the create button with an already existing name', function () { + browser.get(baseURL+ '/#/projects'); + var name = element(by.model('ctrl.name')); + var details = element(by.model('ctrl.description')); + name.sendKeys('testProject2'); + details.sendKeys('demoDescription'); + var buttonCreate = element(by.buttonText('Create')); + buttonCreate.click(); + expect(element(by.cssContainingText(".alert", + "Error creating the new Project from server:undefined")) + .isDisplayed()).toBe(true); + }); + + it('Show error when user try to create a project which he is not belonged to ', function () { + browser.get(baseURL+ '/#/projects'); + var name = element(by.model('ctrl.name')); + var details = element(by.model('ctrl.description')); + name.sendKeys('testProject3'); + details.sendKeys('demoDescription'); + var buttonCreate = element(by.buttonText('Create')); + buttonCreate.click(); + expect(element(by.cssContainingText(".alert", + 'Error creating the new Project from server:"You do not have permission to perform this action"')).isDisplayed()) + .toBe(true); + }); + + it('Do not show error if input is acceptable', function () { + var name = element(by.model('ctrl.name')); + var details = element(by.model('ctrl.description')); + name.sendKeys('testProject1'); + details.sendKeys('demoDescription'); + var buttonCreate = element(by.buttonText('Create')); + buttonCreate.click().then(function(){ + expect(element(by.cssContainingText(".alert", + "Create Success")) + .isDisplayed()).toBe(true); + }); + }); + + it('If backend is not responding then show error when user click the create button',function(){ + mock.teardown(); + mock([ + { + request: { + path: '/api/v1/profile', + method: 'GET' + }, + response: { + data: { + "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", + "user": "testUser", "groups": ["opnfv-testapi-users", + "opnfv-gerrit-testProject1-submitters", + "opnfv-gerrit-testProject2-submitters" ], + "email": "testuser@test.com" + } + } + } + ]); + browser.get(baseURL+ '/#/projects'); + var name = element(by.model('ctrl.name')); + var details = element(by.model('ctrl.description')); + name.sendKeys('testProject1'); + details.sendKeys('demoDescription'); + var buttonCreate = element(by.buttonText('Create')); + buttonCreate.click().then(function(){ + expect(element(by.css(".alert.alert-danger")).isDisplayed()).toBe(true); + }); + }); +}) diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_base.py b/testapi/opnfv_testapi/tests/unit/handlers/test_base.py index eb147cc..4e5c0d9 100644 --- a/testapi/opnfv_testapi/tests/unit/handlers/test_base.py +++ b/testapi/opnfv_testapi/tests/unit/handlers/test_base.py @@ -61,7 +61,8 @@ class TestBase(testing.AsyncHTTPTestCase): 'opnfv-testapi-users', 'opnfv-gerrit-functest-submitters', 'opnfv-gerrit-qtip-submitters', - 'opnfv-gerrit-qtip-contributors'] + 'opnfv-gerrit-qtip-contributors', + 'opnfv-gerrit-apex-submitters'] }) def tearDown(self): diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_project.py b/testapi/opnfv_testapi/tests/unit/handlers/test_project.py index 2873ab0..9bc0e86 100644 --- a/testapi/opnfv_testapi/tests/unit/handlers/test_project.py +++ b/testapi/opnfv_testapi/tests/unit/handlers/test_project.py @@ -110,21 +110,25 @@ class TestProjectUpdate(TestProjectBase): def test_withoutBody(self): return None, 'noBody' + @executor.mock_valid_lfid() @executor.update(httplib.NOT_FOUND, message.not_found_base) def test_notFound(self): return self.req_e, 'notFound' + @executor.mock_valid_lfid() @executor.update(httplib.FORBIDDEN, message.exist_base) def test_newNameExist(self): return self.req_e, self.req_d.name + @executor.mock_valid_lfid() @executor.update(httplib.FORBIDDEN, message.no_update()) def test_noUpdate(self): return self.req_d, self.req_d.name + @executor.mock_valid_lfid() @executor.update(httplib.OK, '_assert_update') def test_success(self): - req = project_models.ProjectUpdateRequest('newName', 'new description') + req = project_models.ProjectUpdateRequest('apex', 'apex test') return req, self.req_d.name def _assert_update(self, req, body): @@ -145,6 +149,7 @@ class TestProjectDelete(TestProjectBase): def test_notFound(self): return 'notFound' + @executor.mock_valid_lfid() @executor.delete(httplib.OK, '_assert_delete') def test_success(self): return self.req_d.name |