import { $ , $$ , browser , by , element , ElementFinder , Key } from 'protractor' ; export class MarqueeWizardPage { wizard = $ ( 'ux-marquee-wizard' ) ; stepHeaders = $$ ( '.marquee-wizard-step' ) ; stepContents = $$ ( 'ux-marquee-wizard-step' ) ; gutter = $ ( '.as-split-gutter' ) ; resizeableButton = element ( by . id ( 'resizeable' ) ) ; footerTemplateButton = element ( by . id ( 'footerTemplate' ) ) ; step4InvalidButton = element ( by . id ( 'step4Invalid' ) ) ; step1InvalidButton = element ( by . id ( 'step1Invalid' ) ) ; step2InvalidButton = element ( by . id ( 'step2Invalid' ) ) ; disableNextWhenInvalidStep1Button = element ( by . id ( 'disableNextWhenInvalidStep1' ) ) ; disableNextWhenInvalidWizardButton = element ( by . id ( 'disableNextWhenInvalidWizard' ) ) ; resetButton = element ( by . id ( 'reset' ) ) ; input = $ ( 'ux-number-picker input' ) ; emittedWidth = element ( by . id ( 'sidePanelWidthChange' ) ) ; buttons = $$ ( 'button' ) ; async getPage ( ) { await browser . get ( '#/marquee-wizard' ) ; } async getButtonByText ( text ) { let buttons = await this . buttons ; let btnText = await this . buttons . map ( button => button . getText ( ) ) ; let matchIdx = btnText . findIndex ( ( label ) => label . toLowerCase ( ) === text . toLowerCase ( ) ) ; return matchIdx === - 1 ? null : buttons [ matchIdx ] ; } async getPreviousButton ( ) { return await this . getButtonByText ( 'Previous' ) ; } async getNextButton ( ) { return await this . getButtonByText ( 'Next' ) ; } async getCancelButton ( ) { return await this . getButtonByText ( 'Cancel' ) ; } async getFinishButton ( ) { return await this . getButtonByText ( 'Finish' ) ; } async goToNext ( ) { let next = await this . getNextButton ( ) ; await next . click ( ) ; } async getGutterAriaValue ( ) { return await this . gutter . getAttribute ( 'aria-valuenow' ) ; } async getGutterAriaValueMin ( ) { return await this . gutter . getAttribute ( 'aria-valuemin' ) ; } async getGutterAriaValueMax ( ) { return await this . gutter . getAttribute ( 'aria-valuemax' ) ; } async getInputField ( ) { return await this . input . getAttribute ( 'value' ) ; } async setGutterFocused ( ) { return await this . gutter . click ( ) ; } async sendLeftKey ( ) { return await browser . actions ( ) . sendKeys ( Key . ARROW_LEFT ) . perform ( ) ; } async sendRightKey ( ) { return await browser . actions ( ) . sendKeys ( Key . ARROW_RIGHT ) . perform ( ) ; } async sendHomeKey ( ) { return await browser . actions ( ) . sendKeys ( Key . HOME ) . perform ( ) ; } async sendEndKey ( ) { return await browser . actions ( ) . sendKeys ( Key . END ) . perform ( ) ; } async mouseMoveLeft ( ) { await browser . actions ( ) . dragAndDrop ( this . gutter , { x : - 10 , y : 0 } ) . perform ( ) ; } async mouseMoveRight ( ) { return await browser . actions ( ) . dragAndDrop ( this . gutter , { x : 10 , y : 0 } ) . perform ( ) ; } }