declare global { namespace Cypress { interface Chainable { returns { typeof object } memberof example CDAndList : typeof CDList ; returns { typeof Body } memberof example triggerHotkey : typeof triggerHotkey ; returns { typeof Document } memberof example triggerFakeCombo : typeof triggerFakeCombo ; returns { typeof Button } memberof example addTab : typeof addTab ; returns { typeof Button } memberof example getTab : typeof getTab ; memberof example triggerHover : ( ) => any ; memberof example toggleSplitView : ( ) => any ; rightclick ( position , options ? ) : any ; rightclick ( x , y , options ? ) : any ; } } } export function toggleSplitView ( ) { return cy . get ( '.data-cy-toggle-splitview' ) . click ( ) ; } export function addTab ( viewId = 0 ) { return cy . get ( `#view_${ viewId } .tablist .addtab` ) . click ( ) ; } export function getTab ( viewId = 0 , tabIndex = 0 ) { return cy . get ( `#view_${ viewId } .tablist > button.tab` ) . eq ( tabIndex ) ; } export function CDList ( viewId = 0 , path , splice = 0 , fixture = "files.json" ) { return cy . window ( ) . then ( win => { cy . fixture ( fixture ) . then ( json => { if ( win . appState && win . appState . caches ) { const files = json . splice ( splice ) ; const fileCache = win . appState . winStates [ 0 ] . views [ viewId ] . caches [ 0 ] ; fileCache . updatePath ( path ) ; fileCache . files . replace ( files ) ; fileCache . setStatus ( "ok" ) ; return files ; } } ) ; } ) ; } export function triggerHover ( elements ) { elements . each ( ( index , element ) => { fireEvent ( element , 'mouseover' ) ; } ) ; function fireEvent ( element , event ) { if ( element . fireEvent ) { element . fireEvent ( 'on' + event ) ; } else { var evObj = document . createEvent ( 'Events' ) ; evObj . initEvent ( event , true , false ) ; element . dispatchEvent ( evObj ) ; } } return elements ; } ; export function triggerHotkey ( hotkey , options = { } ) { return cy . get ( "body" ) . type ( hotkey , options ) ; } export function triggerFakeCombo ( combo , data = { title : "hey!" } ) { cy . log ( 'triggering' , { combo , data } ) ; return cy . document ( ) . trigger ( 'menu_accelerator' , { combo , data } ) ; } Cypress . Commands . add ( "CDAndList" , CDList ) ; Cypress . Commands . add ( "triggerHotkey" , triggerHotkey ) ; Cypress . Commands . add ( "triggerFakeCombo" , triggerFakeCombo ) ; Cypress . Commands . add ( "addTab" , addTab ) ; Cypress . Commands . add ( "getTab" , getTab ) ; Cypress . Commands . add ( "triggerHover" , { prevSubject : true } , triggerHover ) ; Cypress . Commands . add ( "toggleSplitView" , toggleSplitView ) ;