import { expect } from 'chai' ; import { ActivityBar , ContextMenu , EditorView , TitleBar } from 'vscode-extension-tester' ; ( process . platform === 'darwin' ? describe . skip : describe ) ( 'Example menu manipulation test' , ( ) => { let titleBar ; before ( ( ) => { titleBar = new TitleBar ( ) ; } ) ; after ( async ( ) => { await new EditorView ( ) . closeAllEditors ( ) ; } ) ; describe ( 'Title Bar' , ( ) => { it ( 'Select a top level item' , async ( ) => { const menu = await titleBar . select ( 'File' ) ; expect ( menu ) . not . undefined ; await ( menu as ContextMenu ) . close ( ) ; } ) ; it ( 'Select a leaf item' , async ( ) => { await titleBar . select ( 'File' , 'Preferences' , 'Settings' ) ; const titles = await new EditorView ( ) . getOpenEditorTitles ( ) ; expect ( titles ) . contains ( 'Settings' ) ; } ) ; it ( 'Menu items' , async ( ) => { const items = await titleBar . getItems ( ) ; const titles = await Promise . all ( items . map ( async ( item ) => await item . getLabel ( ) ) ) ; expect ( titles ) . contains ( 'File' ) ; const item = await titleBar . getItem ( 'File' ) ; expect ( item ) . not . undefined ; const nonExistent = await titleBar . getItem ( 'this doesnt exist' ) ; expect ( nonExistent ) . undefined ; expect ( await titleBar . hasItem ( 'File' ) ) . is . true ; } ) ; } ) ; describe ( 'Elements with context menu' , async ( ) => { it ( 'open context menu on an element' , async ( ) => { const menu = await new ActivityBar ( ) . openContextMenu ( ) ; await menu . select ( 'Extensions' ) ; } ) ; } ) ; } ) ;