@@ -721,7 +721,7 @@ describe('WorkflowExecuteModal', () => {
721721 } ) ;
722722
723723 it ( 'disables execute button when there are errors' , ( ) => {
724- const { getByTestId } = renderWithProviders (
724+ const { getByTestId, getByText } = renderWithProviders (
725725 < WorkflowExecuteModal
726726 isTestRun = { false }
727727 definition = { null }
@@ -730,10 +730,86 @@ describe('WorkflowExecuteModal', () => {
730730 />
731731 ) ;
732732
733+ fireEvent . click ( getByText ( 'Manual' ) . closest ( 'button' ) ! ) ;
734+
733735 const executeButton = getByTestId ( 'executeWorkflowButton' ) ;
734736 expect ( executeButton ) . not . toBeDisabled ( ) ;
735737 } ) ;
736738
739+ it ( 'disables execute button on the alert tab when no rows are selected' , ( ) => {
740+ const { getByTestId } = renderWithProviders (
741+ < WorkflowExecuteModal
742+ isTestRun = { false }
743+ definition = { null }
744+ onClose = { mockOnClose }
745+ onSubmit = { mockOnSubmit }
746+ />
747+ ) ;
748+
749+ expect ( getByTestId ( 'executeWorkflowButton' ) ) . toBeDisabled ( ) ;
750+ } ) ;
751+
752+ it ( 'enables execute button on the alert tab when rows are selected' , ( ) => {
753+ const { getByTestId } = renderWithProviders (
754+ < WorkflowExecuteModal
755+ isTestRun = { false }
756+ definition = { null }
757+ onClose = { mockOnClose }
758+ onSubmit = { mockOnSubmit }
759+ />
760+ ) ;
761+
762+ const alertFormCalls = mockWorkflowExecuteAlertForm . mock . calls ;
763+ const lastAlertFormProps = alertFormCalls [ alertFormCalls . length - 1 ] ?. [ 0 ] as
764+ | { setValue ?: ( value : string ) => void }
765+ | undefined ;
766+
767+ act ( ( ) => {
768+ lastAlertFormProps ! . setValue ! ( '{"event":{"alertIds":[]}}' ) ;
769+ } ) ;
770+
771+ expect ( getByTestId ( 'executeWorkflowButton' ) ) . not . toBeDisabled ( ) ;
772+ } ) ;
773+
774+ it ( 'disables execute button on the document tab when no rows are selected' , ( ) => {
775+ const { getByTestId, getByText } = renderWithProviders (
776+ < WorkflowExecuteModal
777+ isTestRun = { false }
778+ definition = { null }
779+ onClose = { mockOnClose }
780+ onSubmit = { mockOnSubmit }
781+ />
782+ ) ;
783+
784+ fireEvent . click ( getByText ( 'Document' ) . closest ( 'button' ) ! ) ;
785+
786+ expect ( getByTestId ( 'executeWorkflowButton' ) ) . toBeDisabled ( ) ;
787+ } ) ;
788+
789+ it ( 'enables execute button on the document tab when rows are selected' , ( ) => {
790+ const { getByTestId, getByText } = renderWithProviders (
791+ < WorkflowExecuteModal
792+ isTestRun = { false }
793+ definition = { null }
794+ onClose = { mockOnClose }
795+ onSubmit = { mockOnSubmit }
796+ />
797+ ) ;
798+
799+ fireEvent . click ( getByText ( 'Document' ) . closest ( 'button' ) ! ) ;
800+
801+ const indexFormCalls = mockWorkflowExecuteIndexForm . mock . calls ;
802+ const lastIndexFormProps = indexFormCalls [ indexFormCalls . length - 1 ] ?. [ 0 ] as
803+ | { setValue ?: ( value : string ) => void }
804+ | undefined ;
805+
806+ act ( ( ) => {
807+ lastIndexFormProps ! . setValue ! ( '{"event":{"documents":[]}}' ) ;
808+ } ) ;
809+
810+ expect ( getByTestId ( 'executeWorkflowButton' ) ) . not . toBeDisabled ( ) ;
811+ } ) ;
812+
737813 it ( 'disables execute button when the event trigger reports multiple table row selections' , ( ) => {
738814 const { getByTestId, getByText } = renderWithProviders (
739815 < WorkflowExecuteModal
0 commit comments