11import type { Locator , Page } from '@playwright/test' ;
22
3- export const VISIBILITY_TIMEOUT = 5000 ;
3+ import { VISIBILITY_TIMEOUT } from '../TenantPage' ;
44
55export enum QueryMode {
66 YQLScript = 'YQL Script' ,
@@ -22,6 +22,46 @@ export enum ButtonNames {
2222 Stop = 'Stop' ,
2323}
2424
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+
2565export class SettingsDialog {
2666 private dialog : Locator ;
2767 private page : Page ;
@@ -81,6 +121,22 @@ export class SettingsDialog {
81121 }
82122}
83123
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+
84140export class ResultTable {
85141 private table : Locator ;
86142 private preview : Locator ;
@@ -123,8 +179,10 @@ export class ResultTable {
123179
124180export class QueryEditor {
125181 settingsDialog : SettingsDialog ;
182+ paneWrapper : PaneWrapper ;
183+ queryTabs : QueryTabsNavigation ;
184+ resultTable : ResultTable ;
126185
127- private resultTable : ResultTable ;
128186 private page : Page ;
129187 private selector : Locator ;
130188 private editorTextArea : Locator ;
@@ -158,6 +216,8 @@ export class QueryEditor {
158216
159217 this . settingsDialog = new SettingsDialog ( page ) ;
160218 this . resultTable = new ResultTable ( this . selector ) ;
219+ this . paneWrapper = new PaneWrapper ( page ) ;
220+ this . queryTabs = new QueryTabsNavigation ( page ) ;
161221 }
162222
163223 async run ( query : string , mode : QueryMode ) {
@@ -265,22 +325,6 @@ export class QueryEditor {
265325 return true ;
266326 }
267327
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-
284328 async isStopButtonVisible ( ) {
285329 await this . stopButton . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
286330 return true ;
0 commit comments