Matteo Scandolo | fb46ae6 | 2017-08-08 09:10:50 -0700 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2017-present Open Networking Foundation |
| 4 | |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | |
Matteo Scandolo | d3b57a1 | 2017-04-20 14:33:04 -0700 | [diff] [blame] | 19 | const user = require('../test_helpers/user'); |
| 20 | const page = require('./crud.po'); |
| 21 | const config = require('../test_helpers/config'); |
| 22 | |
| 23 | describe('XOS CRUD Page', function() { |
| 24 | |
| 25 | beforeEach((done) => { |
| 26 | user.login() |
| 27 | .then(() => { |
| 28 | done(); |
| 29 | }); |
| 30 | }); |
| 31 | |
| 32 | describe('list view', () => { |
| 33 | beforeEach(() => { |
| 34 | browser.get(`${config.url}/core/nodes/`); |
| 35 | }); |
| 36 | it('should have a table', () => { |
| 37 | expect(page.tableRows.count()).toBe(2); |
Matteo Scandolo | a4a2df7 | 2017-06-15 17:59:02 -0700 | [diff] [blame] | 38 | expect(page.tableColumn.count()).toBe(4); |
Matteo Scandolo | d3b57a1 | 2017-04-20 14:33:04 -0700 | [diff] [blame] | 39 | expect(page.deleteBtn.count()).toBe(1); // per row |
| 40 | }); |
| 41 | |
| 42 | it('should have an add button', () => { |
| 43 | expect(page.addBtn.isDisplayed()).toBeTruthy(); |
| 44 | page.addBtn.click(); |
| 45 | expect(browser.getCurrentUrl()).toBe(`${config.url}/core/nodes/add`); |
| 46 | }); |
| 47 | }); |
| 48 | |
| 49 | describe('details view', () => { |
| 50 | |
| 51 | describe('for an existing model', () => { |
| 52 | beforeEach(() => { |
| 53 | browser.get(`${config.url}/core/nodes/1`); |
| 54 | }); |
| 55 | it('should have a form', () => { |
Matteo Scandolo | a4a2df7 | 2017-06-15 17:59:02 -0700 | [diff] [blame] | 56 | expect(page.formInputs.count()).toBe(4); |
Matteo Scandolo | d3b57a1 | 2017-04-20 14:33:04 -0700 | [diff] [blame] | 57 | expect(page.formBtn.isPresent()).toBeTruthy(); |
| 58 | }); |
| 59 | |
| 60 | it('should save the model', () => { |
| 61 | page.nameField.clear().sendKeys('test'); |
| 62 | page.formBtn.click(); |
| 63 | expect(page.nameField.getAttribute('value')).toBe('test'); |
| 64 | expect(page.successFeedback.isDisplayed()).toBeTruthy(); |
| 65 | browser.sleep(3000) |
| 66 | }); |
| 67 | }) |
| 68 | }); |
| 69 | }); |