blob: 4eecc628e19f71a495931321dea86d9caa5d2f63 [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');
Matteo Scandolof4f69552017-08-24 17:26:25 -070022const backend = require('../test_helpers/backend');
23
24let testNode;
Matteo Scandolod3b57a12017-04-20 14:33:04 -070025
26describe('XOS CRUD Page', function() {
27
28 beforeEach((done) => {
Matteo Scandolof4f69552017-08-24 17:26:25 -070029 const nodesUrl = `/xosapi/v1/core/nodes`;
30
31 const _testNode = {
32 name: 'test-p',
33 site_deployment_id: 1
34 }
35
36 backend.deleteAllModels(nodesUrl)
37 .then(() => {
38 return backend.createModel(nodesUrl, _testNode)
39 })
40 .then((node) => {
41 testNode = node;
42 done();
43 })
44 .catch(e => {
45 done(e);
46 })
47 });
48
49 beforeEach((done) => {
Matteo Scandolod3b57a12017-04-20 14:33:04 -070050 user.login()
51 .then(() => {
52 done();
53 });
54 });
55
56 describe('list view', () => {
57 beforeEach(() => {
58 browser.get(`${config.url}/core/nodes/`);
59 });
60 it('should have a table', () => {
Matteo Scandolof4f69552017-08-24 17:26:25 -070061 expect(page.tableRows.count()).toBe(1);
62 expect(page.tableColumn.count()).toBe(6);
63 expect(page.deleteBtn.count()).toBe(1);
64 expect(page.detailBtn.count()).toBe(1);
Matteo Scandolod3b57a12017-04-20 14:33:04 -070065 });
66
67 it('should have an add button', () => {
68 expect(page.addBtn.isDisplayed()).toBeTruthy();
69 page.addBtn.click();
70 expect(browser.getCurrentUrl()).toBe(`${config.url}/core/nodes/add`);
71 });
72 });
73
74 describe('details view', () => {
75
76 describe('for an existing model', () => {
77 beforeEach(() => {
Matteo Scandolof4f69552017-08-24 17:26:25 -070078 browser.get(`${config.url}/core/nodes/${testNode.id}`);
Matteo Scandolod3b57a12017-04-20 14:33:04 -070079 });
Matteo Scandolof4f69552017-08-24 17:26:25 -070080 it('should load the correct model', () => {
81 expect(page.formInputs.count()).toBe(2);
82 expect(page.nameInput.getAttribute('value')).toBe(testNode.name);
Matteo Scandolod3b57a12017-04-20 14:33:04 -070083 expect(page.formBtn.isPresent()).toBeTruthy();
84 });
85
86 it('should save the model', () => {
87 page.nameField.clear().sendKeys('test');
88 page.formBtn.click();
89 expect(page.nameField.getAttribute('value')).toBe('test');
90 expect(page.successFeedback.isDisplayed()).toBeTruthy();
91 browser.sleep(3000)
92 });
93 })
94 });
95});