Skip to content

Commit f053fd2

Browse files
Fix test cases
1 parent 20aa1bc commit f053fd2

File tree

3 files changed

+38
-24
lines changed

3 files changed

+38
-24
lines changed

deps/rabbitmq_management/selenium/test/basic-auth/unauthorized.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const { By, Key, until, Builder } = require('selenium-webdriver')
22
require('chromedriver')
33
const assert = require('assert')
4-
const { buildDriver, goToHome, captureScreensFor, teardown, idpLoginPage } = require('../utils')
4+
const { buildDriver, goToHome, captureScreensFor, teardown, delay } = require('../utils')
55

6-
const SSOHomePage = require('../pageobjects/SSOHomePage')
6+
const LoginPage = require('../pageobjects/LoginPage')
77
const OverviewPage = require('../pageobjects/OverviewPage')
88

99
describe('An user without management tag', function () {
@@ -15,38 +15,38 @@ describe('An user without management tag', function () {
1515
before(async function () {
1616
driver = buildDriver()
1717
await goToHome(driver)
18-
homePage = new SSOHomePage(driver)
19-
idpLogin = idpLoginPage(driver)
18+
login = new LoginPage(driver)
2019
overview = new OverviewPage(driver)
2120
captureScreen = captureScreensFor(driver, __filename)
2221

23-
await homePage.clickToLogin()
24-
await idpLogin.login('rabbit_no_management', 'rabbit_no_management')
25-
if (!await homePage.isLoaded()) {
26-
throw new Error('Failed to login')
27-
}
22+
assert.ok(!await login.isPopupWarningDisplayed())
23+
await login.login('rabbit_no_management', 'rabbit_no_management')
24+
await !overview.isLoaded()
2825
})
2926

3027
it('cannot log in into the management ui', async function () {
31-
const visible = await homePage.isWarningVisible()
28+
const visible = await login.isWarningVisible()
3229
assert.ok(visible)
3330
})
3431

35-
it('should get "Not authorized" warning message', async function(){
36-
assert.equal('Not authorized', await homePage.getWarning())
37-
//assert.equal('Click here to logout', await homePage.getLogoutButton())
38-
//assert.ok(!await homePage.isBasicAuthSectionVisible())
39-
//assert.ok(!await homePage.isOAuth2SectionVisible())
32+
it('should get "Login failed" warning message', async function(){
33+
assert.equal('Login failed', await login.getWarning())
4034
})
4135

42-
describe("After clicking on logout button", function() {
36+
it('should get popup warning dialog', async function(){
37+
assert.ok(login.isPopupWarningDisplayed())
38+
assert.equal('Not_Authorized', await login.getPopupWarning())
39+
})
40+
41+
describe("After clicking on popup warning dialog button", function() {
4342

4443
before(async function () {
45-
await homePage.clickToLogout()
44+
await login.closePopupWarning()
4645
})
4746

48-
it('should get redirected to home page again without error message', async function(){
49-
const visible = await homePage.isWarningVisible()
47+
it('should close popup warning', async function(){
48+
await delay(1000)
49+
const visible = await login.isPopupWarningDisplayed()
5050
assert.ok(!visible)
5151
})
5252

deps/rabbitmq_management/selenium/test/pageobjects/BasePage.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ 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')
18+
1619
module.exports = class BasePage {
1720
driver
1821
timeout
@@ -137,25 +140,35 @@ module.exports = class BasePage {
137140
return table_model
138141
}
139142
async isPopupWarningDisplayed() {
140-
const element = "form-popup-warn"
143+
try {
144+
let element = await driver.findElement(FORM_POPUP)
145+
return element.isDisplayed()
146+
} catch(e) {
147+
return Promise.resolve(false)
148+
}
149+
/*
150+
let element = await driver.findElement(FORM_POPUP)
141151
return this.driver.wait(until.elementIsVisible(element), this.timeout / 2,
142152
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,
143153
this.polling / 2).then(function onWarningVisible(e) {
144154
return Promise.resolve(true)
145155
}, function onError(e) {
146156
return Promise.resolve(false)
147157
})
158+
*/
148159
}
149160
async getPopupWarning() {
150-
const element = "form-popup-warn"
161+
let element = await driver.findElement(FORM_POPUP)
151162
return this.driver.wait(until.elementIsVisible(element), this.timeout,
152163
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,
153-
this.polling)
164+
this.polling).getText().then((value) => value.substring(0, value.search('\n\nClose')))
165+
}
166+
async closePopupWarning() {
167+
return this.click(FORM_POPUP_CLOSE_BUTTON)
154168
}
155-
156169
async isDisplayed(locator) {
157170
try {
158-
element = await driver.findElement(locator)
171+
let element = await driver.findElement(locator)
159172

160173
return this.driver.wait(until.elementIsVisible(element), this.timeout,
161174
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,

deps/rabbitmq_management/selenium/test/pageobjects/LoginPage.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const FORM = By.css('div#login form')
66
const USERNAME = By.css('input[name="username"]')
77
const PASSWORD = By.css('input[name="password"]')
88
const LOGIN_BUTTON = By.css('div#outer div#login form input[type=submit]')
9+
const WARNING = By.css('div#outer div#login div#login-status p')
910

1011
module.exports = class LoginPage extends BasePage {
1112
async isLoaded () {

0 commit comments

Comments
 (0)