1
1
import type { Locator , Page } from '@playwright/test' ;
2
2
3
+ import { VISIBILITY_TIMEOUT } from '../tenant/TenantPage' ;
4
+
3
5
export class PaginatedTable {
4
6
private page : Page ;
5
7
private tableSelector : Locator ;
@@ -11,6 +13,8 @@ export class PaginatedTable {
11
13
private refreshButton : Locator ;
12
14
private refreshIntervalSelect : Locator ;
13
15
private headCells : Locator ;
16
+ private columnSetupButton : Locator ;
17
+ private columnSetupPopup : Locator ;
14
18
15
19
constructor ( page : Page ) {
16
20
this . page = page ;
@@ -23,6 +27,14 @@ export class PaginatedTable {
23
27
this . emptyTableRows = this . tableSelector . locator ( '.ydb-paginated-table__row_empty' ) ;
24
28
this . refreshButton = page . locator ( '.auto-refresh-control button[aria-label="Refresh"]' ) ;
25
29
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 } ) ;
26
38
}
27
39
28
40
async search ( searchTerm : string ) {
@@ -119,6 +131,48 @@ export class PaginatedTable {
119
131
await this . waitForTableData ( ) ;
120
132
}
121
133
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
+
122
176
private async getColumnIndex ( columnName : string ) : Promise < number > {
123
177
const count = await this . headCells . count ( ) ;
124
178
for ( let i = 0 ; i < count ; i ++ ) {
0 commit comments