import TeamCredentials from '../support/types/teamCredentials' ; describe ( 'Conduct Retro' , ( ) => { const teamCredentials = { teamName : 'Test Conduct Retro' , teamId : 'test-conduct-retro' , password : 'Retro1234' , jwt : '' , } as TeamCredentials ; before ( ( ) => { cy . createTeamIfNecessaryAndLogin ( teamCredentials ) ; clearBoard ( ) ; cy . enterThought ( 'happy' , 'Good flow to our work this week' ) ; cy . enterThought ( 'happy' , 'Switching to e2e was a good idea' ) ; cy . enterThought ( 'happy' , `I'm a little uneasy about sharing this with the team` ) ; cy . enterThought ( 'confused' , 'How do I prevent end to end testing from being flaky?' ) ; cy . enterThought ( 'unhappy' , 'I wish end to end tests were faster' ) ; enterActionItems ( 'Increase Code Coverage' ) ; enterActionItems ( 'Speed Up Tests' ) ; starThought ( 'happy' , 'Good flow to our work this week' ) ; starThought ( 'happy' , 'Good flow to our work this week' ) ; thoughtDiscussed ( 'happy' , 'Switching to e2e was a good idea' ) ; deleteThought ( 'happy' , `I'm a little uneasy about sharing this with the team` ) ; } ) ; after ( ( ) => { clearBoard ( ) ; } ) ; describe ( 'Happy Column' , ( ) => { it ( 'There are two thoughts in happy column' , ( ) => { confirmNumberOfThoughtsInColumn ( 'happy' , 2 ) ; } ) ; it ( 'The first thought has two stars' , ( ) => { cy . get ( `rq-thoughts-column rq-task.happy` ) . each ( ( input ) => { if ( 'Good flow to our work this week' === input . find ( 'textarea' ) . val ( ) ) { expect ( input . find ( 'div.star-count' ) [ 0 ] . innerText . trim ( ) ) . toEqual ( '2' ) ; } } ) ; } ) ; it ( 'The second thought was discussed' , ( ) => { cy . get ( `rq-thoughts-column rq-task.happy` ) . each ( ( input ) => { if ( 'Switching to e2e was a good idea' === input . find ( 'textarea' ) . val ( ) ) { expect ( input . find ( 'div.complete-container div.checkbox.completed-task' ) . length ) . toEqual ( 1 ) ; } } ) ; } ) ; } ) ; describe ( 'Other Columns' , ( ) => { it ( 'There is one thought in the confused column' , ( ) => { confirmNumberOfThoughtsInColumn ( 'confused' , 1 ) ; } ) ; it ( 'There is one thought in the sad column' , ( ) => { confirmNumberOfThoughtsInColumn ( 'sad' , 1 ) ; } ) ; it ( 'There are two action items' , ( ) => { cy . get ( `rq-actions-column rq-action-item-task` ) . should ( 'have.length' , 2 ) ; } ) ; } ) ; } ) ; function enterActionItems ( actionItem ) { cy . get ( `rq-actions-column` ) . find ( 'input[placeholder="Enter an Action Item"]' ) . type ( `${ actionItem }{enter}` ) ; } function clearBoard ( ) { cy . enterThought ( 'happy' , 'first thought' ) ; enterActionItems ( 'first action item' ) ; cy . get ( `rq-thoughts-column rq-task` ) . each ( ( input ) => { deleteCard ( input ) ; } ) . then ( ( ) => { cy . get ( `rq-actions-column rq-action-item-task` ) . each ( ( actionItem ) => { deleteCard ( actionItem ) ; } ) ; } ) ; } function deleteCard ( card ) { card . find ( `div.container.delete-container` ) . click ( ) ; card . find ( `rq-deletion-overlay.ng-star-inserted div.button-container rq-button.delete-accept-button.primary` ) . click ( ) ; } function starThought ( columnClass , thought ) { cy . get ( `rq-thoughts-column rq-task.${ columnClass }` ) . each ( ( input ) => { if ( thought === input . find ( 'textarea' ) . val ( ) ) { input . find ( 'div.star-count-container' ) . click ( ) ; } } ) ; } function thoughtDiscussed ( columnClass , thought ) { cy . get ( `rq-thoughts-column rq-task.${ columnClass }` ) . each ( ( input ) => { if ( thought === input . find ( 'textarea' ) . val ( ) ) { input . find ( 'div.complete-container' ) . click ( ) ; } } ) ; } function deleteThought ( columnClass , thought ) { cy . get ( `rq-thoughts-column rq-task.${ columnClass }` ) . each ( ( input ) => { if ( thought === input . find ( 'textarea' ) . val ( ) ) { deleteCard ( input ) ; } } ) ; } function confirmNumberOfThoughtsInColumn ( columnClass , expectedCount ) { cy . get ( `rq-thoughts-column rq-task.${ columnClass } textarea` ) . should ( 'have.length' , expectedCount ) ; }