11import type { Locator , Page } from '@playwright/test' ;
22
3+ import type {
4+ QUERY_MODES ,
5+ STATISTICS_MODES ,
6+ TRANSACTION_MODES ,
7+ } from '../../../../../src/utils/query' ;
38import { VISIBILITY_TIMEOUT } from '../../TenantPage' ;
49
5- import type { ButtonNames , QueryMode } from './QueryEditor' ;
10+ import type { ButtonNames } from './QueryEditor' ;
611
712export class SettingsDialog {
813 private dialog : Locator ;
914 private page : Page ;
15+ private selectPopup : Locator ;
16+ private limitRowsInput : Locator ;
17+
18+ private queryModeSelect : Locator ;
19+ private transactionModeSelect : Locator ;
20+ private statisticsModeSelect : Locator ;
21+ private statisticsModeTooltip : Locator ;
1022
1123 constructor ( page : Page ) {
1224 this . page = page ;
1325 this . dialog = page . locator ( '.ydb-query-settings-dialog' ) ;
14- }
1526
16- async changeQueryMode ( mode : QueryMode ) {
17- const dropdown = this . dialog . locator (
27+ this . limitRowsInput = this . dialog . locator ( '.ydb-query-settings-dialog__limit-rows input' ) ;
28+ this . selectPopup = page . locator ( '.ydb-query-settings-select__popup' ) ;
29+
30+ // Define distinct locators for selects
31+ this . queryModeSelect = this . dialog . locator (
1832 '.ydb-query-settings-dialog__control-wrapper_queryMode' ,
1933 ) ;
20- await dropdown . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
21- await dropdown . click ( ) ;
22- const popup = this . page . locator ( '.ydb-query-settings-select__popup' ) ;
23- await popup . getByText ( mode ) . first ( ) . click ( ) ;
34+ this . transactionModeSelect = this . dialog . locator (
35+ '.ydb-query-settings-dialog__control-wrapper_transactionMode' ,
36+ ) ;
37+ this . statisticsModeSelect = this . dialog . locator (
38+ '.ydb-query-settings-dialog__control-wrapper_statisticsMode' ,
39+ ) ;
40+ this . statisticsModeTooltip = this . page . locator (
41+ '.ydb-query-settings-dialog__statistics-mode-tooltip' ,
42+ ) ;
43+ }
44+
45+ async changeQueryMode ( mode : ( typeof QUERY_MODES ) [ keyof typeof QUERY_MODES ] ) {
46+ await this . queryModeSelect . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
47+ await this . queryModeSelect . click ( ) ;
48+ await this . selectPopup . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
49+ await this . page . locator ( `.ydb-query-settings-select__item_type_${ mode } ` ) . click ( ) ;
2450 await this . page . waitForTimeout ( 1000 ) ;
2551 }
2652
27- async changeTransactionMode ( level : string ) {
28- const dropdown = this . dialog . locator (
29- '.ydb-query-settings-dialog__control-wrapper_transactionMode' ,
30- ) ;
31- await dropdown . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
32- await dropdown . click ( ) ;
33- const popup = this . page . locator ( '.ydb-query-settings-select__popup' ) ;
34- await popup . getByText ( level ) . first ( ) . click ( ) ;
53+ async changeTransactionMode ( level : ( typeof TRANSACTION_MODES ) [ keyof typeof TRANSACTION_MODES ] ) {
54+ await this . transactionModeSelect . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
55+ await this . transactionModeSelect . click ( ) ;
56+ await this . selectPopup . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
57+ await this . page . locator ( `.ydb-query-settings-select__item_type_${ level } ` ) . click ( ) ;
3558 await this . page . waitForTimeout ( 1000 ) ;
3659 }
3760
38- async changeStatsLevel ( mode : string ) {
39- const dropdown = this . dialog . locator (
40- '.ydb-query-settings-dialog__control-wrapper_statisticsMode' ,
41- ) ;
42- await dropdown . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
43- await dropdown . click ( ) ;
44- const popup = this . page . locator ( '.ydb-query-settings-select__popup' ) ;
45- await popup . getByText ( mode ) . first ( ) . click ( ) ;
61+ async changeStatsLevel ( mode : ( typeof STATISTICS_MODES ) [ keyof typeof STATISTICS_MODES ] ) {
62+ await this . statisticsModeSelect . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
63+ await this . statisticsModeSelect . click ( ) ;
64+ await this . selectPopup . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
65+ await this . page . locator ( `.ydb-query-settings-select__item_type_${ mode } ` ) . click ( ) ;
4666 await this . page . waitForTimeout ( 1000 ) ;
4767 }
4868
69+ async getStatsLevel ( ) {
70+ await this . statisticsModeSelect . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
71+ const selectedText = await this . statisticsModeSelect
72+ . locator ( '.g-select-control__option-text' )
73+ . textContent ( ) ;
74+ return selectedText ;
75+ }
76+
4977 async changeLimitRows ( limitRows : number ) {
50- const limitRowsInput = this . dialog . locator ( '.ydb-query-settings-dialog__limit-rows input' ) ;
51- await limitRowsInput . fill ( limitRows . toString ( ) ) ;
78+ await this . limitRowsInput . fill ( limitRows . toString ( ) ) ;
5279 await this . page . waitForTimeout ( 1000 ) ;
5380 }
5481
@@ -63,8 +90,23 @@ export class SettingsDialog {
6390 return true ;
6491 }
6592
93+ async isStatsTooltipVisible ( ) {
94+ await this . statisticsModeTooltip . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
95+ return true ;
96+ }
97+
6698 async isHidden ( ) {
6799 await this . dialog . waitFor ( { state : 'hidden' , timeout : VISIBILITY_TIMEOUT } ) ;
68100 return true ;
69101 }
102+
103+ async isStatisticsSelectDisabled ( ) {
104+ await this . statisticsModeSelect . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
105+ return this . statisticsModeSelect . locator ( '.g-select-control_disabled' ) . isVisible ( ) ;
106+ }
107+
108+ async hoverStatisticsSelect ( ) {
109+ await this . statisticsModeSelect . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
110+ await this . statisticsModeSelect . hover ( ) ;
111+ }
70112}
0 commit comments