[CORD-2338] Single command to run E2E tests
Change-Id: Id8db22b2b496ca16d20d2c4d0739d9b9042540db
diff --git a/e2e/crud/crud.po.js b/e2e/crud/crud.po.js
index 6372fc5..78589d4 100644
--- a/e2e/crud/crud.po.js
+++ b/e2e/crud/crud.po.js
@@ -19,19 +19,21 @@
module.exports = new function(){
// list view
- this.tableRows = element.all(by.repeater('item in vm.data'));
- this.tableColumn = element(by.repeater('item in vm.data').row(0))
- .all(by.repeater('col in vm.columns'));
+ this.tableRows = element.all(by.css('tbody > tr'));
+ this.tableColumn = element(by.css('tbody > tr:first-child'))
+ .all(by.css('td'));
- this.actionsColumn = element(by.repeater('item in vm.data').row(0))
+ this.actionsColumn = element(by.css('tbody > tr:first-child'))
.element(by.css('td:last-child'));
- this.deleteBtn = this.actionsColumn.all(by.tagName('a'));
+ this.deleteBtn = this.actionsColumn.all(by.css('a[title="delete"'));
+ this.detailBtn = this.actionsColumn.all(by.css('a[title="details"'));
this.addBtn = element(by.linkText('Add'));
// detail page
this.formInputs = element.all(by.repeater('field in vm.config.inputs'));
+ this.nameInput = element.all(by.css('xos-form input')).first()
this.formBtn = element(by.buttonText('Save'));
this.nameField = element(by.css('[name="name"]'));
diff --git a/e2e/crud/crud.spec.js b/e2e/crud/crud.spec.js
index 0137990..4eecc62 100644
--- a/e2e/crud/crud.spec.js
+++ b/e2e/crud/crud.spec.js
@@ -19,10 +19,34 @@
const user = require('../test_helpers/user');
const page = require('./crud.po');
const config = require('../test_helpers/config');
+const backend = require('../test_helpers/backend');
+
+let testNode;
describe('XOS CRUD Page', function() {
beforeEach((done) => {
+ const nodesUrl = `/xosapi/v1/core/nodes`;
+
+ const _testNode = {
+ name: 'test-p',
+ site_deployment_id: 1
+ }
+
+ backend.deleteAllModels(nodesUrl)
+ .then(() => {
+ return backend.createModel(nodesUrl, _testNode)
+ })
+ .then((node) => {
+ testNode = node;
+ done();
+ })
+ .catch(e => {
+ done(e);
+ })
+ });
+
+ beforeEach((done) => {
user.login()
.then(() => {
done();
@@ -34,9 +58,10 @@
browser.get(`${config.url}/core/nodes/`);
});
it('should have a table', () => {
- expect(page.tableRows.count()).toBe(2);
- expect(page.tableColumn.count()).toBe(4);
- expect(page.deleteBtn.count()).toBe(1); // per row
+ expect(page.tableRows.count()).toBe(1);
+ expect(page.tableColumn.count()).toBe(6);
+ expect(page.deleteBtn.count()).toBe(1);
+ expect(page.detailBtn.count()).toBe(1);
});
it('should have an add button', () => {
@@ -50,10 +75,11 @@
describe('for an existing model', () => {
beforeEach(() => {
- browser.get(`${config.url}/core/nodes/1`);
+ browser.get(`${config.url}/core/nodes/${testNode.id}`);
});
- it('should have a form', () => {
- expect(page.formInputs.count()).toBe(4);
+ it('should load the correct model', () => {
+ expect(page.formInputs.count()).toBe(2);
+ expect(page.nameInput.getAttribute('value')).toBe(testNode.name);
expect(page.formBtn.isPresent()).toBeTruthy();
});
diff --git a/e2e/dashboard/dashboard.po.js b/e2e/dashboard/dashboard.po.js
index 714be20..074a2e8 100644
--- a/e2e/dashboard/dashboard.po.js
+++ b/e2e/dashboard/dashboard.po.js
@@ -18,8 +18,8 @@
module.exports = new function(){
- this.graphTitle = element(by.css('xos-coarse-tenancy-graph h1'));
- this.graphSvg = element(by.css('xos-coarse-tenancy-graph svg'));
+ this.graphTitle = element(by.css('xos-service-graph h1'));
+ this.graphSvg = element(by.css('xos-service-graph svg'));
this.summaryTitle = element(by.css('xos-dashboard > .row > .col-xs-12 > h2'));
this.summaryBoxes = element.all(by.css('.panel.panel-filled'));
diff --git a/e2e/keyboard-shortcuts/shortcut.spec.js b/e2e/keyboard-shortcuts/shortcut.spec.js
index ce0f52a..a4cf974 100644
--- a/e2e/keyboard-shortcuts/shortcut.spec.js
+++ b/e2e/keyboard-shortcuts/shortcut.spec.js
@@ -25,7 +25,12 @@
user.login();
});
- it('should open the side panel when ? is pressed', () => {
+ it('should open the side panel when / is pressed', () => {
+ page.pressKey('/');
+ expect(page.sidePanel.getAttribute('class')).toMatch('open');
+ });
+
+ xit('should open the side panel when ? is pressed', () => {
page.pressKey('?');
expect(page.sidePanel.getAttribute('class')).toMatch('open');
});
diff --git a/e2e/login/login.spec.js b/e2e/login/login.spec.js
index 56090be..95dbb63 100644
--- a/e2e/login/login.spec.js
+++ b/e2e/login/login.spec.js
@@ -25,6 +25,7 @@
describe('XOS Login page', function() {
beforeEach(() => {
+ browser.manage().deleteAllCookies();
browser.get(`${config.url}/login`);
});
diff --git a/e2e/test_helpers/backend.js b/e2e/test_helpers/backend.js
new file mode 100644
index 0000000..5a57b89
--- /dev/null
+++ b/e2e/test_helpers/backend.js
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const request = require('request-promise');
+const config = require('../test_helpers/config');
+const user = require('../test_helpers/user');
+const P = require('bluebird');
+const baseUrl = config.url.replace('/xos/#', '');
+
+const auth = {
+ 'auth': {
+ 'user': user.username,
+ 'pass': user.pwd.replace('\n', ''),
+ }
+};
+
+const _getIds = (list) => {
+ return list.map(i => i.id);
+}
+
+const _parseRes = (res) => JSON.parse(res);
+
+const getModels = P.promisify((url, done) => {
+ request.get(`${ baseUrl + url }`, auth)
+ .then(res => {
+ return done(null, _parseRes(res));
+ })
+ .catch(e => {
+ return done(e);
+ });
+});
+
+const deleteModel = P.promisify((url, id, done) => {
+ request.delete(`${ baseUrl +url }/${id}`, auth)
+ .then(res => {
+ return done(null, res);
+ })
+ .catch(e => {
+ return done(e);
+ });
+});
+
+const deleteAllModels = P.promisify((url, done) => {
+ getModels(url)
+ .then(res => {
+ if (res.items.length === 0) {
+ return done(null);
+ }
+ const ids = _getIds(res.items);
+ const promises = [];
+ ids.forEach(id => {
+ promises.push(deleteModel(url, id));
+ })
+
+ return P.all(promises)
+ })
+ .then(res => {
+ done(null, res);
+ })
+ .catch(e => {
+ return done(e);
+ });
+});
+
+const createModel = P.promisify((url, data, done) => {
+ request({
+ uri: baseUrl + url,
+ method: 'POST',
+ json: data,
+ auth: auth.auth
+ })
+ .then(res => {
+ return done(null, res);
+ })
+ .catch(err => {
+ return done(err);
+ })
+})
+
+// getModels(`/xosapi/v1/core/nodes`).then(console.log);
+
+// createModel(`/xosapi/v1/core/nodes`, {name: 'test-p', site_deployment_id: 1});
+
+module.exports = {
+ getModels: getModels,
+ deleteAllModels: deleteAllModels,
+ createModel: createModel,
+ deleteModel: deleteModel
+}
\ No newline at end of file
diff --git a/e2e/test_helpers/config.js b/e2e/test_helpers/config.js
index eea60b1..d90b3cc 100644
--- a/e2e/test_helpers/config.js
+++ b/e2e/test_helpers/config.js
@@ -16,4 +16,4 @@
*/
-exports.url = process.env.UI_URL || 'http://192.168.46.100/xos/#';
\ No newline at end of file
+exports.url = process.env.UI_URL || 'http://127.0.0.1:4000/xos/#';
\ No newline at end of file
diff --git a/e2e/test_helpers/user.js b/e2e/test_helpers/user.js
index 9a6f09a..11ac4f8 100644
--- a/e2e/test_helpers/user.js
+++ b/e2e/test_helpers/user.js
@@ -17,6 +17,7 @@
const fs = require('fs');
+const path = require('path');
const config = require('./config');
const P = require('bluebird');
@@ -28,7 +29,7 @@
return process.env.UI_PWD;
}
- const pwdFile = fs.readFileSync('../../build/platform-install/credentials/xosadmin@opencord.org', 'utf8');
+ const pwdFile = fs.readFileSync(path.join(__dirname, '../../../../build/platform-install/credentials/xosadmin@opencord.org'), 'utf8');
return pwdFile;
};