1
1
import type { Locator , Page } from '@playwright/test' ;
2
2
3
- export const VISIBILITY_TIMEOUT = 5000 ;
3
+ import { VISIBILITY_TIMEOUT } from '../TenantPage' ;
4
4
5
5
export enum QueryMode {
6
6
YQLScript = 'YQL Script' ,
@@ -22,6 +22,46 @@ export enum ButtonNames {
22
22
Stop = 'Stop' ,
23
23
}
24
24
25
+ export enum ResultTabNames {
26
+ Result = 'Result' ,
27
+ Stats = 'Stats' ,
28
+ Schema = 'Schema' ,
29
+ ExplainPlan = 'Explain Plan' ,
30
+ }
31
+
32
+ export enum QueryTabs {
33
+ Editor = 'Editor' ,
34
+ History = 'History' ,
35
+ Saved = 'Saved' ,
36
+ }
37
+
38
+ export class QueryTabsNavigation {
39
+ private tabsContainer : Locator ;
40
+
41
+ constructor ( page : Page ) {
42
+ this . tabsContainer = page . locator ( '.ydb-query__tabs' ) ;
43
+ }
44
+
45
+ async selectTab ( tabName : QueryTabs ) {
46
+ const tab = this . tabsContainer . locator ( `role=tab[name="${ tabName } "]` ) ;
47
+ await tab . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
48
+ await tab . click ( ) ;
49
+ }
50
+
51
+ async isTabSelected ( tabName : QueryTabs ) : Promise < boolean > {
52
+ const tab = this . tabsContainer . locator ( `role=tab[name="${ tabName } "]` ) ;
53
+ await tab . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
54
+ const isSelected = await tab . getAttribute ( 'aria-selected' ) ;
55
+ return isSelected === 'true' ;
56
+ }
57
+
58
+ async getTabHref ( tabName : QueryTabs ) : Promise < string | null > {
59
+ const link = this . tabsContainer . locator ( `a:has(div[role="tab"][title="${ tabName } "])` ) ;
60
+ await link . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
61
+ return link . getAttribute ( 'href' ) ;
62
+ }
63
+ }
64
+
25
65
export class SettingsDialog {
26
66
private dialog : Locator ;
27
67
private page : Page ;
@@ -81,6 +121,22 @@ export class SettingsDialog {
81
121
}
82
122
}
83
123
124
+ class PaneWrapper {
125
+ paneWrapper : Locator ;
126
+ private radioButton : Locator ;
127
+
128
+ constructor ( page : Page ) {
129
+ this . paneWrapper = page . locator ( '.query-editor__pane-wrapper' ) ;
130
+ this . radioButton = this . paneWrapper . locator ( '.g-radio-button' ) ;
131
+ }
132
+
133
+ async selectTab ( tabName : ResultTabNames ) {
134
+ const tab = this . radioButton . getByLabel ( tabName ) ;
135
+ await tab . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
136
+ await tab . click ( ) ;
137
+ }
138
+ }
139
+
84
140
export class ResultTable {
85
141
private table : Locator ;
86
142
private preview : Locator ;
@@ -123,8 +179,10 @@ export class ResultTable {
123
179
124
180
export class QueryEditor {
125
181
settingsDialog : SettingsDialog ;
182
+ paneWrapper : PaneWrapper ;
183
+ queryTabs : QueryTabsNavigation ;
184
+ resultTable : ResultTable ;
126
185
127
- private resultTable : ResultTable ;
128
186
private page : Page ;
129
187
private selector : Locator ;
130
188
private editorTextArea : Locator ;
@@ -158,6 +216,8 @@ export class QueryEditor {
158
216
159
217
this . settingsDialog = new SettingsDialog ( page ) ;
160
218
this . resultTable = new ResultTable ( this . selector ) ;
219
+ this . paneWrapper = new PaneWrapper ( page ) ;
220
+ this . queryTabs = new QueryTabsNavigation ( page ) ;
161
221
}
162
222
163
223
async run ( query : string , mode : QueryMode ) {
@@ -265,22 +325,6 @@ export class QueryEditor {
265
325
return true ;
266
326
}
267
327
268
- async isResultTableVisible ( ) {
269
- return await this . resultTable . isVisible ( ) ;
270
- }
271
-
272
- async isResultTableHidden ( ) {
273
- return await this . resultTable . isHidden ( ) ;
274
- }
275
-
276
- async isPreviewVisible ( ) {
277
- return await this . resultTable . isPreviewVisible ( ) ;
278
- }
279
-
280
- async isPreviewHidden ( ) {
281
- return await this . resultTable . isPreviewHidden ( ) ;
282
- }
283
-
284
328
async isStopButtonVisible ( ) {
285
329
await this . stopButton . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
286
330
return true ;
0 commit comments