@@ -219,20 +219,85 @@ describe('Feedback Flow API', () => {
219219 expect ( response . data . error ) . toBe ( 'ID already exists in the database' ) ;
220220 } ) ;
221221
222+ test ( '70. Should filter testers by a single id using POST /testers' , async ( ) => {
223+ // Use the authenticated user id added to TESTER in test 40
224+ const response = await api . post ( '/testers' , { ids : testerId } ) ;
225+ expect ( response . status ) . toBe ( 200 ) ;
226+ expect ( response . data . success ) . toBe ( true ) ;
227+ expect ( response . data . data ) . toBeDefined ( ) ;
228+ // At least one tester should match the provided id
229+ expect ( response . data . total ) . toBeGreaterThanOrEqual ( 1 ) ;
230+ // Ensure that one of the returned testers owns the id provided
231+ const matching = response . data . data . find ( ( t : any ) => ( t . ids || [ ] ) . includes ( testerId ) ) ;
232+ expect ( matching ) . toBeDefined ( ) ;
233+ } ) ;
234+
235+ test ( '71. Should filter testers by multiple ids using POST /testers' , async ( ) => {
236+ // Compose multiple ids: the authenticated user and a known other id
237+ const otherId = 'auth0|0987654321' ;
238+ const response = await api . post ( '/testers' , { ids : [ testerId , otherId ] } ) ;
239+ expect ( response . status ) . toBe ( 200 ) ;
240+ expect ( response . data . success ) . toBe ( true ) ;
241+ expect ( response . data . data ) . toBeDefined ( ) ;
242+ // The total should be greater than or equal to 2 (the two ids match distinct testers)
243+ expect ( response . data . total ) . toBeGreaterThanOrEqual ( 2 ) ;
244+ // Each returned tester should have at least one of the provided ids
245+ for ( const t of response . data . data ) {
246+ const ids = t . ids || [ ] ;
247+ expect ( ids . some ( ( id : string ) => id === testerId || id === otherId ) ) . toBeTruthy ( ) ;
248+ }
249+ } ) ;
250+
251+ test ( '72. Should paginate results when limit provided in POST /testers' , async ( ) => {
252+ // Retrieve all testers to gather test ids
253+ const all = await api . get ( '/testers' ) ;
254+ expect ( all . data . data ) . toBeDefined ( ) ;
255+ const allTesters = all . data . data ;
256+ const itemIds : string [ ] = [ ] ;
257+ allTesters . forEach ( ( t : any ) => {
258+ ( t . ids || [ ] ) . forEach ( ( i : string ) => itemIds . push ( i ) ) ;
259+ } ) ;
260+ // Request with pagination limit=1 and page=1
261+ const response = await api . post ( '/testers' , { ids : itemIds , limit : 1 , page : 1 } ) ;
262+ expect ( response . status ) . toBe ( 200 ) ;
263+ expect ( response . data . success ) . toBe ( true ) ;
264+ expect ( response . data . data . length ) . toBe ( 1 ) ;
265+ // total should match the number of unique testers matched by ids
266+ expect ( response . data . total ) . toBeGreaterThanOrEqual ( 1 ) ;
267+ } ) ;
268+
269+ test ( '73. Should return all matches when limit not provided in POST /testers' , async ( ) => {
270+ // Retrieve all testers to gather test ids
271+ const all = await api . get ( '/testers' ) ;
272+ expect ( all . data . data ) . toBeDefined ( ) ;
273+ const allTesters = all . data . data ;
274+ const itemIds : string [ ] = [ ] ;
275+ allTesters . forEach ( ( t : any ) => {
276+ ( t . ids || [ ] ) . forEach ( ( i : string ) => itemIds . push ( i ) ) ;
277+ } ) ;
278+ // Request without pagination
279+ const response = await api . post ( '/testers' , { ids : itemIds } ) ;
280+ expect ( response . status ) . toBe ( 200 ) ;
281+ expect ( response . data . success ) . toBe ( true ) ;
282+ // Without limit, the entire result should be returned
283+ expect ( response . data . data . length ) . toBe ( response . data . total ) ;
284+ expect ( response . data . page ) . toBe ( 1 ) ;
285+ } ) ;
286+
222287 test ( '900. Should return an Auth0 management token from the system endpoint (if configured)' , async ( ) => {
223288 // Only run if Auth0 client credentials are configured in the environment
224- const AUTH0_CLIENT_ID = process . env . AUTH0_CLIENT_ID || '' ;
225- const AUTH0_CLIENT_SECRET = process . env . AUTH0_CLIENT_SECRET || '' ;
289+ const AUTH0_MANAGEMENT_API_CLIENT_ID = process . env . AUTH0_MANAGEMENT_API_CLIENT_ID || '' ;
290+ const AUTH0_MANAGEMENT_API_CLIENT_SECRET = process . env . AUTH0_MANAGEMENT_API_CLIENT_SECRET || '' ;
226291 const AUTH0_DOMAIN = process . env . AUTH0_DOMAIN || '' ;
227292
228- if ( ! AUTH0_CLIENT_ID || ! AUTH0_CLIENT_SECRET || ! AUTH0_DOMAIN ) {
293+ if ( ! AUTH0_MANAGEMENT_API_CLIENT_ID || ! AUTH0_MANAGEMENT_API_CLIENT_SECRET || ! AUTH0_DOMAIN ) {
229294 // Skip this test if credentials are not present (local environment)
230295 console . warn ( 'Skipping Auth0 management token test because AUTH0_CLIENT_* or AUTH0_DOMAIN is not set' ) ;
231296 return ;
232297 }
233298
234299 // Attempt to call the system endpoint to get a management token
235- const response = await api . post ( '/api/ __auth0/token' , { } ) ;
300+ const response = await api . post ( '/__auth0/token' , { } ) ;
236301
237302 // If we are not permitted to call the endpoint, we can get a 403
238303 if ( response . status === 403 ) {
0 commit comments