@@ -12,7 +12,6 @@ const COLUMN_HEADERS = '.data-explorer-panel .right-column .data-grid-column-hea
12
12
const HEADER_TITLES = '.data-grid-column-header .title-description .title' ;
13
13
const DATA_GRID_ROWS = '.data-explorer-panel .right-column .data-grid-rows' ;
14
14
const DATA_GRID_ROW = '.data-grid-row' ;
15
- const CLOSE_DATA_EXPLORER = '.tab .codicon-close' ;
16
15
const IDLE_STATUS = '.status-bar-indicator .icon.idle' ;
17
16
const SCROLLBAR_LOWER_RIGHT_CORNER = '.data-grid-scrollbar-corner' ;
18
17
const DATA_GRID_TOP_LEFT = '.data-grid-corner-top-left' ;
@@ -99,10 +98,6 @@ export class DataExplorer {
99
98
return tableData ;
100
99
}
101
100
102
- async closeDataExplorer ( ) {
103
- await this . code . driver . page . locator ( CLOSE_DATA_EXPLORER ) . first ( ) . click ( ) ;
104
- }
105
-
106
101
async clickLowerRightCorner ( ) {
107
102
await this . code . driver . page . locator ( SCROLLBAR_LOWER_RIGHT_CORNER ) . click ( ) ;
108
103
}
@@ -132,18 +127,56 @@ export class DataExplorer {
132
127
} ) ;
133
128
}
134
129
135
- async getDataExplorerStatusBarText ( ) : Promise < String > {
136
- await expect ( this . code . driver . page . locator ( STATUS_BAR ) ) . toHaveText ( / S h o w i n g / , { timeout : 60000 } ) ;
137
- return ( await this . code . driver . page . locator ( STATUS_BAR ) . textContent ( ) ) ?? '' ;
130
+ async expectLastCellContentToBe ( columnName : string , expectedContent : string , rowAtIndex = - 1 ) : Promise < void > {
131
+ await test . step ( `Verify last cell content: ${ expectedContent } ` , async ( ) => {
132
+ await expect ( async ( ) => {
133
+ const tableData = await this . getDataExplorerTableData ( ) ;
134
+ const lastRow = tableData . at ( rowAtIndex ) ;
135
+ const lastHour = lastRow ! [ columnName ] ;
136
+ expect ( lastHour ) . toBe ( expectedContent ) ;
137
+ } , 'Verify last hour cell content' ) . toPass ( ) ;
138
+ } ) ;
139
+ }
140
+
141
+ async expectStatusBarToHaveText ( expectedText : string , timeout = 60000 ) : Promise < void > {
142
+ await test . step ( `Expect status bar text: ${ expectedText } ` , async ( ) => {
143
+ await expect ( this . code . driver . page . locator ( STATUS_BAR ) ) . toHaveText ( expectedText , { timeout } ) ;
144
+ } ) ;
138
145
}
139
146
147
+
140
148
async selectColumnMenuItem ( columnIndex : number , menuItem : string ) {
141
149
await test . step ( `Sort column ${ columnIndex } by: ${ menuItem } ` , async ( ) => {
142
150
await this . code . driver . page . locator ( `.data-grid-column-header:nth-child(${ columnIndex } ) .sort-button` ) . click ( ) ;
143
- await this . code . driver . page . locator ( `.positron-modal-overlay div.title:has-text(" ${ menuItem } " )` ) . click ( ) ;
151
+ await this . code . driver . page . locator ( `.positron-modal-overlay div.title:has-text(' ${ menuItem } ' )` ) . click ( ) ;
144
152
} ) ;
145
153
}
146
154
155
+ async expectActionBarToHaveButton ( buttonName : string , isVisible : boolean = true ) {
156
+ await test . step ( `Expect action bar to have button: ${ buttonName } ` , async ( ) => {
157
+ const button = this . code . driver . page . getByRole ( 'button' , { name : buttonName } ) ;
158
+ if ( isVisible ) {
159
+ await expect ( button ) . toBeVisible ( ) ;
160
+ } else {
161
+ await expect ( button ) . not . toBeVisible ( ) ;
162
+ }
163
+ } ) ;
164
+ }
165
+
166
+ async verifyCanOpenAsPlaintext ( searchString : string | RegExp ) {
167
+ await this . workbench . editorActionBar . clickButton ( 'Open as Plain Text File' ) ;
168
+
169
+ // Check if the 'Open Anyway' button is visible. This is needed on web only as it warns
170
+ // that the file is large and may take a while to open. This is due to a vs code behavior and file size limit.
171
+ const openAnyway = this . code . driver . page . getByText ( 'Open Anyway' ) ;
172
+
173
+ if ( await openAnyway . waitFor ( { state : 'visible' , timeout : 5000 } ) . then ( ( ) => true ) . catch ( ( ) => false ) ) {
174
+ await openAnyway . click ( ) ;
175
+ }
176
+
177
+ await expect ( this . code . driver . page . getByText ( searchString , { exact : true } ) ) . toBeVisible ( ) ;
178
+ }
179
+
147
180
async home ( ) : Promise < void > {
148
181
await this . code . driver . page . keyboard . press ( 'Home' ) ;
149
182
}
@@ -180,10 +213,8 @@ export class DataExplorer {
180
213
async getColumnProfileInfo ( rowNumber : number ) : Promise < ColumnProfile > {
181
214
182
215
const expandCollapseLocator = this . code . driver . page . locator ( EXPAND_COLLAPSE_PROFILE ( rowNumber ) ) ;
183
-
184
216
await expandCollapseLocator . scrollIntoViewIfNeeded ( ) ;
185
217
await expandCollapseLocator . click ( ) ;
186
-
187
218
await expect ( expandCollapseLocator . locator ( EXPAND_COLLASPE_ICON ) ) . toHaveClass ( / c o d i c o n - c h e v r o n - d o w n / ) ;
188
219
189
220
const profileData : { [ key : string ] : string } = { } ;
@@ -204,7 +235,7 @@ export class DataExplorer {
204
235
}
205
236
}
206
237
207
- // some rects have " count" class, some have " bin-count" class, some have " count other" class
238
+ // some rects have ' count' class, some have ' bin-count' class, some have ' count other' class
208
239
const rects = await this . code . driver . page . locator ( '.column-profile-sparkline' ) . locator ( '[class*="count"]' ) . all ( ) ;
209
240
const profileSparklineHeights : string [ ] = [ ] ;
210
241
for ( let i = 0 ; i < rects . length ; i ++ ) {
@@ -254,7 +285,7 @@ export class DataExplorer {
254
285
} ) ;
255
286
}
256
287
257
- async verifyTableData ( expectedData , timeout = 60000 ) {
288
+ async verifyTableData ( expectedData : Array < { [ key : string ] : string } > , timeout = 60000 ) {
258
289
await test . step ( 'Verify data explorer data' , async ( ) => {
259
290
await expect ( async ( ) => {
260
291
const tableData = await this . getDataExplorerTableData ( ) ;
@@ -302,8 +333,8 @@ export class DataExplorer {
302
333
} ) ;
303
334
}
304
335
305
- async verifyProfileData ( expectedValues : Array < { column : number ; expected : { [ key : string ] : string } } > ) {
306
- await test . step ( 'Verify profile data' , async ( ) => {
336
+ async verifyColumnData ( expectedValues : Array < { column : number ; expected : { [ key : string ] : string } } > ) {
337
+ await test . step ( 'Verify column data' , async ( ) => {
307
338
for ( const { column, expected } of expectedValues ) {
308
339
const profileInfo = await this . getColumnProfileInfo ( column ) ;
309
340
expect ( profileInfo . profileData ) . toStrictEqual ( expected ) ;
@@ -324,6 +355,15 @@ export class DataExplorer {
324
355
} ) ;
325
356
}
326
357
358
+ async verifySparklineHeights ( expectedHeights : Array < { column : number ; expected : string [ ] } > ) {
359
+ await test . step ( 'Verify sparkline heights' , async ( ) => {
360
+ for ( const { column, expected } of expectedHeights ) {
361
+ const colProfileInfo = await this . getColumnProfileInfo ( column ) ;
362
+ expect ( colProfileInfo . profileSparklineHeights ) . toStrictEqual ( expected ) ;
363
+ }
364
+ } ) ;
365
+ }
366
+
327
367
async verifyNullPercentHoverDialog ( ) : Promise < void > {
328
368
await test . step ( 'Verify null percent hover dialog' , async ( ) => {
329
369
const firstNullPercent = this . code . driver . page . locator ( '.column-null-percent' ) . nth ( 0 ) ;
@@ -347,4 +387,11 @@ export class DataExplorer {
347
387
expect ( missing ) . toEqual ( [ ] ) ; // Will throw if any are missing
348
388
} ) ;
349
389
}
390
+
391
+ async clickCell ( rowIndex : number , columnIndex : number ) {
392
+ await test . step ( `Click cell at row ${ rowIndex } , column ${ columnIndex } ` , async ( ) => {
393
+ const cellLocator = this . code . driver . page . locator ( `${ DATA_GRID_ROWS } ${ DATA_GRID_ROW } :nth-child(${ rowIndex + 1 } ) > div:nth-child(${ columnIndex + 1 } )` ) ;
394
+ await cellLocator . click ( ) ;
395
+ } ) ;
396
+ }
350
397
}
0 commit comments