import { UserData } from '../types' ; import { User } from './user' ; const DEFAULT_USER_CRITERIA = 'par défaut' ; export const getUserByCriteria = ( users , criteria ) : User => { const user = User . extractUserFromDataByCriteria ( users , criteria ) ; expect ( user , `No user matches the criteria ${ JSON . stringify ( criteria ) }` ) . to . exist ; cy . wrap ( user ) . as ( 'user' ) ; return user ; } ; export const getEnabledUserByIdpId = ( users , idpId ) : User => { const user = User . extractEnabledUserFromDataByIdpId ( users , idpId ) ; expect ( user , `No active user has credentials for the identity provider '${ idpId }'` ) . to . exist ; cy . wrap ( user ) . as ( 'user' ) ; return user ; } ; export const getDefaultUser = ( users ) : User => getUserByCriteria ( users , [ DEFAULT_USER_CRITERIA ] ) ;