import { get } from 'lodash' ; import { ChainableElement } from '../../common/types' ; import { IdentityProviderConfig } from '../../common/types/identity-provider-config' ; import { OperatorUser } from '../helpers' ; export default class ExploitIdpFormPage { get validationButton ( ) : ChainableElement { return cy . get ( "button[type='submit']" ) ; } get totpInput ( ) : ChainableElement { return cy . get ( '#_totp' ) ; } get allFormInputs ( ) : ChainableElement { return cy . get ( '#fi-form input, #fi-form textarea' ) ; } fillDefaultValues ( values ) { this . allFormInputs . each ( ( $el ) => { const elementId = $el . attr ( 'id' ) ; const value = get ( values , elementId ) ; if ( value ) this . fillValue ( elementId , value ) ; } ) ; } fillValue ( name , value ) { this . getInputFromName ( name ) . then ( ( $elem ) => { if ( $elem . attr ( 'type' ) === 'radio' ) { cy . wrap ( $elem ) . check ( value , { force : true } ) . trigger ( 'change' , { force : true } ) ; } else if ( $elem . is ( 'select' ) ) { cy . wrap ( $elem ) . select ( value ) ; } else { cy . wrap ( $elem ) . clear ( ) . type ( value ) ; } } ) ; } getInputFromName ( name ) { return cy . get ( `[name=${ name }]` ) ; } validateForm ( user ) { user . wrapTotp ( ) . then ( ( token ) => this . totpInput . clear ( ) . type ( token ) ) ; this . validationButton . click ( ) ; } }