3 var mock = require('protractor-http-mock');
4 var baseURL = "http://localhost:8000"
5 describe('testing the Pods page for anonymous user', function () {
15 pods: [{role: "community-ci", name: "test", owner: "testUser", details: "DemoDetails", mode: "metal", _id: "59f02f099a07c84bfc5c7aed", creation_date: "2017-10-25 11:58:25.926168"}]
21 it( 'should navigate to pods link ', function() {
23 var podslink = element(by.linkText('Pods')).click();
24 var EC = browser.ExpectedConditions;
25 browser.wait(EC.urlContains(baseURL+ '/#/pods'), 10000);
28 it('create button is not visible for anonymous user', function () {
29 browser.get(baseURL+'#/pods');
30 var buttonCreate = element(by.buttonText('Create'));
31 expect(buttonCreate.isDisplayed()).toBeFalsy();
34 it('filter button is visible for anonymous user', function () {
35 var buttonFilter = element(by.buttonText('Filter'));
36 expect(buttonFilter.isDisplayed()).toBe(true)
39 it('clear button is visible for anonymous user', function () {
40 var buttonClear = element(by.buttonText('Clear'));
41 expect(buttonClear.isDisplayed()).toBe(true)
44 it('Show results when click filter button', function () {
45 var buttonFilter = element(by.buttonText('Filter'));
47 var pod = element(by.css('.show-pod'));
48 expect(pod.isPresent()).toBe(true);
51 it('Show results when click clear button', function () {
52 browser.get(baseURL+'#/pods');
53 var buttonClear = element(by.buttonText('Clear'));
55 var pod = element(by.css('.show-pod'));
56 expect(pod.isPresent()).toBe(true);
59 it('If details is not shown then show details when click the link',function() {
60 expect(element(by.css('.show-pod.hidden')).isPresent()).toBe(true);
61 var podslink = element(by.linkText('test')).click();
62 expect(element(by.css('.show-pod.hidden')).isPresent()).toBe(false);
65 it('If details is shown then hide details when click the link',function() {
66 expect(element(by.css('.show-pod.hidden')).isPresent()).toBe(false);
67 var podslink = element(by.linkText('test')).click();
68 expect(element(by.css('.show-pod.hidden')).isPresent()).toBe(true);
71 it('If backend is not responding then show error when click filter button', function () {
72 browser.get(baseURL + '/#/pods');
74 var buttonFilter = element(by.buttonText('Filter'));
75 buttonFilter.click().then(function(){
76 expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope')).isDisplayed()).toBe(true);
82 describe('testing the Pods page for authorized user', function () {
84 beforeEach(function(){
93 href: baseURL+"/api/v1/pods/test"
103 details : 'DemoDetails',
104 role : 'community-ci',
114 path: '/api/v1/profile',
119 "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", "user": "testUser", "groups": ["opnfv-testapi-users"], "email": "testuser@test.com"
126 it('create button is visible for authorized user', function () {
127 browser.get(baseURL + '/#/pods');
128 var buttonCreate = element(by.buttonText('Create'));
129 expect(buttonCreate.isDisplayed()).toBe(true);
132 it('Do not show error if input is acceptable', function () {
133 var name = element(by.model('ctrl.name'));
134 var details = element(by.model('ctrl.details'));
135 name.sendKeys('test');
136 details.sendKeys('DemoDetails');
137 var buttonCreate = element(by.buttonText('Create'));
138 buttonCreate.click().then(function(){
139 expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope')).isDisplayed()).toBe(false);
143 it('Show error when user click the create button with a empty name', function () {
144 browser.get(baseURL+ '/#/pods');
145 var details = element(by.model('ctrl.details'));
146 details.sendKeys('DemoDetails');
147 var buttonCreate = element(by.buttonText('Create'));
148 buttonCreate.click();
149 expect(element(by.cssContainingText(".alert","Name is missing.")).isDisplayed()).toBe(true);
152 it('Show error when user click the create button with an already existing name', function () {
153 browser.get(baseURL+ '/#/pods');
154 var name = element(by.model('ctrl.name'));
155 var details = element(by.model('ctrl.details'));
156 name.sendKeys('test1');
157 details.sendKeys('DemoDetails');
158 var buttonCreate = element(by.buttonText('Create'));
159 buttonCreate.click();
160 expect(element(by.cssContainingText(".alert","Error creating the new pod from server: Pod's name already exists")).isDisplayed()).toBe(true);
163 it('If backend is not responding then show error when user click the create button',function(){
168 path: '/api/v1/profile',
173 "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", "user": "testUser", "groups": ["opnfv-testapi-users"], "email": "testuser@test.com"
178 browser.get(baseURL+ '/#/pods');
179 var name = element(by.model('ctrl.name'));
180 var details = element(by.model('ctrl.details'));
181 name.sendKeys('test');
182 details.sendKeys('DemoDetails');
183 var buttonCreate = element(by.buttonText('Create'));
184 buttonCreate.click().then(function(){
185 expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope')).isDisplayed()).toBe(true);