@@ -33,6 +33,7 @@ import {
3333 ORDER_EXPORT_CSV_FIELDS ,
3434 ORDER_LINE_EXPORT_CSV_FIELDS ,
3535 ORDER_LINE_FILTER_LABELS ,
36+ RESULTS_PANE_CHOOSE_FILTER_MESSAGE ,
3637} from '../../constants' ;
3738import InteractorsTools from '../../utils/interactorsTools' ;
3839import getRandomPostfix from '../../utils/stringTools' ;
@@ -41,6 +42,7 @@ import SearchHelper from '../finance/financeHelper';
4142import MultiColumnListHelper from '../multiColumnList' ;
4243import SelectInstanceModal from './modals/selectInstanceModal' ;
4344import SelectLocationModal from './modals/selectLocationModal' ;
45+ import SelectDonorModal from './modals/selectDonorModal' ;
4446import OrderLineDetails from './orderLineDetails' ;
4547
4648const path = require ( 'path' ) ;
@@ -140,6 +142,11 @@ const submitOrderLine = () => {
140142 }
141143 } ) ;
142144} ;
145+
146+ // Filters
147+ const donorFilterAccordion = Accordion ( ORDER_LINE_FILTER_LABELS . DONOR ) ;
148+ const donorLookUpTrigger = donorFilterAccordion . find ( Button ( 'Donor look-up' ) ) ;
149+
143150const checkQuantityPhysical = ( quantity ) => {
144151 cy . expect ( Accordion ( 'Cost details' ) . find ( KeyValue ( 'Quantity physical' ) ) . has ( { value : quantity } ) ) ;
145152} ;
@@ -2782,6 +2789,10 @@ export default {
27822789 MultiColumnListHelper . sortListBy ( searchResultsPane , columnName ) ;
27832790 } ,
27842791
2792+ clearFilter ( filterLabel ) {
2793+ FiltersPaneHelper . clearFilter ( filtersPane , filterLabel ) ;
2794+ } ,
2795+
27852796 filterByCheckboxOptions ( filterLabel , options = [ ] ) {
27862797 FiltersPaneHelper . filterByCheckboxes ( filtersPane , filterLabel , options ) ;
27872798 } ,
@@ -2798,6 +2809,25 @@ export default {
27982809 this . filterByMultiSelectOptions ( ORDER_LINE_FILTER_LABELS . FUND_CODE , codes ) ;
27992810 } ,
28002811
2812+ removeMultiSelectChips ( filterLabel , values = [ ] ) {
2813+ FiltersPaneHelper . removeMultiSelectChips ( filtersPane , filterLabel , values ) ;
2814+ } ,
2815+
2816+ filterByDonors ( names = [ ] ) {
2817+ FiltersPaneHelper . expandFilterAccordion ( filtersPane , ORDER_LINE_FILTER_LABELS . DONOR ) ;
2818+ cy . expect ( donorLookUpTrigger . exists ( ) ) ;
2819+ cy . do ( donorLookUpTrigger . click ( ) ) ;
2820+ SelectDonorModal . waitLoading ( ) ;
2821+ SelectDonorModal . assertDonorsListIncludes ( names ) ;
2822+ SelectDonorModal . selectDonors ( names ) ;
2823+ SelectDonorModal . submitSelectedDonors ( ) ;
2824+ SelectDonorModal . assertModalClosed ( ) ;
2825+ } ,
2826+
2827+ assertNoFiltersApplied ( ) {
2828+ cy . expect ( searchResultsPane . find ( HTML ( including ( RESULTS_PANE_CHOOSE_FILTER_MESSAGE ) ) ) . exists ( ) ) ;
2829+ } ,
2830+
28012831 assertResultsCount ( expectedCount ) {
28022832 searchResultsPane
28032833 . find (
@@ -2806,11 +2836,34 @@ export default {
28062836 . exists ( ) ;
28072837 } ,
28082838
2839+ assertOrderLinesResults ( rowsConfig ) {
2840+ cy . expect ( searchResultsPane . exists ( ) ) ;
2841+ MultiColumnListHelper . assertRowsCellsContent ( searchResultsPane , rowsConfig ) ;
2842+ this . assertResultsCount ( rowsConfig . length ) ;
2843+ } ,
2844+
28092845 assertResultsActionIsDisabled ( actionButtonName , expectedDisabledState = true ) {
28102846 const actionsBtn = searchResultsPane . find ( actionsButton ) ;
28112847
28122848 cy . do ( actionsBtn . click ( ) ) ;
28132849 cy . do ( Button ( actionButtonName ) . has ( { disabled : expectedDisabledState } ) ) ;
28142850 cy . do ( actionsBtn . click ( ) ) ;
28152851 } ,
2852+
2853+ assertMultiSelectFilterValues :
2854+ FiltersPaneHelper . buildMultiSelectFilterValuesAssertion ( filtersPane ) ,
2855+ assertMultiSelectFilterOptions :
2856+ FiltersPaneHelper . buildMultiSelectFilterOptionsValuesAssertion ( filtersPane ) ,
2857+
2858+ assertFundCodeFilterValues ( expectedValues , options = { } ) {
2859+ this . assertMultiSelectFilterValues ( ORDER_LINE_FILTER_LABELS . FUND_CODE , expectedValues , options ) ;
2860+ } ,
2861+
2862+ assertFundCodeFilterOptions ( expectedOptions , options = { } ) {
2863+ this . assertMultiSelectFilterOptions (
2864+ ORDER_LINE_FILTER_LABELS . FUND_CODE ,
2865+ expectedOptions ,
2866+ options ,
2867+ ) ;
2868+ } ,
28162869} ;
0 commit comments