11import assert from "node:assert" ;
2- import path from "node:path" ;
2+ import path , { resolve } from "node:path" ;
33import * as fs from "fs/promises" ;
44import * as tmp from "tmp-promise" ;
55import {
@@ -12,8 +12,11 @@ import {
1212 CustomTreeSection ,
1313} from "vscode-extension-tester" ;
1414import { getViewSection , openFolder , waitForTreeItems } from "./utils" ;
15+ import Time , { TimeUnits } from "@databricks/databricks-sdk/dist/retries/Time" ;
16+ import { PeriodicRunner } from "../PeriodicRunner" ;
17+ import { ImageLogger , Logger } from "../loggingUtils" ;
1518
16- describe ( "Configure Databricks Extension" , function ( ) {
19+ describe ( "Configure Databricks Extension" , async function ( ) {
1720 // these will be populated by the before() function
1821 let browser : VSBrowser ;
1922 let driver : WebDriver ;
@@ -22,10 +25,11 @@ describe("Configure Databricks Extension", function () {
2225
2326 // this will be populated by the tests
2427 let clusterId : string ;
28+ let periodicRunners = new Map < string , PeriodicRunner > ( ) ;
2529
2630 this . timeout ( 10 * 60 * 1000 ) ;
2731
28- before ( async ( ) => {
32+ before ( async function ( ) {
2933 browser = VSBrowser . instance ;
3034 driver = browser . driver ;
3135
@@ -36,16 +40,54 @@ describe("Configure Databricks Extension", function () {
3640 await openFolder ( browser , projectDir ) ;
3741 } ) ;
3842
39- after ( ( ) => {
43+ beforeEach ( async function ( ) {
44+ const testName = this . currentTest ?. title ?? "Default" ;
45+ const suiteName = this . currentTest ?. parent ?. title ?? "Default" ;
46+
47+ const logger = await Logger . getLogger ( suiteName , testName ) ;
48+ const imageLogger = ImageLogger . getLogger ( suiteName , testName ) ;
49+
50+ const periodicRunner = new PeriodicRunner ( )
51+ . runFunction ( {
52+ fn : async ( ) => {
53+ ( await driver . manage ( ) . logs ( ) . get ( "browser" ) ) . map (
54+ ( entry ) => {
55+ logger . info ( entry . message ) ;
56+ }
57+ ) ;
58+ } ,
59+ every : new Time ( 1 , TimeUnits . seconds ) ,
60+ } )
61+ . runFunction ( {
62+ fn : async ( ) => {
63+ await imageLogger . log ( await driver . takeScreenshot ( ) ) ;
64+ } ,
65+ cleanup : async ( ) => {
66+ await imageLogger . flush ( ) ;
67+ } ,
68+ every : new Time ( 1 , TimeUnits . seconds ) ,
69+ } ) ;
70+
71+ periodicRunner . start ( ) ;
72+ periodicRunners . set ( testName , periodicRunner ) ;
73+ } ) ;
74+
75+ afterEach ( async function ( ) {
76+ const testName = this . currentTest ?. title ?? "Default" ;
77+ await periodicRunners . get ( testName ) ?. stop ( ) ;
78+ periodicRunners . delete ( testName ) ;
79+ } ) ;
80+
81+ after ( function ( ) {
4082 cleanup ( ) ;
4183 } ) ;
4284
43- it ( "should open VSCode" , async ( ) => {
85+ it ( "should open VSCode" , async function ( ) {
4486 const title = await driver . getTitle ( ) ;
4587 assert ( title . indexOf ( "Get Started" ) >= 0 ) ;
4688 } ) ;
4789
48- it ( "should open databricks panel and login" , async ( ) => {
90+ it ( "should open databricks panel and login" , async function ( ) {
4991 const section = await getViewSection ( "Configuration" ) ;
5092 assert ( section ) ;
5193 const welcome = await section . findWelcomeContent ( ) ;
@@ -61,14 +103,14 @@ describe("Configure Databricks Extension", function () {
61103 assert ( await waitForTreeItems ( section ) ) ;
62104 } ) ;
63105
64- it ( "should dismiss notifications" , async ( ) => {
106+ it ( "should dismiss notifications" , async function ( ) {
65107 const notifications = await new Workbench ( ) . getNotifications ( ) ;
66108 for ( const n of notifications ) {
67109 await n . dismiss ( ) ;
68110 }
69111 } ) ;
70112
71- it ( "shoult list clusters" , async ( ) => {
113+ it ( "shoult list clusters" , async function ( ) {
72114 const section = await getViewSection ( "Clusters" ) ;
73115 assert ( section ) ;
74116 const tree = section as CustomTreeSection ;
@@ -82,7 +124,7 @@ describe("Configure Databricks Extension", function () {
82124
83125 // test is skipped because context menus currently don't work in vscode-extension-tester
84126 // https://github.com/redhat-developer/vscode-extension-tester/issues/444
85- it . skip ( "should filter clusters" , async ( ) => {
127+ it . skip ( "should filter clusters" , async function ( ) {
86128 const section = await getViewSection ( "Clusters" ) ;
87129 assert ( section ) ;
88130 const action = await section ! . getAction ( "Filter clusters ..." ) ;
@@ -97,7 +139,7 @@ describe("Configure Databricks Extension", function () {
97139 assert ( items . length > 0 ) ;
98140 } ) ;
99141
100- it ( "should attach cluster" , async ( ) => {
142+ it ( "should attach cluster" , async function ( ) {
101143 const config = await getViewSection ( "Configuration" ) ;
102144 assert ( config ) ;
103145 const configTree = config as CustomTreeSection ;
@@ -128,7 +170,6 @@ describe("Configure Databricks Extension", function () {
128170
129171 await input . setText ( clusterId ) ;
130172 await input . confirm ( ) ;
131- await input . selectQuickPick ( 0 ) ;
132173
133174 // get cluster ID
134175 const clusterPropsItems = await clusterConfigItem . getChildren ( ) ;
@@ -142,7 +183,7 @@ describe("Configure Databricks Extension", function () {
142183 assert ( clusterId ) ;
143184 } ) ;
144185
145- it ( "should write the project config file" , async ( ) => {
186+ it ( "should write the project config file" , async function ( ) {
146187 let projectConfig = JSON . parse (
147188 await fs . readFile (
148189 path . join ( projectDir , ".databricks" , "project.json" ) ,
0 commit comments