From 1fe11fb48972ce30b21a4423244642f0ed391b0c Mon Sep 17 00:00:00 2001 From: thuva4 Date: Sun, 11 Feb 2018 16:31:48 +0530 Subject: Add multiple customs in scenario page implement function to add multiple customs with a single add button click JIRA: RELENG-344 Change-Id: I7c4ac409ee5d78a6a01b242368b02813f0df400f Signed-off-by: thuva4 --- .../tests/UI/e2e/scenarioControllerSpec.js | 40 ++++++++++++++++++++-- .../components/scenarios/modals/customModal.html | 30 +++++++++++++--- .../scenarios/scenario/scenarioController.js | 23 +++++++++++-- 3 files changed, 84 insertions(+), 9 deletions(-) (limited to 'testapi') diff --git a/testapi/opnfv_testapi/tests/UI/e2e/scenarioControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/scenarioControllerSpec.js index 60d4949..564fbcf 100644 --- a/testapi/opnfv_testapi/tests/UI/e2e/scenarioControllerSpec.js +++ b/testapi/opnfv_testapi/tests/UI/e2e/scenarioControllerSpec.js @@ -336,7 +336,7 @@ describe('testing the scenarios page for anonymous user', function () { }); -describe('testing the scenarios page for anonymous user', function () { +describe('testing the scenarios page for user', function () { beforeEach(function(){ mock([ { @@ -662,7 +662,7 @@ describe('testing the scenarios page for anonymous user', function () { browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000); }); - it( 'should not show the add installer option for user', function() { + it( 'should show the add installer option for user', function() { browser.get(baseURL+"#/scenarios/test-scenario"); var EC = browser.ExpectedConditions; browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000); @@ -1009,6 +1009,42 @@ describe('testing the scenarios page for anonymous user', function () { .isDisplayed()).toBe(true); }); + it( 'Add multiple Customs by user', function() { + browser.get(baseURL+"#/scenarios/test-scenario"); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000); + var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[5]/td[2]/div[1]/a/p')) + installersShow.click(); + var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[5]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a')) + installerShow.click(); + var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[5]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p')) + versionsShow.click(); + var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[5]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a')) + versionShow.click() + var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[5]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a')) + projectsShow.click(); + var projectShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[5]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a')) + projectShow.click(); + var customsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[5]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[4]/td[2]/a/p')) + customsShow.click(); + var row = element.all(by.repeater('(indexCU, custom) in project.customs')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("dvs"); + var buttonAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[5]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[4]/td[2]/button')) + buttonAdd.click() + var custom = element(by.model('customModalCtrl.custom')); + browser.wait(EC.visibilityOf(custom), 5000); + custom.sendKeys('testC'); + // browser.pause(); + var buttonAddCustom = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[1]/div/fieldset/div/div/div/table/tfoot/tr/td[2]/input')) + buttonAddCustom.click(); + custom.sendKeys('testB'); + var buttonOk = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[2]/button[1]')) + buttonOk.click() + expect(element(by.cssContainingText(".alert","Customs are successfully updated.")) + .isDisplayed()).toBe(true); + }); + it( 'Delete Customs by user', function() { browser.get(baseURL+"#/scenarios/test-scenario"); var EC = browser.ExpectedConditions; diff --git a/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html b/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html index 987cb1e..90e4544 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html +++ b/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html @@ -6,11 +6,31 @@ {{customModalCtrl.data.text}}
- -
- -

-
+ + + + + + + + + + + + + + +
+
+ +

+
+
+
+ +

+
+
diff --git a/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js b/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js index 53eb13a..b76f63c 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js +++ b/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js @@ -435,15 +435,34 @@ ctrl.cancel = cancel; ctrl.data = angular.copy(data); ctrl.open = open; + ctrl.add = add; + ctrl.remove = remove; + ctrl.customs = []; + + function add() { + var custom = ctrl.custom; + if(custom!="" && custom!=undefined ){ + ctrl.customs.push(custom); + ctrl.custom = ""; + } + }; + + function remove(index) { + // var name = ctrl.customs[index].Name; + ctrl.customs.splice(index, 1); + + } /** * Initiate confirmation and call the success handler with the * inputs. */ function confirm() { - ctrl.customs = [] - ctrl.customs.push(ctrl.custom) + var custom = ctrl.custom; + if(custom!="" && custom!=undefined ){ + ctrl.customs.push(custom); + } ctrl.data.successHandler(ctrl.customs,ctrl.data.project,ctrl.data.version,ctrl.data.installer); $uibModalInstance.dismiss('cancel'); -- cgit 1.2.3-korg