@@ -2,10 +2,11 @@ import type {Locator, Page} from '@playwright/test';
22
33import type { QUERY_MODES } from '../../../../../src/utils/query' ;
44import { VISIBILITY_TIMEOUT } from '../../TenantPage' ;
5+ import { QueriesHistoryTable } from '../../queryHistory/models/QueriesHistoryTable' ;
6+ import { SavedQueriesTable } from '../../savedQueries/models/SavedQueriesTable' ;
57
68import { QueryTabsNavigation } from './QueryTabsNavigation' ;
79import { PaneWrapper , ResultTable } from './ResultTable' ;
8- import { SavedQueriesTable } from './SavedQueriesTable' ;
910import { SettingsDialog } from './SettingsDialog' ;
1011
1112export enum ExplainResultType {
@@ -41,13 +42,15 @@ export class QueryEditor {
4142 queryTabs : QueryTabsNavigation ;
4243 resultTable : ResultTable ;
4344 savedQueries : SavedQueriesTable ;
45+ historyQueries : QueriesHistoryTable ;
4446 editorTextArea : Locator ;
4547
4648 private page : Page ;
4749 private selector : Locator ;
4850 private runButton : Locator ;
4951 private explainButton : Locator ;
5052 private stopButton : Locator ;
53+ private saveButton : Locator ;
5154 private gearButton : Locator ;
5255 private indicatorIcon : Locator ;
5356 private banner : Locator ;
@@ -63,6 +66,7 @@ export class QueryEditor {
6366 this . runButton = this . selector . getByRole ( 'button' , { name : ButtonNames . Run } ) ;
6467 this . stopButton = this . selector . getByRole ( 'button' , { name : ButtonNames . Stop } ) ;
6568 this . explainButton = this . selector . getByRole ( 'button' , { name : ButtonNames . Explain } ) ;
69+ this . saveButton = this . selector . getByRole ( 'button' , { name : ButtonNames . Save } ) ;
6670 this . gearButton = this . selector . locator ( '.ydb-query-editor-controls__gear-button' ) ;
6771 this . executionStatus = this . selector . locator ( '.kv-query-execution-status' ) ;
6872 this . resultsControls = this . selector . locator ( '.ydb-query-result__controls' ) ;
@@ -78,6 +82,7 @@ export class QueryEditor {
7882 this . paneWrapper = new PaneWrapper ( page ) ;
7983 this . queryTabs = new QueryTabsNavigation ( page ) ;
8084 this . savedQueries = new SavedQueriesTable ( page ) ;
85+ this . historyQueries = new QueriesHistoryTable ( page ) ;
8186 }
8287
8388 async run ( query : string , mode : keyof typeof QUERY_MODES ) {
@@ -116,6 +121,11 @@ export class QueryEditor {
116121 await this . explainButton . click ( ) ;
117122 }
118123
124+ async clickSaveButton ( ) {
125+ await this . saveButton . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
126+ await this . saveButton . click ( ) ;
127+ }
128+
119129 async getExplainResult ( type : ExplainResultType ) {
120130 await this . selectResultTypeRadio ( type ) ;
121131 const resultArea = this . selector . locator ( '.ydb-query-result__result' ) ;
@@ -144,6 +154,37 @@ export class QueryEditor {
144154 await this . editorTextArea . focus ( ) ;
145155 }
146156
157+ async selectText ( startLine : number , startColumn : number , endLine : number , endColumn : number ) {
158+ await this . editorTextArea . evaluate (
159+ ( _ , coords ) => {
160+ const editor = window . ydbEditor ;
161+ if ( editor ) {
162+ editor . setSelection ( {
163+ startLineNumber : coords . startLine ,
164+ startColumn : coords . startColumn ,
165+ endLineNumber : coords . endLine ,
166+ endColumn : coords . endColumn ,
167+ } ) ;
168+ }
169+ } ,
170+ { startLine, startColumn, endLine, endColumn} ,
171+ ) ;
172+ }
173+
174+ async pressKeys ( key : string ) {
175+ await this . editorTextArea . press ( key ) ;
176+ }
177+
178+ async runSelectedQueryViaContextMenu ( ) {
179+ await this . editorTextArea . evaluate ( ( ) => {
180+ const editor = window . ydbEditor ;
181+ if ( editor ) {
182+ // Trigger the sendSelectedQuery action directly
183+ editor . trigger ( 'contextMenu' , 'sendSelectedQuery' , null ) ;
184+ }
185+ } ) ;
186+ }
187+
147188 async closeSettingsDialog ( ) {
148189 await this . settingsDialog . clickButton ( ButtonNames . Cancel ) ;
149190 }
@@ -166,6 +207,7 @@ export class QueryEditor {
166207
167208 async setQuery ( query : string ) {
168209 await this . editorTextArea . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
210+ await this . editorTextArea . clear ( ) ;
169211 await this . editorTextArea . fill ( query ) ;
170212 }
171213
@@ -205,6 +247,36 @@ export class QueryEditor {
205247 return true ;
206248 }
207249
250+ async collapseResultsControls ( ) {
251+ const collapseButton = this . resultsControls . locator (
252+ '.kv-pane-visibility-button_type_collapse' ,
253+ ) ;
254+ await collapseButton . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
255+ await collapseButton . click ( ) ;
256+ }
257+
258+ async expandResultsControls ( ) {
259+ const expandButton = this . resultsControls . locator ( '.kv-pane-visibility-button_type_expand' ) ;
260+ await expandButton . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
261+ await expandButton . click ( ) ;
262+ }
263+
264+ async isResultsControlsCollapsed ( ) {
265+ const expandButton = this . resultsControls . locator ( '.kv-pane-visibility-button_type_expand' ) ;
266+ try {
267+ await expandButton . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
268+ return true ;
269+ } catch {
270+ return false ;
271+ }
272+ }
273+
274+ async clickCopyResultButton ( ) {
275+ const copyButton = this . resultsControls . locator ( 'button[title="Copy result"]' ) ;
276+ await copyButton . waitFor ( { state : 'visible' , timeout : VISIBILITY_TIMEOUT } ) ;
277+ await copyButton . click ( ) ;
278+ }
279+
208280 async isRunButtonEnabled ( ) {
209281 return this . runButton . isEnabled ( { timeout : VISIBILITY_TIMEOUT } ) ;
210282 }
0 commit comments