import { ActivityBar , DefaultTreeSection , EditorView , SideBarView , ViewContent , ViewTitlePart , VSBrowser } from 'vscode-extension-tester' ; import * as path from 'path' ; import { expect } from 'chai' ; describe ( 'Example tree view tests' , ( ) => { let titlePart ; let content ; before ( async ( ) => { await VSBrowser . instance . openResources ( path . join ( 'src' , 'ui-test' , 'resources' , 'test' ) ) ; ( await new ActivityBar ( ) . getViewControl ( 'Explorer' ) ) ?. openView ( ) ; const view = new SideBarView ( ) ; titlePart = view . getTitlePart ( ) ; content = view . getContent ( ) ; } ) ; it ( 'Title part' , async ( ) => { const title = await titlePart . getTitle ( ) ; expect ( title . toLowerCase ( ) ) . equals ( 'explorer' ) ; const actions = await titlePart . getActions ( ) ; } ) ; describe ( 'Content' , ( ) => { let tree ; before ( async ( ) => { tree = await content . getSection ( 'test' ) as DefaultTreeSection ; } ) ; it ( 'Look at the items' , async ( ) => { const items = await tree . getVisibleItems ( ) ; const labels = await Promise . all ( items . map ( item => item . getLabel ( ) ) ) ; expect ( labels ) . contains ( 'test-folder' ) ; expect ( labels ) . contains ( 'test-file' ) ; const children = await tree . openItem ( 'test-folder' ) ; expect ( children . length ) . equals ( 1 ) ; const notReallyChildren = await tree . openItem ( 'test-folder' , 'more-test-file' ) ; expect ( notReallyChildren ) . is . empty ; const editors = await new EditorView ( ) . getOpenEditorTitles ( ) ; expect ( editors ) . contains ( 'more-test-file' ) ; } ) ; it ( 'A little bit of searching' , async ( ) => { const item = await tree . findItem ( 'more-test-file' ) ; expect ( item ) . not . undefined ; const item1 = await tree . findItem ( 'more-test-files' , 1 ) ; expect ( item1 ) . undefined ; } ) ; } ) ; } ) ;