@@ -2,9 +2,11 @@ import { faker } from '@faker-js/faker';
22import {
33 AllocationTimeUnits ,
44 DataType ,
5+ EmailStatusActionRecipients ,
56 FeatureId ,
67 ProposalEndStatus ,
78 SettingsId ,
9+ StatusActionType ,
810 TemplateCategoryId ,
911 TemplateGroupId ,
1012 WorkflowType ,
@@ -143,6 +145,7 @@ context('Proposal tests', () => {
143145 cy . addStatusToWorkflow ( {
144146 statusId : initialDBData . proposalStatuses . feasibilityReview . id ,
145147 workflowId : result . createWorkflow . id ,
148+ posY : 200 ,
146149 } ) ;
147150 createdWorkflowId = result . createWorkflow . id ;
148151 }
@@ -896,6 +899,79 @@ context('Proposal tests', () => {
896899 ) ;
897900 } ) ;
898901
902+ it ( 'User officer should be able to opt-in to run status actions when changing status' , ( ) => {
903+ const statusActionConfig = {
904+ recipientsWithEmailTemplate : [
905+ {
906+ recipient : {
907+ name : EmailStatusActionRecipients . PI ,
908+ description : '' ,
909+ } ,
910+ emailTemplate : {
911+ id : initialDBData . emailTemplates . template1 . id ,
912+ name : initialDBData . emailTemplates . template1 . name ,
913+ } ,
914+ combineEmails : true ,
915+ } ,
916+ ] ,
917+ } ;
918+
919+ // Add a status with a connection from DRAFT and attach a status action
920+ cy . addStatusToWorkflow ( {
921+ statusId : initialDBData . proposalStatuses . feasibilityReview . id ,
922+ workflowId : initialDBData . workflows . defaultWorkflow . id ,
923+ prevId :
924+ initialDBData . workflows . defaultWorkflow . workflowStatuses . draft . id ,
925+ posX : 0 ,
926+ posY : 200 ,
927+ } ) . then ( ( result ) => {
928+ cy . addConnectionStatusActions ( {
929+ actions : [
930+ {
931+ actionId : 1 ,
932+ actionType : StatusActionType . EMAIL ,
933+ config : JSON . stringify ( statusActionConfig ) ,
934+ } ,
935+ ] ,
936+ connectionId : result . createWorkflowConnection . id ,
937+ workflowId : initialDBData . workflows . defaultWorkflow . id ,
938+ } ) ;
939+ } ) ;
940+
941+ cy . login ( 'officer' ) ;
942+ cy . visit ( '/' ) ;
943+
944+ cy . contains ( newProposalTitle ) . parent ( ) . find ( '[type="checkbox"]' ) . check ( ) ;
945+
946+ cy . get ( '[data-cy="change-proposal-status"]' ) . click ( ) ;
947+
948+ cy . finishedLoading ( ) ;
949+
950+ cy . get ( '[role="presentation"] .MuiDialogContent-root' ) . as ( 'dialog' ) ;
951+
952+ // Select the status that has a connection with actions
953+ cy . get ( '@dialog' ) . find ( '#selectedWorkflowStatusId-input' ) . click ( ) ;
954+ cy . get ( '[role="listbox"]' )
955+ . contains ( initialDBData . proposalStatuses . feasibilityReview . name )
956+ . click ( ) ;
957+
958+ // The run status actions checkbox should appear and be unchecked
959+ cy . get ( '[data-cy="run-status-actions-checkbox"] input' )
960+ . should ( 'exist' )
961+ . should ( 'not.be.checked' ) ;
962+
963+ // Check it to opt-in to running status actions
964+ cy . get ( '[data-cy="run-status-actions-checkbox"] input' ) . check ( ) ;
965+
966+ // Should be able to submit the status change
967+ cy . get ( '[data-cy="submit-proposal-status-change"]' ) . click ( ) ;
968+
969+ cy . notification ( {
970+ variant : 'success' ,
971+ text : 'status changed successfully' ,
972+ } ) ;
973+ } ) ;
974+
899975 it ( 'Should be able to delete proposal' , ( ) => {
900976 cy . login ( 'user1' , initialDBData . roles . user ) ;
901977 cy . visit ( '/' ) ;
0 commit comments