@@ -7,7 +7,10 @@ const AdminTab = require('./AdminTab')
77const FEATURE_FLAGS_SECTION = By . css ( 'div#main div#feature-flags' )
88const 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' )
1114const 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