import { browser } from 'protractor' ; import { LoginComponent } from '../components/components' ; import { Page } from './page' ; import { APP_ROUTES } from '../configs' ; import { waitForPresence } from '../utilities/utils' ; import { BrowserActions , Logger } from '@alfresco/adf-testing' ; export class LoginPage extends Page { login = new LoginComponent ( this . appRoot ) ; constructor ( ) { super ( APP_ROUTES . LOGIN ) ; } async load ( ) { await super . load ( ) ; if ( await this . isLoggedIn ( ) ) { await this . signOut ( ) ; } await waitForPresence ( this . login . submitButton ) ; } async loginWith ( username , password ? ) { try { const pass = password || username ; await this . load ( ) ; await this . login . enterCredentials ( username , pass ) ; await BrowserActions . click ( this . login . submitButton ) ; await this . waitForApp ( ) ; } catch ( error ) { Logger . error ( `----- loginWith catch : failed to login with user: ${ username } : ${ error }` ) ; } } async loginWithAdmin ( ) { await this . loginWith ( browser . params . ADMIN_USERNAME , browser . params . ADMIN_PASSWORD ) ; } async tryLoginWith ( username , password ? ) { const pass = password || username ; await this . load ( ) ; await this . login . enterCredentials ( username , pass ) ; await BrowserActions . click ( this . login . submitButton ) ; await waitForPresence ( this . login . errorMessage ) ; } }