From b9ebfe3d652ded4992fa3eb80738a47d3627d503 Mon Sep 17 00:00:00 2001 From: Kate Pimenova Date: Thu, 17 Sep 2015 17:08:32 +0300 Subject: [PATCH] [Intern] Notifications test - also added new helpers: .assertElement[Not]Displayed Related to blueprint ui-functional-tests-with-intern Change-Id: Ic2d5608e60aa68f7c1fa936a3212a79199deb561 --- .../tests/functional/test_notifications.js | 78 +++++++++++++++++++ nailgun/static/tests/helpers.js | 22 ++++++ 2 files changed, 100 insertions(+) create mode 100644 nailgun/static/tests/functional/test_notifications.js diff --git a/nailgun/static/tests/functional/test_notifications.js b/nailgun/static/tests/functional/test_notifications.js new file mode 100644 index 0000000000..2ace6754ad --- /dev/null +++ b/nailgun/static/tests/functional/test_notifications.js @@ -0,0 +1,78 @@ +/* + * 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([ + 'intern!object', + 'tests/functional/pages/common', + 'tests/functional/pages/modal' +], function(registerSuite, Common, ModalWindow) { + 'use strict'; + + registerSuite(function() { + var common, + modal; + + return { + name: 'Notifications', + setup: function() { + common = new Common(this.remote); + modal = new ModalWindow(this.remote); + + return this.remote + .then(function() { + return common.getIn(); + }) + }, + 'Notification Page': function() { + return this.remote + .assertElementDisplayed('.notifications-icon .badge', 'Badge notification indicator is shown in navigation') + // Go to Notification page + .clickByCssSelector('.notifications-icon') + .clickLinkByText('View all') + .assertElementAppears('.notifications-page', 2000, 'Notification page is rendered') + .assertElementsExist('.notifications-page .row.notification', 'There are one or more notifications on the page') + .assertElementNotDisplayed('.notifications-icon .badge', 'Badge notification indicator is hidden'); + }, + 'Notification badge behaviour': function() { + var clusterName = common.pickRandomName('Test Cluster'); + return this.remote + .then(function() { + return common.createCluster(clusterName); + }) + .then(function() { + return common.addNodesToCluster(1, ['Storage - Cinder']); + }) + // Just in case - reset and hide badge notification counter by clicking on it + .clickByCssSelector('.notifications-icon') + .then(function() { + return common.removeCluster(clusterName); + }) + .assertElementAppears('.notifications-icon .badge.visible', 3000, 'New notification appear after the cluster removal') + .clickByCssSelector('.notifications-icon') + .assertElementAppears('.notifications-popover .notification.clickable', 20000, 'Discovered node notification uploaded') + // Check if Node Information dialog is shown + .clickByCssSelector('.notifications-popover .notification.clickable p') + .then(function() { + return modal.waitToOpen(); + }) + .then(function() { + // Dialog with node information is open + return modal.checkTitle('Node Information'); + }); + } + }; + }); +}); diff --git a/nailgun/static/tests/helpers.js b/nailgun/static/tests/helpers.js index 635fef2708..50ffec2148 100644 --- a/nailgun/static/tests/helpers.js +++ b/nailgun/static/tests/helpers.js @@ -357,6 +357,28 @@ define([ .end(); }); }, + assertElementDisplayed: function(cssSelector, message) { + return new this.constructor(this, function() { + return this.parent + .findByCssSelector(cssSelector) + .isDisplayed() + .then(function(isDisplayed) { + return assert.isTrue(isDisplayed, message); + }) + .end(); + }); + }, + assertElementNotDisplayed: function(cssSelector, message) { + return new this.constructor(this, function() { + return this.parent + .findByCssSelector(cssSelector) + .isDisplayed() + .then(function(isDisplayed) { + return assert.isFalse(isDisplayed, message); + }) + .end(); + }); + }, assertElementTextEquals: function(cssSelector, expectedText, message) { return new this.constructor(this, function() { return this.parent