import { TestPage } from "./lforms_testpage.po" ; import TestUtil from "./util" ; import { browser , logging , element , by , WebElementPromise , ExpectedConditions } from 'protractor' ; import { protractor } from 'protractor/built/ptor' ; let tp = new TestPage ( ) ; let LForms = ( global as any ) . LForms ; describe ( 'form validation' , function ( ) { beforeAll ( async ( ) => { await browser . waitForAngularEnabled ( false ) ; tp . openBaseTestPage ( ) ; } ) ; it ( 'DT data type should work' , function ( ) { tp . loadFromTestData ( 'test-date-validation.json' ) ; let dtEl = element ( by . id ( '/required_dt/1' ) ) . element ( by . css ( "input" ) ) ; let otherEl = element ( by . id ( '/required_tx/1' ) ) ; let dateStr = '02/032019' ; dtEl . clear ( ) ; TestUtil . sendKeys ( dtEl , dateStr ) ; otherEl . click ( ) ; expect ( dtEl . getAttribute ( "value" ) ) . toBe ( '' ) ; dateStr = '02/03/2019' ; dtEl . clear ( ) ; TestUtil . sendKeys ( dtEl , dateStr ) ; otherEl . click ( ) ; expect ( dtEl . getAttribute ( "value" ) ) . toEqual ( dateStr ) ; } ) ; it ( 'should validate when required inputs are entered' , function ( ) { tp . loadFromTestData ( 'test-date-validation.json' ) ; const skipLogicTrigger = element ( by . id ( '/sl_source_to_test_required/1' ) ) ; TestUtil . sendKeys ( skipLogicTrigger , '1' ) ; let otherEl = element ( by . id ( "/required_tx/1" ) ) ; const dtEl = element ( by . id ( '/required_dt/1' ) ) . element ( by . css ( "input" ) ) ; dtEl . clear ( ) ; TestUtil . sendKeys ( dtEl , '10/16/2020' ) ; otherEl . click ( ) ; const dtmEl = element ( by . id ( '/required_dtm/1' ) ) . element ( by . css ( "input" ) ) ; TestUtil . sendKeys ( dtmEl , '10/16/2020 16:00:00' ) ; otherEl . click ( ) ; const txEl = element ( by . id ( '/required_tx/1' ) ) ; TestUtil . sendKeys ( txEl , 'test' ) ; const stEl = element ( by . id ( '/required_st/1' ) ) ; TestUtil . sendKeys ( stEl , 'test' ) ; const originalHiddenEl1 = element ( by . id ( '/sl_target_to_test_required1/1' ) ) ; TestUtil . sendKeys ( originalHiddenEl1 , 'test' ) ; const originalHiddenSubEl1 = element ( by . id ( '/sl_target_header/sl_target_to_test_required/1/1' ) ) ; TestUtil . sendKeys ( originalHiddenSubEl1 , 'test' ) ; const errors = browser . driver . executeScript ( 'return LForms.Util.checkValidity()' ) ; expect ( errors ) . toEqual ( null ) ; } ) ; } ) ;