function selectValue ( selectPlaceholder , value ) { cy . get ( `input[aria-label="${ selectPlaceholder }"]` ) . click ( { force : true } ) . type ( value , { force : true } ) ; cy . get ( '[class*="-menu"]' ) . contains ( value ) . click ( ) ; } function changeToTenant ( tenant ) { cy . get ( '.pf-c-dropdown > button' ) . click ( ) ; cy . contains ( tenant ) . click ( ) ; } function gotoPage ( page ) { cy . get ( '#nav-toggle' ) . click ( ) ; cy . get ( `[href*="/${ page }"]` ) . click ( ) ; cy . get ( '#nav-toggle' ) . click ( ) ; } function dragCreateShift ( day , from , to ) { cy . get ( '.rbc-time-slot' ) . eq ( 0 ) . then ( ( firstTimeEle ) => { cy . get ( '.rbc-time-slot' ) . eq ( 1 ) . then ( ( secondTimeEle ) => { const twoHourYDiff = ( secondTimeEle [ 0 ] . offsetTop - firstTimeEle [ 0 ] . offsetTop ) / 2 ; const reference = Cypress . moment ( '2018-01-01T00:00' ) ; const fromDate = Cypress . moment ( `2018-01-01T${ from }` ) ; const toDate = Cypress . moment ( `2018-01-01T${ to }` ) ; const startLocation = ( Cypress . moment . duration ( fromDate . diff ( reference ) ) . asHours ( ) / 2 ) * twoHourYDiff + 10 ; const endLocation = ( Cypress . moment . duration ( toDate . diff ( reference ) ) . asHours ( ) / 2 ) * twoHourYDiff + 10 ; cy . get ( '.rbc-events-container' ) . eq ( day ) . trigger ( 'mousedown' , { force : true , x : 100 , y : startLocation } ) ; cy . get ( '.rbc-events-container' ) . eq ( day ) . trigger ( 'mousemove' , { force : true , x : 100 , y : endLocation } ) ; cy . get ( '.rbc-events-container' ) . eq ( day ) . trigger ( 'mouseup' , { force : true , x : 100 , y : endLocation } ) ; } ) ; } ) ; } function closeAlerts ( ) { cy . get ( '.pf-c-alert__action > button' , { timeout : 120000 } ) . click ( { multiple : true , force : true } ) ; } describe ( 'A new tenant can be created, who can have their own employees, spots, skills and shifts' , ( ) => { before ( ( ) => { cy . server ( ) ; cy . visit ( '/' ) ; } ) ; beforeEach ( ( ) => { cy . wait ( 3000 ) ; } ) ; it ( 'basic tenant workflow' , ( ) => { cy . get ( '[data-cy=settings]' ) . click ( ) ; cy . get ( '[data-cy=data-table-add]' ) . click ( ) ; cy . get ( '[data-cy=name]' ) . type ( 'Test Tenant' ) ; cy . get ( '[data-cy=schedule-start-date]' ) . type ( '2018-01-01' ) ; cy . get ( '[data-cy=draft-length]' ) . type ( '7' ) ; cy . get ( '[data-cy=publish-notice]' ) . type ( '7' ) ; cy . get ( '[data-cy=rotation-length]' ) . type ( '7' ) ; selectValue ( 'Select a timezone...' , 'UTC' ) ; cy . get ( '[data-cy=save]' ) . click ( ) ; closeAlerts ( ) ; changeToTenant ( 'Test Tenant' ) ; gotoPage ( 'skills' ) ; cy . get ( '[data-cy=data-table-add]' ) . click ( ) ; cy . get ( '[data-label="Name"]>input' ) . type ( 'New Skill' ) ; cy . get ( '[data-cy=data-table-save]' ) . click ( ) ; closeAlerts ( ) ; gotoPage ( 'spots' ) ; cy . get ( '[data-cy=data-table-add]' ) . click ( ) ; cy . get ( '[data-label="Name"]>input' ) . type ( 'Required Skill Spot' ) ; selectValue ( 'Select required skills...' , 'New Skill' ) ; cy . get ( '[data-cy=data-table-save]' ) . click ( ) ; closeAlerts ( ) ; gotoPage ( 'contracts' ) ; cy . get ( '[data-cy=data-table-add]' ) . click ( ) ; cy . get ( '[data-label="Name"]' ) . type ( 'New Contract' ) ; cy . get ( '[data-cy=data-table-save]' ) . click ( ) ; closeAlerts ( ) ; gotoPage ( 'employees' ) ; cy . get ( '[data-cy=data-table-add]' ) . click ( ) ; cy . get ( '[data-label="Name"]' ) . type ( 'Employee with Skills' ) ; selectValue ( 'Select a contract...' , 'New Contract' ) ; selectValue ( 'Select skill proficiencies...' , 'New Skill' ) ; cy . get ( '[data-cy=data-table-save]' ) . click ( ) ; closeAlerts ( ) ; gotoPage ( 'shift' ) ; cy . wait ( 1500 ) ; cy . get ( '[aria-label="Next Week"]' ) . click ( { force : true } ) ; dragCreateShift ( 3 , '00:00' , '06:00' ) ; cy . get ( '[aria-label="Actions"]' ) . click ( ) ; cy . contains ( 'Schedule' ) . click ( ) ; cy . wait ( 5000 ) ; closeAlerts ( ) ; cy . get ( '[aria-label="Actions"]' ) . click ( ) ; cy . contains ( 'Terminate Early' ) . click ( ) ; closeAlerts ( ) ; cy . get ( '.rbc-event-content' ) . contains ( 'Employee with Skills' ) ; } ) ; } ) ;