import '@testing-library/cypress/add-commands' ; import TeamCredentials from './types/teamCredentials' ; Cypress . Commands . add ( 'login' , ( teamCredentials ) => { cy . visit ( '/login' ) ; enterText ( '#teamNameInput' , teamCredentials . teamName ) ; enterText ( '#teamPasswordInput' , teamCredentials . password ) ; click ( '#signInButton' ) ; } ) ; Cypress . Commands . add ( 'createTeam' , ( teamCredentials ) => { cy . visit ( '/create' ) ; enterText ( '#teamNameInput' , teamCredentials . teamName ) ; enterText ( '#teamPasswordInput' , teamCredentials . password ) ; enterText ( '#teamPasswordConfirmInput' , teamCredentials . password ) ; click ( '#createRetroButton' ) ; } ) ; Cypress . Commands . add ( 'createTeamIfNecessaryAndLogin' , ( teamCredentials ) => { cy . request ( { url : `/api/team/login` , failOnStatusCode : false , method : 'POST' , body : { name : teamCredentials . teamName , password : teamCredentials . password , captchaResponse : null , } , } ) . then ( ( response ) => { console . log ( response . body ) ; if ( response . status === 200 ) { teamCredentials . jwt = response . body ; cy . login ( teamCredentials ) ; } else { cy . createTeam ( teamCredentials ) ; } } ) ; } ) ; Cypress . Commands . add ( 'enterThought' , ( columnClass , thought ) => { cy . get ( `div.${ columnClass }.rq-thought-column-header` ) . find ( 'input[placeholder="Enter A Thought"]' ) . type ( `${ thought }{enter}` ) ; } ) ; function click ( selector ) { cy . get ( selector ) . click ( ) ; } function enterText ( selector , textToEnter ) { cy . get ( selector ) . type ( textToEnter ) ; }