11import type { Locator , Page } from '@playwright/test' ;
22
3+ import { VISIBILITY_TIMEOUT } from '../tenant/TenantPage' ;
4+
35export class PaginatedTable {
46 private page : Page ;
57 private tableSelector : Locator ;
@@ -11,6 +13,8 @@ export class PaginatedTable {
1113 private refreshButton : Locator ;
1214 private refreshIntervalSelect : Locator ;
1315 private headCells : Locator ;
16+ private columnSetupButton : Locator ;
17+ private columnSetupPopup : Locator ;
1418
1519 constructor ( page : Page ) {
1620 this . page = page ;
@@ -23,6 +27,14 @@ export class PaginatedTable {
2327 this . emptyTableRows = this . tableSelector . locator ( '.ydb-paginated-table__row_empty' ) ;
2428 this . refreshButton = page . locator ( '.auto-refresh-control button[aria-label="Refresh"]' ) ;
2529 this . refreshIntervalSelect = page . getByTestId ( 'ydb-autorefresh-select' ) ;
30+ this . columnSetupButton = this . tableSelector . locator (
31+ '.g-tree-select.g-table-column-setup button' ,
32+ ) ;
33+ this . columnSetupPopup = page . locator ( '.g-popup .g-select-popup.g-tree-select__popup' ) ;
34+ }
35+
36+ async waitForTableVisible ( ) {
37+ await this . tableSelector . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
2638 }
2739
2840 async search ( searchTerm : string ) {
@@ -119,6 +131,48 @@ export class PaginatedTable {
119131 await this . waitForTableData ( ) ;
120132 }
121133
134+ async openColumnSetup ( ) {
135+ await this . columnSetupButton . click ( ) ;
136+ await this . columnSetupPopup . waitFor ( { state : 'visible' } ) ;
137+ }
138+
139+ async setColumnChecked ( columnName : string ) {
140+ const columnOption = this . columnSetupPopup . locator ( `[data-list-item="${ columnName } "]` ) ;
141+ const checkIcon = columnOption . locator ( '.g-icon.g-color-text_color_info' ) ;
142+ const isVisible = await checkIcon . isVisible ( ) ;
143+ if ( ! isVisible ) {
144+ await columnOption . click ( ) ;
145+ }
146+ }
147+
148+ async setColumnUnchecked ( columnName : string ) {
149+ const columnOption = this . columnSetupPopup . locator ( `[data-list-item="${ columnName } "]` ) ;
150+ const checkIcon = columnOption . locator ( '.g-icon.g-color-text_color_info' ) ;
151+ const isVisible = await checkIcon . isVisible ( ) ;
152+ if ( isVisible ) {
153+ await columnOption . click ( ) ;
154+ }
155+ }
156+
157+ async applyColumnVisibility ( ) {
158+ const applyButton = this . columnSetupPopup . locator ( 'button:has-text("Apply")' ) ;
159+ await applyButton . click ( ) ;
160+ await this . columnSetupPopup . waitFor ( { state : 'hidden' } ) ;
161+ }
162+
163+ async getVisibleColumnsCount ( ) : Promise < string > {
164+ const statusText = await this . columnSetupButton
165+ . locator ( '.g-table-column-setup__status' )
166+ . innerText ( ) ;
167+ return statusText ;
168+ }
169+
170+ async isColumnVisible ( columnName : string ) : Promise < boolean > {
171+ const columnOption = this . columnSetupPopup . locator ( `[data-list-item="${ columnName } "]` ) ;
172+ const checkIcon = columnOption . locator ( '.g-icon.g-color-text_color_info' ) ;
173+ return await checkIcon . isVisible ( ) ;
174+ }
175+
122176 private async getColumnIndex ( columnName : string ) : Promise < number > {
123177 const count = await this . headCells . count ( ) ;
124178 for ( let i = 0 ; i < count ; i ++ ) {
0 commit comments