[Intern] Test cluster nodes page
Related to blueprint ui-functional-tests-with-intern Change-Id: Iaa285e3820b674fb0f6636145ca8f7244101abcb
This commit is contained in:
parent
94ccfc294a
commit
635f617e3b
|
@ -1,4 +1,5 @@
|
|||
define([
|
||||
'underscore',
|
||||
'intern/node_modules/dojo/node!fs',
|
||||
'../../helpers',
|
||||
'tests/functional/pages/login',
|
||||
|
@ -6,7 +7,7 @@ define([
|
|||
'tests/functional/pages/cluster',
|
||||
'tests/functional/pages/clusters'
|
||||
],
|
||||
function(fs, Helpers, LoginPage, WelcomePage, ClusterPage, ClustersPage) {
|
||||
function(_, fs, Helpers, LoginPage, WelcomePage, ClusterPage, ClustersPage) {
|
||||
'use strict';
|
||||
function CommonMethods(remote) {
|
||||
this.remote = remote;
|
||||
|
@ -18,6 +19,9 @@ define([
|
|||
|
||||
CommonMethods.prototype = {
|
||||
constructor: CommonMethods,
|
||||
pickRandomName: function(prefix) {
|
||||
return (prefix || 'Item') + ' #' + _.random(1000, 9999);
|
||||
},
|
||||
takeScreenshot: function(filename, error) {
|
||||
return this.remote
|
||||
.takeScreenshot()
|
||||
|
@ -64,17 +68,30 @@ define([
|
|||
},
|
||||
waitForModal: function() {
|
||||
return this.remote
|
||||
.setTimeout(2000)
|
||||
.setFindTimeout(2000)
|
||||
.findByCssSelector('div.modal-content')
|
||||
.end();
|
||||
},
|
||||
waitForModalToClose: function() {
|
||||
closeModal: function() {
|
||||
return this.remote
|
||||
.setTimeout(2000)
|
||||
.waitForDeletedByCssSelector('div.modal-content')
|
||||
.findByCssSelector('.modal-header button.close')
|
||||
.click()
|
||||
.end();
|
||||
},
|
||||
goToEnvironment: function(clusterName) {
|
||||
waitForElementDeletion: function(cssSelector) {
|
||||
return this.remote
|
||||
.setFindTimeout(2000)
|
||||
.waitForDeletedByCssSelector(cssSelector)
|
||||
.catch() // For cases when element is destroyed already
|
||||
.findByCssSelector(cssSelector)
|
||||
.then(function() {
|
||||
throw new Error('Element ' + cssSelector + ' was not destroyed');
|
||||
}, _.constant(true));
|
||||
},
|
||||
waitForModalToClose: function() {
|
||||
return this.waitForElementDeletion('div.modal-content');
|
||||
},
|
||||
goToEnvironment: function(clusterName, tabName) {
|
||||
var that = this;
|
||||
return this.remote
|
||||
.then(function() {
|
||||
|
@ -82,6 +99,9 @@ define([
|
|||
})
|
||||
.then(function() {
|
||||
return that.clustersPage.goToEnvironment(clusterName);
|
||||
})
|
||||
.then(function() {
|
||||
if (tabName) return that.clusterPage.goToTab(tabName);
|
||||
});
|
||||
},
|
||||
createCluster: function(clusterName) {
|
||||
|
@ -126,6 +146,28 @@ define([
|
|||
}
|
||||
)}, false);
|
||||
});
|
||||
},
|
||||
addNodesToCluster: function(nodesAmount, nodesRoles) {
|
||||
var that = this;
|
||||
return this.remote
|
||||
.setFindTimeout(5000)
|
||||
.findByCssSelector('a.btn-add-nodes')
|
||||
.click()
|
||||
.end()
|
||||
.findByCssSelector('div.role-panel')
|
||||
.end()
|
||||
.then(function() {
|
||||
return that.clusterPage.checkNodeRoles(nodesRoles);
|
||||
})
|
||||
.then(function() {
|
||||
return that.clusterPage.checkNodes(nodesAmount);
|
||||
})
|
||||
.findByCssSelector('button.btn-apply')
|
||||
.click()
|
||||
.end()
|
||||
.setFindTimeout(2000)
|
||||
.findByCssSelector('button.btn-add-nodes')
|
||||
.end();
|
||||
}
|
||||
};
|
||||
return CommonMethods;
|
||||
|
|
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
* Copyright 2015 Mirantis, Inc.
|
||||
*
|
||||
* 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.
|
||||
**/
|
||||
|
||||
define([
|
||||
'underscore',
|
||||
'intern!object',
|
||||
'intern/chai!assert',
|
||||
'tests/functional/pages/common'
|
||||
], function(_, registerSuite, assert, Common) {
|
||||
'use strict';
|
||||
|
||||
registerSuite(function() {
|
||||
var common,
|
||||
clusterName,
|
||||
nodesAmount = 4;
|
||||
|
||||
return {
|
||||
name: 'Cluster Nodes page',
|
||||
setup: function() {
|
||||
common = new Common(this.remote);
|
||||
clusterName = common.pickRandomName('Test Cluster');
|
||||
|
||||
return this.remote
|
||||
.then(function() {
|
||||
return common.getIn();
|
||||
})
|
||||
.then(function() {
|
||||
return common.createCluster(clusterName);
|
||||
})
|
||||
.then(function() {
|
||||
return common.addNodesToCluster(nodesAmount, ['Controller']);
|
||||
});
|
||||
},
|
||||
teardown: function() {
|
||||
return this.remote
|
||||
.then(function() {
|
||||
return common.removeCluster(clusterName, true);
|
||||
});
|
||||
},
|
||||
afterEach: function() {
|
||||
// Deselecting all nodes after every test
|
||||
return this.remote
|
||||
.findByCssSelector('.select-all label')
|
||||
.click()
|
||||
.click()
|
||||
.end();
|
||||
},
|
||||
'Standard View Mode': function() {
|
||||
var nodeNewName = 'Node new name';
|
||||
return this.remote
|
||||
.setFindTimeout(2000)
|
||||
.findByCssSelector('label.standard')
|
||||
// Standard mode chosen
|
||||
.click()
|
||||
.end()
|
||||
.findByClassName('node-box')
|
||||
.click()
|
||||
// Node gets selected upon clicking
|
||||
.findByCssSelector('.checkbox-group input[type=checkbox]:checked')
|
||||
.end()
|
||||
.end()
|
||||
.findByCssSelector('button.btn-delete-nodes')
|
||||
// Delete and
|
||||
.end()
|
||||
.findByCssSelector('button.btn-edit-roles')
|
||||
// ... Edit Roles buttons appear upon node selection
|
||||
.end()
|
||||
.findByCssSelector('.node.selected')
|
||||
.findByCssSelector('.name p')
|
||||
.click()
|
||||
.end()
|
||||
.findByCssSelector('input.node-name-input')
|
||||
// Node name gets editable upon clicking on it
|
||||
.clearValue()
|
||||
.type(nodeNewName)
|
||||
.pressKeys('\uE007')
|
||||
.end()
|
||||
.findByCssSelector('.name p')
|
||||
.getVisibleText()
|
||||
.then(function(nodeName) {
|
||||
assert.equal(nodeName, nodeNewName, 'Node name has been updated');
|
||||
})
|
||||
.end()
|
||||
.end()
|
||||
.findByCssSelector('div.node-settings')
|
||||
.click()
|
||||
.end()
|
||||
.then(function() {
|
||||
return common.waitForModal();
|
||||
})
|
||||
.findByCssSelector('.modal-header h4.modal-title')
|
||||
.getVisibleText()
|
||||
.then(function(nodeName) {
|
||||
assert.equal(nodeName, nodeNewName, 'Node pop-up has updated node name');
|
||||
})
|
||||
.end()
|
||||
.then(function() {
|
||||
return common.closeModal();
|
||||
})
|
||||
.then(function() {
|
||||
return common.waitForModalToClose();
|
||||
});
|
||||
},
|
||||
'Compact View Mode': function() {
|
||||
return this.remote
|
||||
.setFindTimeout(2000)
|
||||
.findByCssSelector('label.compact')
|
||||
// Standard mode chosen by default
|
||||
.click()
|
||||
.end()
|
||||
.findByCssSelector('div.compact-node')
|
||||
// Find a node
|
||||
.findByCssSelector('div.node-checkbox')
|
||||
.click()
|
||||
.findByCssSelector('i.glyphicon-ok')
|
||||
// Check that node is selectable
|
||||
.end()
|
||||
.end();
|
||||
},
|
||||
'Compact View Node Popover': function() {
|
||||
return this.remote
|
||||
.setFindTimeout(2000)
|
||||
.findByCssSelector('label.compact')
|
||||
// Standard mode chosen by default
|
||||
.click()
|
||||
.end()
|
||||
.findByCssSelector('div.compact-node')
|
||||
// Find a node
|
||||
.findByCssSelector('div.node-hardware p.btn')
|
||||
// Hardware pop-over
|
||||
.click()
|
||||
.end()
|
||||
.end()
|
||||
.findByCssSelector('div.node-popover')
|
||||
.findByCssSelector('button.node-details')
|
||||
// Open node extended view
|
||||
.click()
|
||||
.end()
|
||||
.end()
|
||||
.then(function() {
|
||||
return common.waitForElementDeletion('div.node-popover');
|
||||
})
|
||||
.then(function() {
|
||||
return common.waitForModal();
|
||||
})
|
||||
.then(function() {
|
||||
return common.closeModal();
|
||||
})
|
||||
.then(function() {
|
||||
return common.waitForModalToClose();
|
||||
})
|
||||
.findByCssSelector('div.compact-node div.node-hardware p.btn')
|
||||
// Open popover again
|
||||
.click()
|
||||
.end()
|
||||
.findByCssSelector('div.node-popover button.btn-discard')
|
||||
// Discarding node addition
|
||||
.click()
|
||||
.end()
|
||||
.then(function() {
|
||||
// Deletion confirmation shows up
|
||||
return common.waitForModal();
|
||||
})
|
||||
.findByCssSelector('div.modal-content button.btn-delete')
|
||||
// Confirm deletion
|
||||
.click()
|
||||
.end()
|
||||
.then(function() {
|
||||
return common.waitForModalToClose();
|
||||
})
|
||||
.findAllByCssSelector('div.compact-node')
|
||||
.then(function(nodes) {
|
||||
// Count nodes left
|
||||
assert.equal(nodes.length, nodesAmount - 1, 'Node has been removed');
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
|
@ -29,11 +29,11 @@ define([
|
|||
clusterName;
|
||||
|
||||
return {
|
||||
name: 'Clusters page',
|
||||
name: 'Cluster page',
|
||||
setup: function() {
|
||||
common = new Common(this.remote);
|
||||
clusterPage = new ClusterPage(this.remote);
|
||||
clusterName = 'Test Cluster #' + Math.round(99999 * Math.random());
|
||||
clusterName = common.pickRandomName('Test Cluster');
|
||||
},
|
||||
beforeEach: function() {
|
||||
return this.remote
|
||||
|
|
|
@ -29,7 +29,7 @@ define([
|
|||
name: 'Clusters page',
|
||||
setup: function() {
|
||||
common = new Common(this.remote);
|
||||
clusterName = 'Test Cluster #' + Math.round(99999 * Math.random());
|
||||
clusterName = common.pickRandomName('Test Cluster');
|
||||
},
|
||||
beforeEach: function() {
|
||||
return this.remote
|
||||
|
|
|
@ -57,4 +57,4 @@ casper.then(function() {
|
|||
|
||||
casper.run(function() {
|
||||
this.test.done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue