Skip to content

Commit 4fd25e0

Browse files
MarcialRosalesmergify[bot]
authored andcommitted
Testing new vhost has the tag
(cherry picked from commit ea66a25)
1 parent 3855983 commit 4fd25e0

File tree

4 files changed

+77
-30
lines changed

4 files changed

+77
-30
lines changed

selenium/test/pageobjects/BasePage.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ const EXCHANGES_TAB = By.css('div#menu ul#tabs li#exchanges')
1313
const ADMIN_TAB = By.css('div#menu ul#tabs li#admin')
1414
const STREAM_CONNECTIONS_TAB = By.css('div#menu ul#tabs li#stream-connections')
1515

16-
const FORM_POPUP = By.css('div.form-popup-warn')
17-
const FORM_POPUP_CLOSE_BUTTON = By.css('div.form-popup-warn span#close')
16+
const FORM_POPUP_WARNING = By.css('div.form-popup-warn')
17+
const FORM_POPUP_WARNING_CLOSE_BUTTON = By.css('div.form-popup-warn span#close')
1818

19+
const FORM_POPUP_OPTIONS = By.css('div.form-popup-options')
1920
const ADD_MINUS_BUTTON = By.css('div#main table.list thead tr th.plus-minus')
2021
const TABLE_COLUMNS_POPUP = By.css('div.form-popup-options table.form')
22+
const FORM_POPUP_OPTIONS_CLOSE_BUTTON = By.css('div.form-popup-options span#close')
2123

2224
module.exports = class BasePage {
2325
driver
@@ -157,7 +159,7 @@ module.exports = class BasePage {
157159
}
158160
async isPopupWarningDisplayed() {
159161
try {
160-
let element = await driver.findElement(FORM_POPUP)
162+
let element = await driver.findElement(FORM_POPUP_WARNING)
161163
return element.isDisplayed()
162164
} catch(e) {
163165
return Promise.resolve(false)
@@ -175,7 +177,7 @@ module.exports = class BasePage {
175177
}
176178

177179
async isPopupWarningNotDisplayed() {
178-
return this.isElementNotVisible(FORM_POPUP)
180+
return this.isElementNotVisible(FORM_POPUP_WARNING)
179181
}
180182

181183
async isElementNotVisible(locator) {
@@ -195,13 +197,13 @@ module.exports = class BasePage {
195197
}
196198
}
197199
async getPopupWarning() {
198-
let element = await driver.findElement(FORM_POPUP)
200+
let element = await driver.findElement(FORM_POPUP_WARNING)
199201
return this.driver.wait(until.elementIsVisible(element), this.timeout,
200202
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,
201203
this.polling).getText().then((value) => value.substring(0, value.search('\n\nClose')))
202204
}
203205
async closePopupWarning() {
204-
return this.click(FORM_POPUP_CLOSE_BUTTON)
206+
return this.click(FORM_POPUP_WARNING_CLOSE_BUTTON)
205207
}
206208
async clickOnSelectTableColumns() {
207209
return this.click(ADD_MINUS_BUTTON)
@@ -210,24 +212,28 @@ module.exports = class BasePage {
210212
const table = await this.waitForDisplayed(TABLE_COLUMNS_POPUP)
211213
const rows = await table.findElements(By.css('tbody tr'))
212214
let table_model = []
213-
console.log("Found "+ rows.length + " rows")
214215
for (let i = 1; i < rows.length; i++) { // skip first row
215216
let groupNameLabel = await rows[i].findElement(By.css('th label'))
216217
let groupName = await groupNameLabel.getText()
217-
console.log("Found group "+ groupName )
218218
let columns = await rows[i].findElements(By.css('td label'))
219219
let table_row = []
220-
console.log("Found "+ columns.length + " columns")
221220
for (let column of columns) {
222221
let checkbox = await column.findElement(By.css('input'))
223222
table_row.push({"name:" : await column.getText(), "id" : await checkbox.getAttribute("id")})
224223
}
225224
let group = {"name": groupName, "columns": table_row}
226-
console.log("Add group " + group)
227225
table_model.push(group)
228226
}
229227
return table_model
230228
}
229+
async selectTableColumnsById(arrayOfColumnsIds) {
230+
const table = await this.waitForDisplayed(TABLE_COLUMNS_POPUP)
231+
for (let id of arrayOfColumnsIds) {
232+
let checkbox = await table.findElement(By.css('tbody tr input#'+id))
233+
await checkbox.click()
234+
}
235+
await this.click(FORM_POPUP_OPTIONS_CLOSE_BUTTON)
236+
}
231237

232238
async isDisplayed(locator) {
233239
try {

selenium/test/pageobjects/VhostsAdminTab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const FILTER_VHOST = By.css('div#main div.filter input#filter')
99
const CHECKBOX_REGEX = By.css('div#main div.filter input#filter-regex-mode')
1010

1111
const VHOSTS_TABLE_ROWS = By.css('div#main table.list tbody tr')
12-
const TABLE_SECTION = By.css('div#main table.list')
12+
const TABLE_SECTION = By.css('div#main div#vhosts.section table.list')
1313

1414
module.exports = class VhostsAdminTab extends AdminTab {
1515
async isLoaded () {

selenium/test/utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = {
6262
}
6363
let chromeCapabilities = Capabilities.chrome();
6464
const options = new chrome.Options()
65-
chromeCapabilities.setAcceptInsecureCerts(true);
65+
chromeCapabilities.setAcceptInsecureCerts(true);
6666
chromeCapabilities.set('goog:chromeOptions', {
6767
excludeSwitches: [ // disable info bar
6868
'enable-automation',
@@ -71,7 +71,8 @@ module.exports = {
7171
'profile.password_manager_enabled' : false
7272
},
7373
args: [
74-
"--guest",
74+
"--enable-automation",
75+
"guest",
7576
"disable-infobars",
7677
"--disable-notifications",
7778
"--lang=en",
@@ -87,7 +88,7 @@ module.exports = {
8788
});
8889
driver = builder
8990
.forBrowser('chrome')
90-
.setChromeOptions(options.excludeSwitches('enable-automation'))
91+
//.setChromeOptions(options.excludeSwitches("disable-popup-blocking", "enable-automation"))
9192
.withCapabilities(chromeCapabilities)
9293
.build()
9394
driver.manage().setTimeouts( { pageLoad: 35000 } )

selenium/test/vhosts/admin-vhosts.js

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { By, Key, until, Builder } = require('selenium-webdriver')
22
require('chromedriver')
33
const assert = require('assert')
4-
const { buildDriver, goToHome, captureScreensFor, teardown, doWhile, log } = require('../utils')
4+
const { buildDriver, goToHome, captureScreensFor, teardown, doWhile, log, delay } = require('../utils')
55
const { getManagementUrl, createVhost, deleteVhost } = require('../mgt-api')
66

77
const LoginPage = require('../pageobjects/LoginPage')
@@ -51,15 +51,51 @@ describe('Virtual Hosts in Admin tab', function () {
5151
await overview.clickOnOverviewTab()
5252
await overview.clickOnAdminTab()
5353
await adminTab.clickOnVhosts()
54+
await doWhile(async function() { return vhostsTab.getVhostsTable() },
55+
function(table) { return table.length>1 })
56+
5457
await vhostsTab.clickOnSelectTableColumns()
5558
let table = await vhostsTab.getSelectableTableColumns()
56-
log("Table: " + table)
57-
await doWhile(async function() {
58-
return vhostsTab.getVhostsTable()
59-
}, function(table) {
60-
return table.length > 0 && vhost.localeCompare(table[0][0])
61-
})
59+
60+
assert.equal(4, table.length)
61+
let overviewGroup = {
62+
"name" : "Overview:",
63+
"columns": [
64+
{"name:":"Default queue type","id":"checkbox-vhosts-default-queue-type"},
65+
{"name:":"Cluster state","id":"checkbox-vhosts-cluster-state"},
66+
{"name:":"Description","id":"checkbox-vhosts-description"},
67+
{"name:":"Tags","id":"checkbox-vhosts-tags"}
68+
]
69+
}
70+
assert.equal(JSON.stringify(table[0]), JSON.stringify(overviewGroup))
71+
let messagesGroup = {
72+
"name" : "Messages:",
73+
"columns": [
74+
{"name:":"Ready","id":"checkbox-vhosts-msgs-ready"},
75+
{"name:":"Unacknowledged","id":"checkbox-vhosts-msgs-unacked"},
76+
{"name:":"Total","id":"checkbox-vhosts-msgs-total"}
77+
]
78+
}
79+
assert.equal(JSON.stringify(table[1]), JSON.stringify(messagesGroup))
80+
let networkGroup = {
81+
"name" : "Network:",
82+
"columns": [
83+
{"name:":"From client","id":"checkbox-vhosts-from_client"},
84+
{"name:":"To client","id":"checkbox-vhosts-to_client"}
85+
]
86+
}
87+
assert.equal(JSON.stringify(table[2]), JSON.stringify(networkGroup))
88+
let messageRatesGroup = {
89+
"name" : "Message rates:",
90+
"columns": [
91+
{"name:":"publish","id":"checkbox-vhosts-rate-publish"},
92+
{"name:":"deliver / get","id":"checkbox-vhosts-rate-deliver"}
93+
]
94+
}
95+
assert.equal(JSON.stringify(table[3]), JSON.stringify(messageRatesGroup))
96+
6297
})
98+
6399
describe('given there is a new virtualhost with a tag', async function() {
64100
let vhost = "test_" + Math.floor(Math.random() * 1000)
65101
before(async function() {
@@ -70,23 +106,27 @@ describe('Virtual Hosts in Admin tab', function () {
70106
await adminTab.clickOnVhosts()
71107
})
72108
it('vhost is listed with tag', async function () {
73-
log("Searching for vhost")
74-
await vhostsTab.searchForVhosts(vhost)
75-
await vhostsTab.clickOnSelectTableColumns()
76-
let table = vhostsTab.getSelectableTableColumns()
77-
log("Table: " + table)
78-
await doWhile(async function() {
79-
return vhostsTab.getVhostsTable()
80-
}, function(table) {
81-
return table.length > 0 && vhost.localeCompare(table[0][0])
109+
log("Searching for vhost " + vhost)
110+
await doWhile(async function() { return vhostsTab.searchForVhosts(vhost) },
111+
function(table) {
112+
return table.length==1 && table[1][0].localeCompare(vhost)
113+
})
114+
log("Found vhost " + vhost)
115+
await vhostsTab.selectTableColumnsById(["checkbox-vhosts-tags"])
116+
117+
await doWhile(async function() { return vhostsTab.getVhostsTable() },
118+
function(table) {
119+
return table.length==1 && table[1][3].localeCompare("selenium-tag")
82120
})
121+
83122
})
84123
after(async function () {
85124
log("Deleting vhost")
86125
deleteVhost(getManagementUrl(), vhost)
87126
})
88127

89128
})
129+
90130

91131
after(async function () {
92132
await teardown(driver, this, captureScreen)

0 commit comments

Comments
 (0)