@@ -8,11 +8,19 @@ export class Sidebar {
88 private documentationButton : Locator ;
99 private accountButton : Locator ;
1010 private collapseButton : Locator ;
11+ private drawer : Locator ;
12+ private drawerMenu : Locator ;
13+ private experimentsSection : Locator ;
1114
1215 constructor ( page : Page ) {
1316 this . sidebarContainer = page . locator ( '.gn-aside-header__aside-content' ) ;
1417 this . logoButton = this . sidebarContainer . locator ( '.gn-logo__btn-logo' ) ;
1518 this . footer = this . sidebarContainer . locator ( '.gn-aside-header__footer' ) ;
19+ this . drawer = page . locator ( '.gn-drawer' ) ;
20+ this . drawerMenu = page . locator ( '.gn-settings-menu' ) ;
21+ this . experimentsSection = this . drawerMenu
22+ . locator ( '.gn-settings-menu__item' )
23+ . filter ( { hasText : 'Experiments' } ) ;
1624
1725 // Footer buttons with specific icons
1826 const footerItems = this . sidebarContainer . locator ( '.gn-footer-item' ) ;
@@ -94,4 +102,41 @@ export class Sidebar {
94102 const item = items . nth ( index ) ;
95103 return item . locator ( '.gn-composite-bar-item__title-text' ) . innerText ( ) ;
96104 }
105+
106+ async isDrawerVisible ( ) {
107+ return this . drawer . isVisible ( ) ;
108+ }
109+
110+ async getDrawerMenuItems ( ) : Promise < string [ ] > {
111+ const items = this . drawerMenu . locator ( '.gn-settings-menu__item >> span' ) ;
112+ const count = await items . count ( ) ;
113+ const texts : string [ ] = [ ] ;
114+ for ( let i = 0 ; i < count ; i ++ ) {
115+ texts . push ( await items . nth ( i ) . innerText ( ) ) ;
116+ }
117+ return texts ;
118+ }
119+
120+ async clickExperimentsSection ( ) {
121+ await this . experimentsSection . click ( ) ;
122+ }
123+
124+ async toggleExperimentByTitle ( title : string ) {
125+ const experimentItem = this . drawer
126+ . locator ( '.gn-settings__item-title' )
127+ . filter ( { hasText : title } ) ;
128+ // Click the label element which wraps the switch, avoiding the slider that intercepts events
129+ const switchLabel = experimentItem . locator (
130+ 'xpath=../../..//label[contains(@class, "g-control-label")]' ,
131+ ) ;
132+ await switchLabel . click ( ) ;
133+ }
134+
135+ async isExperimentEnabled ( title : string ) : Promise < boolean > {
136+ const experimentItem = this . drawer
137+ . locator ( '.gn-settings__item-title' )
138+ . filter ( { hasText : title } ) ;
139+ const switchControl = experimentItem . locator ( 'xpath=../../..//input[@type="checkbox"]' ) ;
140+ return switchControl . isChecked ( ) ;
141+ }
97142}
0 commit comments