66 ViewControl ,
77 ViewSection ,
88 InputBox ,
9+ OutputView ,
10+ TreeItem ,
911} from "wdio-vscode-service" ;
1012
1113// eslint-disable-next-line @typescript-eslint/naming-convention
@@ -19,6 +21,17 @@ const ViewSectionTypes = [
1921] as const ;
2022export type ViewSectionType = ( typeof ViewSectionTypes ) [ number ] ;
2123
24+ export async function selectOutputChannel (
25+ outputView : OutputView ,
26+ channelName : string
27+ ) {
28+ if ( ( await outputView . getCurrentChannel ( ) ) === channelName ) {
29+ return ;
30+ }
31+ outputView . locatorMap . BottomBarViews . outputChannels = `ul[aria-label="Output actions"] select` ;
32+ await outputView . selectChannel ( channelName ) ;
33+ }
34+
2235export async function findViewSection ( name : ViewSectionType ) {
2336 const workbench = await browser . getWorkbench ( ) ;
2437
@@ -41,12 +54,14 @@ export async function findViewSection(name: ViewSectionType) {
4154 ) ;
4255 const views =
4356 ( await ( await control ?. openView ( ) ) ?. getContent ( ) ?. getSections ( ) ) ?? [ ] ;
57+ console . log ( "Views:" , views . length ) ;
4458 for ( const v of views ) {
45- const title = await v . getTitle ( ) ;
59+ const title = await v . elem . getText ( ) ;
60+ console . log ( "View title:" , title ) ;
4661 if ( title === null ) {
4762 continue ;
4863 }
49- if ( title . toUpperCase ( ) === name ) {
64+ if ( title . toUpperCase ( ) . includes ( name ) ) {
5065 return v ;
5166 }
5267 }
@@ -335,28 +350,15 @@ export async function waitForNotification(message: string, action?: string) {
335350 ) ;
336351}
337352
338- export async function waitForDeployment ( ) {
353+ export async function waitForDeployment ( outputView : OutputView ) {
339354 console . log ( "Waiting for deployment to finish" ) ;
340- const workbench = await driver . getWorkbench ( ) ;
355+ await browser . executeWorkbench ( async ( vscode ) => {
356+ await vscode . commands . executeCommand ( "workbench.panel.output.focus" ) ;
357+ } ) ;
358+ await selectOutputChannel ( outputView , "Databricks Bundle Logs" ) ;
341359 await browser . waitUntil (
342360 async ( ) => {
343361 try {
344- await browser . executeWorkbench ( async ( vscode ) => {
345- await vscode . commands . executeCommand (
346- "workbench.panel.output.focus"
347- ) ;
348- } ) ;
349- const outputView = await workbench
350- . getBottomBar ( )
351- . openOutputView ( ) ;
352-
353- if (
354- ( await outputView . getCurrentChannel ( ) ) !==
355- "Databricks Bundle Logs"
356- ) {
357- await outputView . selectChannel ( "Databricks Bundle Logs" ) ;
358- }
359-
360362 const logs = ( await outputView . getText ( ) ) . join ( "" ) ;
361363 console . log ( "------------ Bundle Output ------------" ) ;
362364 console . log ( logs ) ;
@@ -376,3 +378,22 @@ export async function waitForDeployment() {
376378 }
377379 ) ;
378380}
381+
382+ export async function getActionButton ( item : TreeItem , label : string ) {
383+ const actions = await item . getActionButtons ( ) ;
384+ if ( actions . length > 0 ) {
385+ for ( const item of actions ) {
386+ console . log ( "Checking action button:" , item . getLabel ( ) ) ;
387+ console . log (
388+ "Action button element:" ,
389+ await ( await item . elem ) . getHTML ( )
390+ ) ;
391+ const itemLabel =
392+ item . getLabel ( ) ?? ( await item . elem . getAttribute ( "aria-label" ) ) ;
393+ if ( itemLabel . indexOf ( label ) > - 1 ) {
394+ return item ;
395+ }
396+ }
397+ }
398+ return undefined ;
399+ }
0 commit comments