@@ -633,21 +633,6 @@ Cypress.Commands.add('chooseMuiSelect', (label, value) => {
633633 cy . get ( '@option' ) . click ( )
634634} )
635635
636- Cypress . Commands . add ( 'selectDropdownByLabel' , ( label , value = null ) => {
637- cy . contains ( 'label' , label )
638- . parent ( )
639- . click ( )
640-
641- if ( value ) {
642- cy . contains ( 'li[role="option"]' , value )
643- . click ( )
644- } else {
645- cy . get ( 'li[role="option"]' )
646- . first ( )
647- . click ( )
648- }
649- } )
650-
651636Cypress . Commands . add ( 'assertMuiInput' , ( label , value , inputTag = 'input' ) => {
652637 cy . contains ( 'label' , label )
653638 . siblings ( '.MuiInputBase-root' )
@@ -673,13 +658,23 @@ Cypress.Commands.add('assertMuiSelectValue', (label, value) => {
673658 . contains ( value )
674659} )
675660
676- Cypress . Commands . add ( 'chooseMuiAutocomplete' , ( label , value ) => {
661+ Cypress . Commands . add ( 'chooseMuiAutocomplete' , ( label , value = null ) => {
677662 cy . contains ( 'label' , label )
678663 . siblings ( '.MuiInputBase-root' )
679664 . find ( 'input' )
680665 . click ( )
681666
682- cy . contains ( '[role="menu"] li, [role="presentation"] li' , value ) . click ( ) ;
667+ const optionSelector = '[role="menu"] li, [role="presentation"] li, [role="listbox"] li, li[role="option"]'
668+
669+ if ( value ) {
670+ cy . contains ( optionSelector , value ) . click ( ) ;
671+ return
672+ }
673+
674+ cy . get ( optionSelector )
675+ . should ( 'have.length.at.least' , 1 )
676+ . first ( )
677+ . click ( )
683678} )
684679
685680Cypress . Commands . add ( 'setModuleConfig' , ( moduleName , configFixtureFile ) => {
@@ -731,13 +726,13 @@ Cypress.Commands.add('createGrievance', (grievanceData) => {
731726
732727 // Required fields
733728 cy . enterMuiInput ( 'Grievance Title' , grievanceData . title ) ;
734- cy . selectDropdownByLabel ( 'Category' , grievanceData . category ) ;
735- cy . selectDropdownByLabel ( 'Flag' , grievanceData . flag ) ;
736- cy . selectDropdownByLabel ( 'Channel' , grievanceData . channel ) ;
729+ cy . chooseMuiAutocomplete ( 'Category' , grievanceData . category ) ;
730+ cy . chooseMuiAutocomplete ( 'Flag' , grievanceData . flag ) ;
731+ cy . chooseMuiAutocomplete ( 'Channel' , grievanceData . channel ) ;
737732
738733 // Optional fields
739734 if ( grievanceData . priority ) {
740- cy . selectDropdownByLabel ( 'Priority' , grievanceData . priority ) ;
735+ cy . chooseMuiSelect ( 'Priority' , grievanceData . priority ) ;
741736 }
742737
743738 if ( grievanceData . dateOfIncident ) {
@@ -757,7 +752,7 @@ Cypress.Commands.add('createGrievance', (grievanceData) => {
757752
758753 // Reporter type handling
759754 if ( grievanceData . reporterType ) {
760- cy . selectDropdownByLabel ( 'Reporter Type' , grievanceData . reporterType ) ;
755+ cy . chooseMuiSelect ( 'Reporter Type' , grievanceData . reporterType ) ;
761756
762757 if ( grievanceData . reporterType === 'Individual' ) {
763758 if ( grievanceData . benefitPlan ) {
@@ -766,12 +761,7 @@ Cypress.Commands.add('createGrievance', (grievanceData) => {
766761 if ( grievanceData . individual ) {
767762 cy . chooseMuiAutocomplete ( 'Individual' , grievanceData . individual ) ;
768763 } else {
769- // Select first available individual
770- cy . contains ( 'label' , 'Individual' )
771- . siblings ( '.MuiInputBase-root' )
772- . find ( 'input' )
773- . click ( ) ;
774- cy . get ( '[role="menu"] li, [role="presentation"] li' ) . first ( ) . click ( ) ;
764+ cy . chooseMuiAutocomplete ( 'Individual' ) ;
775765 }
776766 } else if ( grievanceData . reporterType === 'Beneficiary' ) {
777767 if ( grievanceData . benefitPlan ) {
@@ -780,26 +770,13 @@ Cypress.Commands.add('createGrievance', (grievanceData) => {
780770 if ( grievanceData . beneficiary ) {
781771 cy . chooseMuiAutocomplete ( 'BeneficiaryPicker' , grievanceData . beneficiary ) ;
782772 } else {
783- // Select first available beneficiary
784- cy . contains ( 'label' , 'BeneficiaryPicker' )
785- . siblings ( '.MuiInputBase-root' )
786- . find ( 'input' )
787- . click ( ) ;
788- cy . get ( '[role="menu"] li, [role="presentation"] li' )
789- . should ( 'have.length.at.least' , 1 )
790- . first ( )
791- . click ( ) ;
773+ cy . chooseMuiAutocomplete ( 'BeneficiaryPicker' ) ;
792774 }
793775 } else if ( grievanceData . reporterType === 'Attending Staff' ) {
794776 if ( grievanceData . attendingStaff ) {
795777 cy . chooseMuiAutocomplete ( 'Complainant' , grievanceData . attendingStaff ) ;
796778 } else {
797- // Select first available staff
798- cy . contains ( 'label' , 'Complainant' )
799- . siblings ( '.MuiInputBase-root' )
800- . find ( 'input' )
801- . click ( ) ;
802- cy . get ( '[role="menu"] li, [role="presentation"] li' ) . first ( ) . click ( ) ;
779+ cy . chooseMuiAutocomplete ( 'Complainant' ) ;
803780 }
804781 }
805782 }
@@ -817,7 +794,7 @@ Cypress.Commands.add('createGrievance', (grievanceData) => {
817794 cy . contains ( 'Failed to create' ) . should ( 'not.exist' ) ;
818795} ) ;
819796
820- Cypress . Commands . add ( 'updateGrievance' , ( grievanceCode , updateData ) => {
797+ Cypress . Commands . add ( 'updateGrievance' , ( grievanceCode , updateData , immutableFields = { } ) => {
821798 cy . visit ( '/front/ticket/tickets' ) ;
822799 cy . contains ( 'tfoot' , 'Rows Per Page' ) . should ( 'be.visible' ) ;
823800
@@ -833,25 +810,36 @@ Cypress.Commands.add('updateGrievance', (grievanceCode, updateData) => {
833810 cy . get ( 'button[title="Edit"]' ) . click ( ) ;
834811 } ) ;
835812
813+ if ( immutableFields . reporterType ) {
814+ cy . assertMuiInputDisabled ( 'Reporter Type' , immutableFields . reporterType ) ;
815+ }
816+
817+ if ( immutableFields . reporterFieldLabel ) {
818+ cy . assertMuiInputDisabled (
819+ immutableFields . reporterFieldLabel ,
820+ immutableFields . reporterFieldValue ?? null
821+ ) ;
822+ }
823+
836824 // Update fields (excluding reporter type and reporter info)
837825 if ( updateData . title ) {
838826 cy . enterMuiInput ( 'Title' , updateData . title ) ;
839827 }
840828
841829 if ( updateData . category ) {
842- cy . selectDropdownByLabel ( 'Category' , updateData . category ) ;
830+ cy . chooseMuiAutocomplete ( 'Category' , updateData . category ) ;
843831 }
844832
845833 if ( updateData . flag ) {
846- cy . selectDropdownByLabel ( 'Flag' , updateData . flag ) ;
834+ cy . chooseMuiAutocomplete ( 'Flag' , updateData . flag ) ;
847835 }
848836
849837 if ( updateData . channel ) {
850- cy . selectDropdownByLabel ( 'Channel' , updateData . channel ) ;
838+ cy . chooseMuiAutocomplete ( 'Channel' , updateData . channel ) ;
851839 }
852840
853841 if ( updateData . priority ) {
854- cy . selectDropdownByLabel ( 'Priority' , updateData . priority ) ;
842+ cy . chooseMuiSelect ( 'Priority' , updateData . priority ) ;
855843 }
856844
857845 if ( updateData . details ) {
@@ -901,17 +889,11 @@ Cypress.Commands.add('unlockGrievance', (grievanceCode) => {
901889 cy . contains ( 'Failed' ) . should ( 'not.exist' ) ;
902890} ) ;
903891
904- Cypress . Commands . add ( 'checkGrievanceFieldValues' , ( title , _category , flag , channel , priority = null , details = null ) => {
892+ Cypress . Commands . add ( 'checkGrievanceFieldValues' , ( title , category , flag , channel , priority = null , details = null ) => {
905893 cy . assertMuiInput ( 'Grievance Title' , title ) ;
906- // Category uses DropDownCategoryPicker (Autocomplete with object options).
907- // The API returns category as a plain string, so the Autocomplete cannot match it
908- // to an option object and shows an empty input — skip this assertion.
909- // Flag uses FlagsPicker (Autocomplete with string options → input is visible and has the value).
894+ cy . assertMuiInput ( 'Category' , category ) ;
910895 cy . assertMuiInput ( 'Flag' , flag ) ;
911- // Channel uses ChannelPicker (Autocomplete with string options → same as Flag).
912896 cy . assertMuiInput ( 'Channel' , channel ) ;
913- // Priority uses TicketPriorityPicker (ConstantBasedPicker / MUI Select).
914- // The selected text is rendered as DOM text content, so use assertMuiSelectValue.
915897 if ( priority ) {
916898 cy . assertMuiSelectValue ( 'Priority' , priority ) ;
917899 }
@@ -986,7 +968,7 @@ Cypress.Commands.add('addGrievanceComment', (commentText, commentData = {}) => {
986968 } ) ;
987969
988970 if ( commentData . reporterType ) {
989- cy . selectDropdownByLabel ( 'Reporter Type' , commentData . reporterType ) ;
971+ cy . chooseMuiSelect ( 'Reporter Type' , commentData . reporterType ) ;
990972
991973 if ( commentData . reporterType === 'Individual' ) {
992974 if ( commentData . benefitPlan ) {
@@ -995,11 +977,7 @@ Cypress.Commands.add('addGrievanceComment', (commentText, commentData = {}) => {
995977 if ( commentData . individual ) {
996978 cy . chooseMuiAutocomplete ( 'Individual' , commentData . individual ) ;
997979 } else {
998- cy . contains ( 'label' , 'Individual' )
999- . siblings ( '.MuiInputBase-root' )
1000- . find ( 'input' )
1001- . click ( ) ;
1002- cy . get ( '[role="menu"] li, [role="presentation"] li' ) . first ( ) . click ( ) ;
980+ cy . chooseMuiAutocomplete ( 'Individual' ) ;
1003981 }
1004982 } else if ( commentData . reporterType === 'Beneficiary' ) {
1005983 if ( commentData . benefitPlan ) {
@@ -1008,24 +986,13 @@ Cypress.Commands.add('addGrievanceComment', (commentText, commentData = {}) => {
1008986 if ( commentData . beneficiary ) {
1009987 cy . chooseMuiAutocomplete ( 'Beneficiary' , commentData . beneficiary ) ;
1010988 } else {
1011- cy . contains ( 'label' , 'Beneficiary' )
1012- . siblings ( '.MuiInputBase-root' )
1013- . find ( 'input' )
1014- . click ( ) ;
1015- cy . get ( '[role="menu"] li, [role="presentation"] li' )
1016- . should ( 'have.length.at.least' , 1 )
1017- . first ( )
1018- . click ( ) ;
989+ cy . chooseMuiAutocomplete ( 'Beneficiary' ) ;
1019990 }
1020991 } else if ( commentData . reporterType === 'Attending Staff' ) {
1021992 if ( commentData . attendingStaff ) {
1022993 cy . chooseMuiAutocomplete ( 'Commenter' , commentData . attendingStaff ) ;
1023994 } else {
1024- cy . contains ( 'label' , 'Commenter' )
1025- . siblings ( '.MuiInputBase-root' )
1026- . find ( 'input' )
1027- . click ( ) ;
1028- cy . get ( '[role="menu"] li, [role="presentation"] li' ) . first ( ) . click ( ) ;
995+ cy . chooseMuiAutocomplete ( 'Commenter' ) ;
1029996 }
1030997 }
1031998 }
0 commit comments