const testUtil = require ( './util' ) ; describe ( 'directive: ' , function ( ) { describe ( 'horizontal table' , function ( ) { var BLANK_GIF_DATAURL = 'data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///////wAAACH5BAUUAAIALAAAAAABAAEAAAICVAEAOw==' ; var tp = require ( './lforms_testpage.po.js' ) ; describe ( 'should have BLANK_GIF_DATAURL' , function ( ) { it ( 'in datepicker stop-sign image tag' , function ( ) { tp . openDirectiveTest ( ) ; expect ( element . all ( by . css ( 'img.stop-sign' ) ) . getAttribute ( 'src' ) ) . toContain ( BLANK_GIF_DATAURL ) ; } ) ; } ) ; it ( 'should have one add button in the horizontal table when the form loads' , function ( ) { tp . openDirectiveTest ( ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 2 ) . isPresent ( ) ) . toBe ( true ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 2 ) . getText ( ) ) . toBe ( '+ Add another "This family member\'s history of disease"' ) ; } ) ; it ( 'should still have two remove buttons visible after the user adds a row' , function ( ) { element . all ( by . css ( '.lf-float-button' ) ) . get ( 2 ) . click ( ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 2 ) . getText ( ) ) . toBe ( '-' ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 3 ) . getText ( ) ) . toBe ( '-' ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 4 ) . getText ( ) ) . toBe ( '+ Add another "This family member\'s history of disease"' ) ; } ) ; it ( 'should have three remove buttons visible after the user adds a row' , function ( ) { testUtil . safeClick ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 4 ) ) ; browser . wait ( function ( ) { return element . all ( by . css ( '.lf-float-button' ) ) . count ( ) . then ( n => n == 7 ) ; } ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 2 ) . getText ( ) ) . toBe ( '-' ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 3 ) . getText ( ) ) . toBe ( '-' ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 4 ) . getText ( ) ) . toBe ( '-' ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 5 ) . getText ( ) ) . toBe ( '+ Add another "This family member\'s history of disease"' ) ; } ) ; it ( 'should have the 2 rows after the user removes the 2nd row' , function ( ) { testUtil . safeClick ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 3 ) ) ; browser . wait ( function ( ) { return element . all ( by . css ( '.lf-float-button' ) ) . count ( ) . then ( n => n == 6 ) ; } ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 2 ) . getText ( ) ) . toBe ( '-' ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 3 ) . getText ( ) ) . toBe ( '-' ) ; browser . wait ( function ( ) { return element . all ( by . css ( '.lf-float-button' ) ) . get ( 4 ) . getText ( ) . then ( text => text == '+ Add another "This family member\'s history of disease"' ) ; } , 5000 ) ; } ) ; describe ( 'autocomp list inside lforms directive' , function ( ) { var listFieldID = '/54126-8/54132-6/1/1' ; var searchResults = $ ( '#searchResults' ) ; it ( 'should be visible after the user clicks in a field' , function ( ) { tp . openDirectiveTest ( ) ; var listField = element ( by . id ( listFieldID ) ) ; browser . wait ( function ( ) { return listField . isDisplayed ( ) ; } , tp . WAIT_TIMEOUT_2 ) ; listField . click ( ) ; browser . wait ( function ( ) { return searchResults . isDisplayed ( ) ; } , tp . WAIT_TIMEOUT_2 ) ; expect ( searchResults . isDisplayed ( ) ) . toBeTruthy ( ) ; } ) ; } ) ; } ) ; describe ( 'checkbox controlled by templateOptions in the form data: ' , function ( ) { var tp = require ( './lforms_testpage.po.js' ) ; var loadForm1 = 'load1' ; var loadForm2 = 'load2' ; var loadForm3 = 'load3' ; it ( 'default value of the checkboxes should not be checked' , function ( ) { tp . openDirectiveTest ( ) ; var checkboxes = element . all ( by . css ( 'div.lf-form-control > label > input[type="checkbox"]' ) ) ; expect ( checkboxes . get ( 0 ) . isSelected ( ) ) . toBe ( false ) ; expect ( checkboxes . get ( 1 ) . isSelected ( ) ) . toBe ( false ) ; expect ( checkboxes . get ( 2 ) . isSelected ( ) ) . toBe ( false ) ; } ) ; it ( '2 checkboxes should be checked on form 1' , function ( ) { element ( by . id ( loadForm2 ) ) . click ( ) ; browser . waitForAngular ( ) ; var checkboxes = element . all ( by . css ( 'div.lf-form-control > label > input[type="checkbox"]' ) ) ; expect ( checkboxes . get ( 0 ) . isSelected ( ) ) . toBe ( true ) ; expect ( checkboxes . get ( 1 ) . isSelected ( ) ) . toBe ( true ) ; expect ( checkboxes . get ( 2 ) . isSelected ( ) ) . toBe ( false ) ; var code = element ( by . css ( 'a[href="http://s.details.loinc.org/LOINC/54126-8.html"]' ) ) ; expect ( code . isDisplayed ( ) ) . toBe ( true ) ; } ) ; it ( '1 checkbox should be checked on form 1' , function ( ) { element ( by . id ( loadForm1 ) ) . click ( ) ; browser . waitForAngular ( ) ; var checkboxes = element . all ( by . css ( 'div.lf-form-control > label > input[type="checkbox"]' ) ) ; expect ( checkboxes . get ( 0 ) . isSelected ( ) ) . toBe ( true ) ; expect ( checkboxes . get ( 1 ) . isSelected ( ) ) . toBe ( false ) ; expect ( checkboxes . get ( 2 ) . isSelected ( ) ) . toBe ( false ) ; var code = element ( by . css ( 'a[href="http://s.details.loinc.org/LOINC/54126-8.html"]' ) ) ; expect ( code . isDisplayed ( ) ) . toBe ( true ) ; } ) ; it ( 'changing templateOptions alone should also change the form' , function ( ) { element ( by . id ( loadForm3 ) ) . click ( ) ; browser . waitForAngular ( ) ; var checkboxes = element ( by . css ( 'div.lf-form-control > label > input[type="checkbox"]' ) ) ; expect ( checkboxes . isPresent ( ) ) . toBeFalsy ( ) ; expect ( element ( by . id ( 'date_done' ) ) . isPresent ( ) ) . toBe ( false ) ; } ) ; } ) ; } ) ;