@@ -160,6 +160,42 @@ module.exports = () => {
160160 expect ( runs ) . to . lengthOf ( 6 ) ;
161161 } ) ;
162162
163+ it ( 'should successfully filter with single beamType' , async ( ) => {
164+ const beamType = 'p-p' ;
165+ const response = await request ( server ) . get ( `/api/runs?filter[beamTypes]=${ beamType } ` ) ;
166+
167+ expect ( response . status ) . to . equal ( 200 ) ;
168+ const { data : runs } = response . body ;
169+
170+ expect ( runs ) . to . be . an ( 'array' ) ;
171+ expect ( runs ) . to . have . lengthOf . greaterThan ( 0 ) ;
172+ expect ( runs . every ( ( { lhcFill } ) => lhcFill ?. beamType === beamType ) ) . to . be . true ;
173+ } ) ;
174+
175+ it ( 'should successfully filter with multiple beamTypes' , async ( ) => {
176+ const beamTypes = [ 'p-p' , 'Pb-Pb' ] ;
177+ const response = await request ( server ) . get ( `/api/runs?filter[beamTypes]=${ beamTypes . join ( ',' ) } ` ) ;
178+
179+ expect ( response . status ) . to . equal ( 200 ) ;
180+ const { data : runs } = response . body ;
181+
182+ expect ( runs ) . to . be . an ( 'array' ) ;
183+ expect ( runs ) . to . have . lengthOf . greaterThan ( 0 ) ;
184+ expect ( runs . every ( ( { lhcFill } ) => beamTypes . includes ( lhcFill ?. beamType ) ) ) . to . be . true ;
185+ } ) ;
186+
187+ it ( 'should return 400 if beamTypes filter has the incorrect format' , async ( ) => {
188+ const beamTypeString = 'DOES NOT EXIST' ;
189+ const response = await request ( server ) . get ( `/api/runs?filter[beamTypes]=${ beamTypeString } ` ) ;
190+
191+ expect ( response . status ) . to . equal ( 400 ) ;
192+
193+ const { errors : [ error ] } = response . body ;
194+
195+ expect ( error . title ) . to . equal ( 'Invalid Attribute' ) ;
196+ expect ( error . detail ) . to . equal ( `Invalid beam type format: ${ beamTypeString } ` ) ;
197+ } ) ;
198+
163199 it ( 'should return 400 if beamModes filter has the incorrect format' , async ( ) => {
164200 const beamModeString = '*THERE\'S NON LETTERS IN HERE' ;
165201 const response = await request ( server ) . get ( `/api/runs?filter[beamModes]=${ beamModeString } ` ) ;
0 commit comments