Skip to content

Commit 3855983

Browse files
MarcialRosalesmergify[bot]
authored andcommitted
Select columns of vhosts
(cherry picked from commit 7003fef)
1 parent 4231ea7 commit 3855983

File tree

5 files changed

+61
-21
lines changed

5 files changed

+61
-21
lines changed

deps/rabbitmq_management/priv/www/js/tmpl/popup.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
<%= text %>
33
<br/>
44
<br/>
5-
<span>Close</span>
5+
<span id="close">Close</span>
66
</div>

selenium/test/pageobjects/BasePage.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ 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

1616
const FORM_POPUP = By.css('div.form-popup-warn')
17-
const FORM_POPUP_CLOSE_BUTTON = By.css('div.form-popup-warn span')
17+
const FORM_POPUP_CLOSE_BUTTON = By.css('div.form-popup-warn span#close')
18+
19+
const ADD_MINUS_BUTTON = By.css('div#main table.list thead tr th.plus-minus')
20+
const TABLE_COLUMNS_POPUP = By.css('div.form-popup-options table.form')
1821

1922
module.exports = class BasePage {
2023
driver
@@ -136,6 +139,7 @@ module.exports = class BasePage {
136139
}
137140

138141

142+
139143
async getTable(tableLocator, firstNColumns, rowClass) {
140144
const table = await this.waitForDisplayed(tableLocator)
141145
const rows = await table.findElements(rowClass == undefined ?
@@ -199,6 +203,32 @@ module.exports = class BasePage {
199203
async closePopupWarning() {
200204
return this.click(FORM_POPUP_CLOSE_BUTTON)
201205
}
206+
async clickOnSelectTableColumns() {
207+
return this.click(ADD_MINUS_BUTTON)
208+
}
209+
async getSelectableTableColumns() {
210+
const table = await this.waitForDisplayed(TABLE_COLUMNS_POPUP)
211+
const rows = await table.findElements(By.css('tbody tr'))
212+
let table_model = []
213+
console.log("Found "+ rows.length + " rows")
214+
for (let i = 1; i < rows.length; i++) { // skip first row
215+
let groupNameLabel = await rows[i].findElement(By.css('th label'))
216+
let groupName = await groupNameLabel.getText()
217+
console.log("Found group "+ groupName )
218+
let columns = await rows[i].findElements(By.css('td label'))
219+
let table_row = []
220+
console.log("Found "+ columns.length + " columns")
221+
for (let column of columns) {
222+
let checkbox = await column.findElement(By.css('input'))
223+
table_row.push({"name:" : await column.getText(), "id" : await checkbox.getAttribute("id")})
224+
}
225+
let group = {"name": groupName, "columns": table_row}
226+
console.log("Add group " + group)
227+
table_model.push(group)
228+
}
229+
return table_model
230+
}
231+
202232
async isDisplayed(locator) {
203233
try {
204234
let element = await driver.findElement(locator)

selenium/test/pageobjects/VhostsAdminTab.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ 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')
1212
const TABLE_SECTION = By.css('div#main table.list')
13-
const ADD_MINUS_BUTTON = By.css('div#main table.list thead tr th.plus-minus')
14-
15-
const TABLE_COLUMNS_POPUP = By.css('div.form-popup-options')
1613

1714
module.exports = class VhostsAdminTab extends AdminTab {
1815
async isLoaded () {
@@ -41,10 +38,5 @@ module.exports = class VhostsAdminTab extends AdminTab {
4138
async getVhostsTable(firstNColumns) {
4239
return this.getTable(TABLE_SECTION, firstNColumns)
4340
}
44-
async clickOnSelectColumns() {
45-
return this.click(ADD_MINUS_BUTTON)
46-
}
47-
async getSelectableTableColumns() {
48-
return this.waitForDisplayed(TABLE_COLUMNS_POPUP)
49-
}
41+
5042
}

selenium/test/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ module.exports = {
6868
'enable-automation',
6969
],
7070
prefs: {
71-
'profile.managed_default_content_settings.popups' : 2,
72-
'profile.managed_default_content_settings.notifications' : 2,
71+
'profile.password_manager_enabled' : false
7372
},
7473
args: [
74+
"--guest",
7575
"disable-infobars",
7676
"--disable-notifications",
7777
"--lang=en",

selenium/test/vhosts/admin-vhosts.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Virtual Hosts in Admin tab', function () {
2929
if (!await overview.isLoaded()) {
3030
throw new Error('Failed to login')
3131
}
32-
32+
await overview.selectRefreshOption("Do not refresh")
3333
})
3434

3535
it('find default vhost', async function () {
@@ -38,6 +38,7 @@ describe('Virtual Hosts in Admin tab', function () {
3838
assert.equal(true, await vhostsTab.hasVhosts("/"))
3939
})
4040
it('find default vhost and view it', async function () {
41+
await overview.clickOnOverviewTab()
4142
await overview.clickOnAdminTab()
4243
await adminTab.clickOnVhosts()
4344
await vhostsTab.clickOnVhost(await vhostsTab.searchForVhosts("/"), "/")
@@ -46,25 +47,42 @@ describe('Virtual Hosts in Admin tab', function () {
4647
}
4748
assert.equal("/", await vhostTab.getName())
4849
})
49-
50+
it('vhost selectable columns', async function () {
51+
await overview.clickOnOverviewTab()
52+
await overview.clickOnAdminTab()
53+
await adminTab.clickOnVhosts()
54+
await vhostsTab.clickOnSelectTableColumns()
55+
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+
})
62+
})
5063
describe('given there is a new virtualhost with a tag', async function() {
5164
let vhost = "test_" + Math.floor(Math.random() * 1000)
5265
before(async function() {
66+
log("Creating vhost")
5367
createVhost(getManagementUrl(), vhost, "selenium", "selenium-tag")
68+
await overview.clickOnOverviewTab()
5469
await overview.clickOnAdminTab()
55-
await adminTab.clickOnVhosts()
70+
await adminTab.clickOnVhosts()
5671
})
57-
it('vhost is listed', async function () {
58-
await vhostsTab.searchForVhosts(vhost)
72+
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)
5978
await doWhile(async function() {
6079
return vhostsTab.getVhostsTable()
6180
}, function(table) {
62-
return table.length > 0 && vhost.localeCompare(table[0][0])
81+
return table.length > 0 && vhost.localeCompare(table[0][0])
6382
})
64-
await vhostsTab.clickOnSelectColumns()
65-
await vhostsTab.getSelectableTableColumns()
6683
})
6784
after(async function () {
85+
log("Deleting vhost")
6886
deleteVhost(getManagementUrl(), vhost)
6987
})
7088

0 commit comments

Comments
 (0)