Testing new vhost has the tag
This commit is contained in:
parent
7003fefa44
commit
ea66a25dfa
|
@ -13,11 +13,13 @@ const EXCHANGES_TAB = By.css('div#menu ul#tabs li#exchanges')
|
|||
const ADMIN_TAB = By.css('div#menu ul#tabs li#admin')
|
||||
const STREAM_CONNECTIONS_TAB = By.css('div#menu ul#tabs li#stream-connections')
|
||||
|
||||
const FORM_POPUP = By.css('div.form-popup-warn')
|
||||
const FORM_POPUP_CLOSE_BUTTON = By.css('div.form-popup-warn span#close')
|
||||
const FORM_POPUP_WARNING = By.css('div.form-popup-warn')
|
||||
const FORM_POPUP_WARNING_CLOSE_BUTTON = By.css('div.form-popup-warn span#close')
|
||||
|
||||
const FORM_POPUP_OPTIONS = By.css('div.form-popup-options')
|
||||
const ADD_MINUS_BUTTON = By.css('div#main table.list thead tr th.plus-minus')
|
||||
const TABLE_COLUMNS_POPUP = By.css('div.form-popup-options table.form')
|
||||
const FORM_POPUP_OPTIONS_CLOSE_BUTTON = By.css('div.form-popup-options span#close')
|
||||
|
||||
module.exports = class BasePage {
|
||||
driver
|
||||
|
@ -157,7 +159,7 @@ module.exports = class BasePage {
|
|||
}
|
||||
async isPopupWarningDisplayed() {
|
||||
try {
|
||||
let element = await driver.findElement(FORM_POPUP)
|
||||
let element = await driver.findElement(FORM_POPUP_WARNING)
|
||||
return element.isDisplayed()
|
||||
} catch(e) {
|
||||
return Promise.resolve(false)
|
||||
|
@ -175,7 +177,7 @@ module.exports = class BasePage {
|
|||
}
|
||||
|
||||
async isPopupWarningNotDisplayed() {
|
||||
return this.isElementNotVisible(FORM_POPUP)
|
||||
return this.isElementNotVisible(FORM_POPUP_WARNING)
|
||||
}
|
||||
|
||||
async isElementNotVisible(locator) {
|
||||
|
@ -195,13 +197,13 @@ module.exports = class BasePage {
|
|||
}
|
||||
}
|
||||
async getPopupWarning() {
|
||||
let element = await driver.findElement(FORM_POPUP)
|
||||
let element = await driver.findElement(FORM_POPUP_WARNING)
|
||||
return this.driver.wait(until.elementIsVisible(element), this.timeout,
|
||||
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,
|
||||
this.polling).getText().then((value) => value.substring(0, value.search('\n\nClose')))
|
||||
}
|
||||
async closePopupWarning() {
|
||||
return this.click(FORM_POPUP_CLOSE_BUTTON)
|
||||
return this.click(FORM_POPUP_WARNING_CLOSE_BUTTON)
|
||||
}
|
||||
async clickOnSelectTableColumns() {
|
||||
return this.click(ADD_MINUS_BUTTON)
|
||||
|
@ -210,24 +212,28 @@ module.exports = class BasePage {
|
|||
const table = await this.waitForDisplayed(TABLE_COLUMNS_POPUP)
|
||||
const rows = await table.findElements(By.css('tbody tr'))
|
||||
let table_model = []
|
||||
console.log("Found "+ rows.length + " rows")
|
||||
for (let i = 1; i < rows.length; i++) { // skip first row
|
||||
let groupNameLabel = await rows[i].findElement(By.css('th label'))
|
||||
let groupName = await groupNameLabel.getText()
|
||||
console.log("Found group "+ groupName )
|
||||
let columns = await rows[i].findElements(By.css('td label'))
|
||||
let table_row = []
|
||||
console.log("Found "+ columns.length + " columns")
|
||||
for (let column of columns) {
|
||||
let checkbox = await column.findElement(By.css('input'))
|
||||
table_row.push({"name:" : await column.getText(), "id" : await checkbox.getAttribute("id")})
|
||||
}
|
||||
let group = {"name": groupName, "columns": table_row}
|
||||
console.log("Add group " + group)
|
||||
table_model.push(group)
|
||||
}
|
||||
return table_model
|
||||
}
|
||||
async selectTableColumnsById(arrayOfColumnsIds) {
|
||||
const table = await this.waitForDisplayed(TABLE_COLUMNS_POPUP)
|
||||
for (let id of arrayOfColumnsIds) {
|
||||
let checkbox = await table.findElement(By.css('tbody tr input#'+id))
|
||||
await checkbox.click()
|
||||
}
|
||||
await this.click(FORM_POPUP_OPTIONS_CLOSE_BUTTON)
|
||||
}
|
||||
|
||||
async isDisplayed(locator) {
|
||||
try {
|
||||
|
|
|
@ -9,7 +9,7 @@ const FILTER_VHOST = By.css('div#main div.filter input#filter')
|
|||
const CHECKBOX_REGEX = By.css('div#main div.filter input#filter-regex-mode')
|
||||
|
||||
const VHOSTS_TABLE_ROWS = By.css('div#main table.list tbody tr')
|
||||
const TABLE_SECTION = By.css('div#main table.list')
|
||||
const TABLE_SECTION = By.css('div#main div#vhosts.section table.list')
|
||||
|
||||
module.exports = class VhostsAdminTab extends AdminTab {
|
||||
async isLoaded () {
|
||||
|
|
|
@ -62,7 +62,7 @@ module.exports = {
|
|||
}
|
||||
let chromeCapabilities = Capabilities.chrome();
|
||||
const options = new chrome.Options()
|
||||
chromeCapabilities.setAcceptInsecureCerts(true);
|
||||
chromeCapabilities.setAcceptInsecureCerts(true);
|
||||
chromeCapabilities.set('goog:chromeOptions', {
|
||||
excludeSwitches: [ // disable info bar
|
||||
'enable-automation',
|
||||
|
@ -71,7 +71,8 @@ module.exports = {
|
|||
'profile.password_manager_enabled' : false
|
||||
},
|
||||
args: [
|
||||
"--guest",
|
||||
"--enable-automation",
|
||||
"guest",
|
||||
"disable-infobars",
|
||||
"--disable-notifications",
|
||||
"--lang=en",
|
||||
|
@ -87,7 +88,7 @@ module.exports = {
|
|||
});
|
||||
driver = builder
|
||||
.forBrowser('chrome')
|
||||
.setChromeOptions(options.excludeSwitches('enable-automation'))
|
||||
//.setChromeOptions(options.excludeSwitches("disable-popup-blocking", "enable-automation"))
|
||||
.withCapabilities(chromeCapabilities)
|
||||
.build()
|
||||
driver.manage().setTimeouts( { pageLoad: 35000 } )
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const { By, Key, until, Builder } = require('selenium-webdriver')
|
||||
require('chromedriver')
|
||||
const assert = require('assert')
|
||||
const { buildDriver, goToHome, captureScreensFor, teardown, doWhile, log } = require('../utils')
|
||||
const { buildDriver, goToHome, captureScreensFor, teardown, doWhile, log, delay } = require('../utils')
|
||||
const { getManagementUrl, createVhost, deleteVhost } = require('../mgt-api')
|
||||
|
||||
const LoginPage = require('../pageobjects/LoginPage')
|
||||
|
@ -51,15 +51,51 @@ describe('Virtual Hosts in Admin tab', function () {
|
|||
await overview.clickOnOverviewTab()
|
||||
await overview.clickOnAdminTab()
|
||||
await adminTab.clickOnVhosts()
|
||||
await doWhile(async function() { return vhostsTab.getVhostsTable() },
|
||||
function(table) { return table.length>1 })
|
||||
|
||||
await vhostsTab.clickOnSelectTableColumns()
|
||||
let table = await vhostsTab.getSelectableTableColumns()
|
||||
log("Table: " + table)
|
||||
await doWhile(async function() {
|
||||
return vhostsTab.getVhostsTable()
|
||||
}, function(table) {
|
||||
return table.length > 0 && vhost.localeCompare(table[0][0])
|
||||
})
|
||||
|
||||
assert.equal(4, table.length)
|
||||
let overviewGroup = {
|
||||
"name" : "Overview:",
|
||||
"columns": [
|
||||
{"name:":"Default queue type","id":"checkbox-vhosts-default-queue-type"},
|
||||
{"name:":"Cluster state","id":"checkbox-vhosts-cluster-state"},
|
||||
{"name:":"Description","id":"checkbox-vhosts-description"},
|
||||
{"name:":"Tags","id":"checkbox-vhosts-tags"}
|
||||
]
|
||||
}
|
||||
assert.equal(JSON.stringify(table[0]), JSON.stringify(overviewGroup))
|
||||
let messagesGroup = {
|
||||
"name" : "Messages:",
|
||||
"columns": [
|
||||
{"name:":"Ready","id":"checkbox-vhosts-msgs-ready"},
|
||||
{"name:":"Unacknowledged","id":"checkbox-vhosts-msgs-unacked"},
|
||||
{"name:":"Total","id":"checkbox-vhosts-msgs-total"}
|
||||
]
|
||||
}
|
||||
assert.equal(JSON.stringify(table[1]), JSON.stringify(messagesGroup))
|
||||
let networkGroup = {
|
||||
"name" : "Network:",
|
||||
"columns": [
|
||||
{"name:":"From client","id":"checkbox-vhosts-from_client"},
|
||||
{"name:":"To client","id":"checkbox-vhosts-to_client"}
|
||||
]
|
||||
}
|
||||
assert.equal(JSON.stringify(table[2]), JSON.stringify(networkGroup))
|
||||
let messageRatesGroup = {
|
||||
"name" : "Message rates:",
|
||||
"columns": [
|
||||
{"name:":"publish","id":"checkbox-vhosts-rate-publish"},
|
||||
{"name:":"deliver / get","id":"checkbox-vhosts-rate-deliver"}
|
||||
]
|
||||
}
|
||||
assert.equal(JSON.stringify(table[3]), JSON.stringify(messageRatesGroup))
|
||||
|
||||
})
|
||||
|
||||
describe('given there is a new virtualhost with a tag', async function() {
|
||||
let vhost = "test_" + Math.floor(Math.random() * 1000)
|
||||
before(async function() {
|
||||
|
@ -70,16 +106,19 @@ describe('Virtual Hosts in Admin tab', function () {
|
|||
await adminTab.clickOnVhosts()
|
||||
})
|
||||
it('vhost is listed with tag', async function () {
|
||||
log("Searching for vhost")
|
||||
await vhostsTab.searchForVhosts(vhost)
|
||||
await vhostsTab.clickOnSelectTableColumns()
|
||||
let table = vhostsTab.getSelectableTableColumns()
|
||||
log("Table: " + table)
|
||||
await doWhile(async function() {
|
||||
return vhostsTab.getVhostsTable()
|
||||
}, function(table) {
|
||||
return table.length > 0 && vhost.localeCompare(table[0][0])
|
||||
log("Searching for vhost " + vhost)
|
||||
await doWhile(async function() { return vhostsTab.searchForVhosts(vhost) },
|
||||
function(table) {
|
||||
return table.length==1 && table[1][0].localeCompare(vhost)
|
||||
})
|
||||
log("Found vhost " + vhost)
|
||||
await vhostsTab.selectTableColumnsById(["checkbox-vhosts-tags"])
|
||||
|
||||
await doWhile(async function() { return vhostsTab.getVhostsTable() },
|
||||
function(table) {
|
||||
return table.length==1 && table[1][3].localeCompare("selenium-tag")
|
||||
})
|
||||
|
||||
})
|
||||
after(async function () {
|
||||
log("Deleting vhost")
|
||||
|
@ -87,6 +126,7 @@ describe('Virtual Hosts in Admin tab', function () {
|
|||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
after(async function () {
|
||||
await teardown(driver, this, captureScreen)
|
||||
|
|
Loading…
Reference in New Issue