import { browser , ElementFinder } from 'protractor' ; import { DashboardDynamicLayoutPage } from './dynamic-layout.po.spec' ; describe ( 'Dashboard Dynamic Layout' , ( ) => { let page ; let widget1 ; let widget2 ; let widget3 ; let widget4 ; beforeEach ( async ( ) => { page = new DashboardDynamicLayoutPage ( ) ; await page . getPage ( ) ; await browser . driver . manage ( ) . window ( ) . setSize ( 1320 , 800 ) ; widget1 = await page . getWidget ( 0 ) ; widget2 = await page . getWidget ( 1 ) ; widget3 = await page . getWidget ( 2 ) ; widget4 = await page . getWidget ( 3 ) ; } ) ; it ( 'should resize widget 1 to 2 rows when the rowSpan is changed to 2, widgets 4 should move down one row' , async ( ) => { expect ( await page . getWidgetLocationValue ( widget1 , 'height' ) ) . toBe ( 220 ) ; expect ( await page . getWidgetLocationValue ( widget4 , 'top' ) ) . toBe ( 220 ) ; await page . widget1RowIncrement . click ( ) ; expect ( await page . getWidgetLocationValue ( widget1 , 'height' ) ) . toBe ( 440 ) ; expect ( await page . getWidgetLocationValue ( widget4 , 'top' ) ) . toBe ( 440 ) ; } ) ; it ( 'should resize widget 1 to 2 columns when the colSpan is changed to 2, widgets 2 should move down one row' , async ( ) => { expect ( await page . getWidgetLocationValue ( widget1 , 'width' ) ) . toBe ( 554 ) ; expect ( await page . getWidgetLocationValue ( widget2 , 'top' ) ) . toBe ( 0 ) ; await page . widget1ColIncrement . click ( ) ; expect ( await page . getWidgetLocationValue ( widget1 , 'width' ) ) . toBe ( 831 ) ; expect ( await page . getWidgetLocationValue ( widget2 , 'top' ) ) . toBe ( 220 ) ; } ) ; it ( 'should not resize widget 4 to 1 row when the rowSpan is changed to 1 as the minRowSpan is set to 2' , async ( ) => { expect ( await page . getWidgetLocationValue ( widget4 , 'height' ) ) . toBe ( 440 ) ; await page . widget4RowDecrement . click ( ) ; expect ( await page . getWidgetLocationValue ( widget4 , 'height' ) ) . toBe ( 440 ) ; } ) ; it ( 'should not resize widget 4 to 3 columns when the colSpan is changed to 3 as the minColSpan is set to 4' , async ( ) => { expect ( await page . getWidgetLocationValue ( widget4 , 'width' ) ) . toBe ( 1108 ) ; await page . widget4ColDecrement . click ( ) ; expect ( await page . getWidgetLocationValue ( widget4 , 'width' ) ) . toBe ( 1108 ) ; } ) ; it ( 'should resize widget 1 to 4 columns and 2 rows when the colSpan is changed to 4 and the rowSpan is changed to 2, widgets 2-4 should react correctly' , async ( ) => { expect ( await page . getWidgetLocationValue ( widget1 , 'height' ) ) . toBe ( 220 ) ; expect ( await page . getWidgetLocationValue ( widget1 , 'width' ) ) . toBe ( 554 ) ; expect ( await page . getWidgetLocationValue ( widget2 , 'top' ) ) . toBe ( 0 ) ; expect ( await page . getWidgetLocationValue ( widget2 , 'left' ) ) . toBe ( 554 ) ; expect ( await page . getWidgetLocationValue ( widget3 , 'top' ) ) . toBe ( 0 ) ; expect ( await page . getWidgetLocationValue ( widget3 , 'left' ) ) . toBe ( 831 ) ; expect ( await page . getWidgetLocationValue ( widget4 , 'top' ) ) . toBe ( 220 ) ; expect ( await page . getWidgetLocationValue ( widget4 , 'left' ) ) . toBe ( 0 ) ; await page . widget1BothIncrement . click ( ) ; await page . widget1BothIncrement . click ( ) ; expect ( await page . getWidgetLocationValue ( widget1 , 'height' ) ) . toBe ( 660 ) ; expect ( await page . getWidgetLocationValue ( widget1 , 'width' ) ) . toBe ( 1108 ) ; expect ( await page . getWidgetLocationValue ( widget2 , 'top' ) ) . toBe ( 660 ) ; expect ( await page . getWidgetLocationValue ( widget2 , 'left' ) ) . toBe ( 554 ) ; expect ( await page . getWidgetLocationValue ( widget3 , 'top' ) ) . toBe ( 660 ) ; expect ( await page . getWidgetLocationValue ( widget3 , 'left' ) ) . toBe ( 831 ) ; expect ( await page . getWidgetLocationValue ( widget4 , 'top' ) ) . toBe ( 880 ) ; expect ( await page . getWidgetLocationValue ( widget4 , 'left' ) ) . toBe ( 0 ) ; } ) ; it ( 'should resize widget 1 and widgets 2-4 should react correctly' , async ( ) => { await page . changeLayout . click ( ) ; await page . widget1BothIncrement . click ( ) ; expect ( await page . getWidgetLocationValue ( widget1 , 'height' ) ) . toBe ( 660 ) ; expect ( await page . getWidgetLocationValue ( widget1 , 'width' ) ) . toBe ( 1108 ) ; expect ( await page . getWidgetLocationValue ( widget2 , 'top' ) ) . toBe ( 880 ) ; expect ( await page . getWidgetLocationValue ( widget2 , 'left' ) ) . toBe ( 831 ) ; expect ( await page . getWidgetLocationValue ( widget3 , 'top' ) ) . toBe ( 660 ) ; expect ( await page . getWidgetLocationValue ( widget3 , 'left' ) ) . toBe ( 831 ) ; expect ( await page . getWidgetLocationValue ( widget4 , 'top' ) ) . toBe ( 1100 ) ; expect ( await page . getWidgetLocationValue ( widget4 , 'left' ) ) . toBe ( 0 ) ; } ) ; } ) ;