diff options
author | thuva4 <tharma.thuva@gmail.com> | 2017-12-30 09:29:03 +0530 |
---|---|---|
committer | thuva4 <tharma.thuva@gmail.com> | 2017-12-30 09:35:22 +0530 |
commit | c72bebf41dbd08facb7398fa94680d812ea38a62 (patch) | |
tree | 895711bc6168dc4d603c8a556ad4424b1e48c1f6 /testapi/opnfv_testapi/tests/UI | |
parent | 304b8eaad63eb7a610adb62f6c97c7a21a2b91fb (diff) |
Add the filter option in results page
apply multiple filter in results page.
Add e2e tests for results page.
Change-Id: Ia55407d921136756ab5f15507c92775f95a761dc
Signed-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/opnfv_testapi/tests/UI')
-rw-r--r-- | testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js | 363 |
1 files changed, 363 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js new file mode 100644 index 0000000..a14f8ea --- /dev/null +++ b/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js @@ -0,0 +1,363 @@ +'use strict'; + +var mock = require('protractor-http-mock'); +var baseURL = "http://localhost:8000/" + +describe('testing the result page for anonymous user', function () { + beforeEach(function(){ + mock([ + { + request: { + path: '/api/v1/results', + method: 'GET', + queryString: { + page: '1' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "results": [ + { + "project_name": "testproject", + "description": "Demo results", + "stop_date": "2017-12-28 16:08:43", + "case_name": "testcase", + "build_tag": null, + "user": null, + "installer": "fuel", + "scenario": "test-scenario", + "trust_indicator": null, + "public": "true", + "version": "euphrates", + "details": "", + "criteria": "PASS", + "_id": "5a45170bbb2092000e2643f4", + "start_date": "2017-12-28 14:44:27", + "pod_name": "testPod" + } + ] + } + } + }, + { + request: { + path: '/api/v1/results', + method: 'GET', + queryString: { + page: '1', + project: 'testproject' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "results": [ + { + "project_name": "testproject", + "description": "Demo results", + "stop_date": "2017-12-28 16:08:43", + "case_name": "testcase", + "build_tag": null, + "user": null, + "installer": "fuel", + "scenario": "test-scenario", + "trust_indicator": null, + "public": "true", + "version": "euphrates", + "details": "", + "criteria": "PASS", + "_id": "5a45170bbb2092000e2643f5", + "start_date": "2017-12-28 14:44:27", + "pod_name": "testPod" + } + ] + } + } + }, + { + request: { + path: '/api/v1/results', + method: 'GET', + queryString: { + page: '1', + project: 'testproject', + case: 'testcase' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "results": [ + { + "project_name": "testproject", + "description": "Demo results", + "stop_date": "2017-12-28 16:08:43", + "case_name": "testcase", + "build_tag": null, + "user": null, + "installer": "fuel", + "scenario": "test-scenario", + "trust_indicator": null, + "public": "true", + "version": "euphrates", + "details": "", + "criteria": "PASS", + "_id": "5a45170bbb2092000e2643f6", + "start_date": "2017-12-28 14:44:27", + "pod_name": "testPod" + } + ] + } + } + } + ]); + }); + + afterEach(function(){ + mock.teardown(); + }); + + it( 'should show the results page for anonymous user', function() { + browser.get(baseURL+"#/results"); + expect(element(by.cssContainingText(".ng-binding.ng-scope","Test Results")).isDisplayed()).toBe(true); + }); + + it( 'navigate anonymous user to testCase page', function() { + browser.get(baseURL); + var resultLink = element(by.linkText('Results')).click(); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains(baseURL+ '#/results'), 10000); + }); + + it('Should show the results in results page for anonymous user ', function () { + browser.get(baseURL+"#/results"); + var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f4"); + }); + + it('Should show the results in results page related to the filters for anonymous user ', function () { + browser.get(baseURL+"#/results"); + var filter = element(by.model('ctrl.filter')); + var filterText = element(by.model('ctrl.filterText')); + filter.sendKeys('project'); + filterText.sendKeys('testproject'); + var buttonFilter = element(by.buttonText('Filter')); + buttonFilter.click(); + var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f5"); + filter.sendKeys('case'); + filterText.sendKeys('testcase') + buttonFilter.click(); + expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f6"); + }); + it('Should not show the results in results page related to the filters for anonymous user ', function () { + browser.get(baseURL+"#/results"); + var filter = element(by.model('ctrl.filter')); + var filterText = element(by.model('ctrl.filterText')); + filter.sendKeys('project'); + filterText.sendKeys('testproject1'); + var buttonFilter = element(by.buttonText('Filter')); + buttonFilter.click(); + expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope')) + .isDisplayed()).toBe(true); + }); + +}); + +describe('testing the result page for user', 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" + } + } + }, + { + request: { + path: '/api/v1/results', + method: 'GET', + queryString: { + page: '1' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "results": [ + { + "project_name": "testproject", + "description": "Demo results", + "stop_date": "2017-12-28 16:08:43", + "case_name": "testcase", + "build_tag": null, + "user": null, + "installer": "fuel", + "scenario": "test-scenario", + "trust_indicator": null, + "public": "true", + "version": "euphrates", + "details": "", + "criteria": "PASS", + "_id": "5a45170bbb2092000e2643f4", + "start_date": "2017-12-28 14:44:27", + "pod_name": "testPod" + } + ] + } + } + }, + { + request: { + path: '/api/v1/results', + method: 'GET', + queryString: { + page: '1', + project: 'testproject' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "results": [ + { + "project_name": "testproject", + "description": "Demo results", + "stop_date": "2017-12-28 16:08:43", + "case_name": "testcase", + "build_tag": null, + "user": null, + "installer": "fuel", + "scenario": "test-scenario", + "trust_indicator": null, + "public": "true", + "version": "euphrates", + "details": "", + "criteria": "PASS", + "_id": "5a45170bbb2092000e2643f5", + "start_date": "2017-12-28 14:44:27", + "pod_name": "testPod" + } + ] + } + } + }, + { + request: { + path: '/api/v1/results', + method: 'GET', + queryString: { + page: '1', + project: 'testproject', + case: 'testcase' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "results": [ + { + "project_name": "testproject", + "description": "Demo results", + "stop_date": "2017-12-28 16:08:43", + "case_name": "testcase", + "build_tag": null, + "user": null, + "installer": "fuel", + "scenario": "test-scenario", + "trust_indicator": null, + "public": "true", + "version": "euphrates", + "details": "", + "criteria": "PASS", + "_id": "5a45170bbb2092000e2643f6", + "start_date": "2017-12-28 14:44:27", + "pod_name": "testPod" + } + ] + } + } + } + ]); + }); + + afterEach(function(){ + mock.teardown(); + }); + + it( 'should show the results page for user', function() { + browser.get(baseURL+"#/results"); + expect(element(by.cssContainingText(".ng-binding.ng-scope","Test Results")).isDisplayed()).toBe(true); + }); + + it( 'navigate user to testCase page', function() { + browser.get(baseURL); + var resultLink = element(by.linkText('Results')).click(); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains(baseURL+ '#/results'), 10000); + }); + + it('Should show the results in results page for user ', function () { + browser.get(baseURL+"#/results"); + var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f4"); + }); + + it('Should show the results in results page related to the filters for user ', function () { + browser.get(baseURL+"#/results"); + var filter = element(by.model('ctrl.filter')); + var filterText = element(by.model('ctrl.filterText')); + filter.sendKeys('project'); + filterText.sendKeys('testproject'); + var buttonFilter = element(by.buttonText('Filter')); + buttonFilter.click(); + var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f5"); + filter.sendKeys('case'); + filterText.sendKeys('testcase') + buttonFilter.click(); + expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f6"); + }); + it('Should not show the results in results page related to the filters for user ', function () { + browser.get(baseURL+"#/results"); + var filter = element(by.model('ctrl.filter')); + var filterText = element(by.model('ctrl.filterText')); + filter.sendKeys('project'); + filterText.sendKeys('testproject1'); + var buttonFilter = element(by.buttonText('Filter')); + buttonFilter.click(); + expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope')) + .isDisplayed()).toBe(true); + }); + +});
\ No newline at end of file |