blob: 0137990f12249f61dce6648459700687c9df6faa [file] [log] [blame]
Matteo Scandolofb46ae62017-08-08 09:10:50 -07001
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 Scandolod3b57a12017-04-20 14:33:04 -070019const user = require('../test_helpers/user');
20const page = require('./crud.po');
21const config = require('../test_helpers/config');
22
23describe('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 Scandoloa4a2df72017-06-15 17:59:02 -070038 expect(page.tableColumn.count()).toBe(4);
Matteo Scandolod3b57a12017-04-20 14:33:04 -070039 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 Scandoloa4a2df72017-06-15 17:59:02 -070056 expect(page.formInputs.count()).toBe(4);
Matteo Scandolod3b57a12017-04-20 14:33:04 -070057 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});