Skip to content

Commit dbcc379

Browse files
michaelklishinmergify[bot]
authored andcommitted
Better Selenium suite coverage for #16916
(cherry picked from commit 00b9e87)
1 parent fe3c41c commit dbcc379

5 files changed

Lines changed: 76 additions & 20 deletions

File tree

selenium/bin/components/rabbitmq

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ start_docker_cluster_rabbitmq() {
111111
${BIN_DIR}/gen-advanced-config "${PROFILES}" ${RABBITMQ_CONFIG_DIR} $ENV_FILE $CONF_DIR/rabbitmq/advanced.config
112112
RESULT=$?
113113
if [ $RESULT -eq 0 ]; then
114-
if [ -s $RESULT ]; then
114+
if [ -s $CONF_DIR/rabbitmq/advanced.config ]; then
115115
print "> EFFECTIVE ADVANCED_CONFIG_FILE: $CONF_DIR/rabbitmq/advanced.config"
116116
else
117117
rm $CONF_DIR/rabbitmq/advanced.config
@@ -163,7 +163,7 @@ start_docker_rabbitmq() {
163163
${BIN_DIR}/gen-advanced-config "${PROFILES}" ${RABBITMQ_CONFIG_DIR} $ENV_FILE $CONF_DIR/rabbitmq/advanced.config
164164
RESULT=$?
165165
if [ $RESULT -eq 0 ]; then
166-
if [ -s $RESULT ]; then
166+
if [ -s $CONF_DIR/rabbitmq/advanced.config ]; then
167167
print "> EFFECTIVE ADVANCED_CONFIG_FILE: $CONF_DIR/rabbitmq/advanced.config"
168168
else
169169
rm $CONF_DIR/rabbitmq/advanced.config

selenium/suites/mgt/feature-flags.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
44

55
TEST_CASES_PATH=/feature-flags
66
TEST_CONFIG_PATH=/basic-auth
7+
PROFILES="ff-disabled"
78

89
source $SCRIPT/../../bin/suite_template $@
910
run
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{rabbit, [
3+
%% Enable every feature flag on boot except these two stable ones, so that
4+
%% the feature flags page renders its "enable" affordances.
5+
{forced_feature_flags_on_init,
6+
{rel, [], [track_qq_members_uids, tie_binding_to_dest_with_keep_while_cond]}}
7+
]}
8+
].

selenium/test/feature-flags/feature-flags.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const OverviewPage = require('../pageobjects/OverviewPage')
88
const AdminTab = require('../pageobjects/AdminTab')
99
const FeatureFlagsAdminTab = require('../pageobjects/FeatureFlagsAdminTab')
1010

11+
// Both flags are stable and left disabled on boot by the suite's advanced.config.
12+
// Enabling a feature flag cannot be undone, so each test case needs its own.
13+
const TOGGLED_FEATURE_FLAG = 'track_qq_members_uids'
14+
const ENABLED_VIA_BUTTON_FEATURE_FLAG = 'tie_binding_to_dest_with_keep_while_cond'
15+
1116
describe('Feature flags in Admin tab', function () {
1217
let driver
1318
let login
@@ -29,15 +34,33 @@ describe('Feature flags in Admin tab', function () {
2934
throw new Error('Failed to login')
3035
}
3136
await overview.selectRefreshOption("Do not refresh")
37+
await overview.clickOnAdminTab()
38+
await adminTab.clickOnFeatureFlags()
3239
})
3340

3441
it('it has at least one feature flag', async function () {
35-
await overview.clickOnAdminTab()
36-
await adminTab.clickOnFeatureFlags()
3742
let ffTable = await ffTab.getAll()
3843
assert(ffTable.length > 0)
3944
})
4045

46+
it('it warns about disabled stable feature flags', async function () {
47+
assert(await ffTab.isDisabledStableWarningDisplayed())
48+
assert(await ffTab.isEnableAllStableFeatureFlagsEnabled())
49+
})
50+
51+
it('it enables a stable feature flag from its toggle', async function () {
52+
assert(!await (await ffTab.getState(TOGGLED_FEATURE_FLAG)).isSelected())
53+
await ffTab.enable(TOGGLED_FEATURE_FLAG)
54+
await ffTab.waitUntilEnabled(TOGGLED_FEATURE_FLAG)
55+
})
56+
57+
it('it enables the remaining stable feature flags from the warning button', async function () {
58+
assert(!await (await ffTab.getState(ENABLED_VIA_BUTTON_FEATURE_FLAG)).isSelected())
59+
await ffTab.clickOnEnableAllStableFeatureFlags()
60+
await ffTab.waitUntilEnabled(ENABLED_VIA_BUTTON_FEATURE_FLAG)
61+
assert(await ffTab.isDisabledStableWarningNotDisplayed())
62+
})
63+
4164
after(async function () {
4265
await teardown(driver, this, captureScreen)
4366
})

selenium/test/pageobjects/FeatureFlagsAdminTab.js

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ const AdminTab = require('./AdminTab')
77
const FEATURE_FLAGS_SECTION = By.css('div#main div#feature-flags')
88
const FEATURE_FLAGS_TABLE = By.css('div#main div#feature-flags div#ff-table-section table')
99

10-
const ACCEPT_ENABLE_EXPERIMENTAL_FEATURE_FLAG = By.css('p#ff-exp-ack-supported')
10+
const DISABLED_STABLE_WARNING = By.css('div#ff-disabled-stable-warning')
11+
const ENABLE_ALL_STABLE_BUTTON = By.css('button#ff-enable-all-button')
12+
13+
const ACCEPT_ENABLE_EXPERIMENTAL_FEATURE_FLAG = By.css('input#ff-exp-ack-supported-checkbox')
1114
const CONFIRM_ENABLE_EXPERIMENTAL_FEATURE_FLAG = By.css('button#ff-exp-confirm')
1215

1316

@@ -26,32 +29,53 @@ module.exports = class FeatureFlagsAdminTab extends AdminTab {
2629
}
2730
}
2831

29-
async enable(name, isExperimental = false) {
32+
async enable(name, isExperimental = false) {
3033
let state = await this.getState(name)
3134
if (!await state.isSelected()) {
32-
await this.driver.findElement(this.getParentCheckboxLocator(name)).click()
35+
await this.click(this.getToggleLocator(name))
3336
if (isExperimental) {
34-
await delay(1000)
3537
const dialog = await this.driver.wait(
36-
until.elementLocated(By.css('dialog#ff-exp-dialog[open]')),
37-
10000 // 10 seconds timeout
38-
)
38+
until.elementLocated(By.css('dialog#ff-exp-dialog[open]')), this.timeout)
3939
await dialog.findElement(ACCEPT_ENABLE_EXPERIMENTAL_FEATURE_FLAG).click()
40-
await dialog.findElement(CONFIRM_ENABLE_EXPERIMENTAL_FEATURE_FLAG).click()
41-
return delay(1000)
42-
}else {
43-
return Promise.resolve()
40+
await dialog.findElement(CONFIRM_ENABLE_EXPERIMENTAL_FEATURE_FLAG).click()
4441
}
45-
}else {
46-
return Promise.resolve()
4742
}
4843
}
44+
45+
async clickOnEnableAllStableFeatureFlags() {
46+
return this.click(ENABLE_ALL_STABLE_BUTTON)
47+
}
48+
49+
async isDisabledStableWarningDisplayed() {
50+
return this.isDisplayed(DISABLED_STABLE_WARNING)
51+
}
52+
53+
async isDisabledStableWarningNotDisplayed() {
54+
return this.isElementNotVisible(DISABLED_STABLE_WARNING)
55+
}
56+
57+
async isEnableAllStableFeatureFlagsEnabled() {
58+
const button = await this.waitForDisplayed(ENABLE_ALL_STABLE_BUTTON)
59+
return button.isEnabled()
60+
}
61+
62+
async waitUntilEnabled(name) {
63+
const checkbox = await this.driver.findElement(this.getCheckboxLocator(name))
64+
return this.driver.wait(until.elementIsSelected(checkbox), this.timeout,
65+
'Timed out waiting for feature flag ' + name + ' to become enabled', this.polling)
66+
}
67+
68+
// Feature flag names may contain dots, e.g. rabbitmq_4.3.0, which a CSS id
69+
// selector would read as a class. Hence the attribute selectors below.
4970
getCheckboxLocator(name) {
50-
return By.css('div#ff-table-section table input#ff-checkbox-' + name)
71+
return By.css('div#ff-table-section table input[id="ff-checkbox-' + name + '"]')
5172
}
52-
getParentCheckboxLocator(name) {
53-
return By.css('div#ff-table-section table td#ff-td-' + name)
73+
74+
// The checkbox itself is display:none, so the toggle label is what a user clicks.
75+
getToggleLocator(name) {
76+
return By.css('div#ff-table-section table label[for="ff-checkbox-' + name + '"]')
5477
}
78+
5579
async getState(name) {
5680
return this.driver.findElement(this.getCheckboxLocator(name))
5781
}

0 commit comments

Comments
 (0)