import { BottomBarPanel , MarkerType , OutputView , ProblemsView , TerminalView , VSBrowser } from "vscode-extension-tester" ; import * as path from 'path' ; import { expect } from "chai" ; describe ( 'Bottom Bar Example Tests' , ( ) => { let bottomBar ; before ( async ( ) => { bottomBar = new BottomBarPanel ( ) ; await bottomBar . toggle ( true ) ; } ) ; describe ( 'Problems View' , ( ) => { let view ; async function problemsExist ( view ) { const markers = await view . getAllMarkers ( MarkerType . Any ) ; return markers . length > 0 ; } before ( async function ( ) { this . timeout ( 30000 ) ; view = await bottomBar . openProblemsView ( ) ; await VSBrowser . instance . openResources ( path . join ( 'src' , 'ui-test' , 'resources' , 'problems.ts' ) ) ; await view . getDriver ( ) . wait ( ( ) => { return problemsExist ( view ) ; } , 15000 ) ; } ) ; it ( 'Error markers are displayed' , async ( ) => { const errors = await view . getAllMarkers ( MarkerType . Error ) ; expect ( errors . length ) . is . greaterThan ( 5 ) ; } ) ; it ( 'There are no warnings' , async ( ) => { const warnings = await view . getAllMarkers ( MarkerType . Warning ) ; expect ( warnings ) . is . empty ; } ) ; it ( 'There is a file marker' , async ( ) => { const files = await view . getAllMarkers ( MarkerType . File ) ; const file = files [ 0 ] ; expect ( await file . getText ( ) ) . contains ( 'problems.ts' ) ; expect ( await file . getType ( ) ) . equals ( MarkerType . File ) ; await file . toggleExpand ( false ) ; await file . toggleExpand ( true ) ; } ) ; it ( 'Filtering works' , async ( ) => { await view . setFilter ( 'aa' ) ; await new Promise ( res => setTimeout ( res , 1000 ) ) ; const errors = await view . getAllMarkers ( MarkerType . Error ) ; expect ( errors . length ) . equals ( 1 ) ; await view . clearFilter ( ) ; } ) ; } ) ; describe ( 'Output View' , ( ) => { let view ; before ( async ( ) => { view = await bottomBar . openOutputView ( ) ; await view . selectChannel ( 'Log (Main)' ) ; } ) ; it ( 'Get the text' , async ( ) => { const text = await view . getText ( ) ; expect ( text ) . is . not . empty ; } ) ; it ( 'Clear the output channel' , async ( ) => { await view . clearText ( ) ; const text = await view . getText ( ) ; expect ( text ) . equals ( '\n' ) ; } ) ; } ) ; describe ( 'Terminal View' , ( ) => { let view ; before ( async ( ) => { view = await bottomBar . openTerminalView ( ) ; } ) ; it ( 'Execute a command' , async ( ) => { await view . executeCommand ( 'echo "hello world!"' ) ; const text = await view . getText ( ) ; const textFound = text . split ( '\n' ) . some ( line => line === 'hello world!' ) ; expect ( textFound ) . is . true ; } ) ; } ) ; } ) ;