import userEvent from '@testing-library/user-event' ; export const clickBySelector = async ( selector ) : Promise < void > => { const elem = getElem ( selector ) ; if ( ! elem ) { return ; } await userEvent . click ( elem ) ; } ; export const getElem = ( selector ) : Element | null => document . querySelector ( selector ) ; export const getElemByTestId = ( id ) : Element | null => document . querySelector ( `[data-test-id="${ id }"]` ) ; export const changeTextBySelector = async ( selector , value ) : Promise < void > => { const elem = getElem ( selector ) ; if ( ! elem ) { return ; } await userEvent . type ( elem , `{selectall}{del}${ value }` ) ; } ; export const selectBySelector = async ( selector , value ) : Promise < void > => { const elem = getElem ( selector ) ; if ( ! elem ) { return ; } await userEvent . selectOptions ( elem , [ value ] ) ; } ; export const fetch = ( time = 1000 , func ? ) : Promise < boolean > => new Promise < boolean > ( ( resolve ) => { setTimeout ( ( ) => { resolve ( func ?. ( ) || false ) ; } , time ) ; } ) ; export const generateFileContent = ( size ) : Array < string > => [ new Array ( size ) . fill ( '1' ) . join ( '' ) , ] ;