@@ -845,3 +845,147 @@ describe("GET /stats/dietary-restrictions", () => {
845845 ) ;
846846 } ) ;
847847} ) ;
848+
849+ describe ( "GET /stats/registrations" , ( ) => {
850+ beforeEach ( async ( ) => {
851+ await SupabaseDB . REGISTRATIONS . delete ( ) . neq ( "userId" , "non-existent" ) ;
852+ await SupabaseDB . AUTH_INFO . delete ( ) . neq ( "userId" , "non-existent" ) ;
853+
854+ await SupabaseDB . AUTH_INFO . insert ( [ AUTH_INFO_RITAM , AUTH_INFO_NATHAN ] ) ;
855+ await SupabaseDB . REGISTRATIONS . insert ( [
856+ {
857+ userId : "a1" ,
858+ name : "Ritam" ,
859+ email : "ritam@test.com" ,
860+ school : "University of Illinois" ,
861+ educationLevel : "Computer Science" ,
862+ graduationYear : "2025" ,
863+ majors : [ "Computer Science" ] ,
864+ dietaryRestrictions : [ ] ,
865+ allergies : [ ] ,
866+ gender : "Prefer not to say" ,
867+ ethnicity : [ ] ,
868+ howDidYouHear : [ ] ,
869+ personalLinks : [ ] ,
870+ opportunities : [ ] ,
871+ isInterestedMechMania : false ,
872+ isInterestedPuzzleBang : false ,
873+ } ,
874+ {
875+ userId : "a2" ,
876+ name : "Nathan" ,
877+ email : "nathan@test.com" ,
878+ school : "University of Illinois" ,
879+ educationLevel : "Computer Science" ,
880+ graduationYear : "2024" ,
881+ majors : [ "Computer Science" ] ,
882+ dietaryRestrictions : [ ] ,
883+ allergies : [ ] ,
884+ gender : "Prefer not to say" ,
885+ ethnicity : [ ] ,
886+ howDidYouHear : [ ] ,
887+ personalLinks : [ ] ,
888+ opportunities : [ ] ,
889+ isInterestedMechMania : false ,
890+ isInterestedPuzzleBang : false ,
891+ } ,
892+ ] ) ;
893+ } ) ;
894+
895+ it ( "should return the correct count of total registrations" , async ( ) => {
896+ const response = await getAsStaff ( "/stats/registrations" ) . expect (
897+ StatusCodes . OK
898+ ) ;
899+ expect ( response . body . count ) . toBe ( 2 ) ;
900+ } ) ;
901+
902+ it ( "should return 0 when no registrations exist" , async ( ) => {
903+ await SupabaseDB . REGISTRATIONS . delete ( ) . neq ( "userId" , "non-existent" ) ;
904+ const response = await getAsStaff ( "/stats/registrations" ) . expect (
905+ StatusCodes . OK
906+ ) ;
907+ expect ( response . body . count ) . toBe ( 0 ) ;
908+ } ) ;
909+ } ) ;
910+
911+ describe ( "GET /stats/event/:EVENT_ID/attendance" , ( ) => {
912+ beforeEach ( async ( ) => {
913+ await SupabaseDB . EVENTS . delete ( ) . neq ( "eventId" , uuidv4 ( ) ) ;
914+ await SupabaseDB . EVENTS . insert ( EVENT_1 ) ;
915+ } ) ;
916+
917+ it ( "should return the attendance count for a specific event" , async ( ) => {
918+ const response = await getAsStaff (
919+ `/stats/event/${ EVENT_1 . eventId } /attendance`
920+ ) . expect ( StatusCodes . OK ) ;
921+ expect ( response . body . attendanceCount ) . toBe ( EVENT_1 . attendanceCount ) ;
922+ } ) ;
923+
924+ it ( "should return 404 for a non-existent event" , async ( ) => {
925+ await getAsStaff ( `/stats/event/${ uuidv4 ( ) } /attendance` ) . expect (
926+ StatusCodes . NOT_FOUND
927+ ) ;
928+ } ) ;
929+
930+ it ( "should return 400 for an invalid event ID format" , async ( ) => {
931+ await getAsStaff ( "/stats/event/not-a-uuid/attendance" ) . expect (
932+ StatusCodes . BAD_REQUEST
933+ ) ;
934+ } ) ;
935+ } ) ;
936+
937+ describe ( "GET /stats/tier-counts" , ( ) => {
938+ beforeEach ( async ( ) => {
939+ await SupabaseDB . ATTENDEES . delete ( ) . neq ( "userId" , "non-existent" ) ;
940+ await SupabaseDB . AUTH_INFO . delete ( ) . neq ( "userId" , "non-existent" ) ;
941+
942+ await SupabaseDB . AUTH_INFO . insert ( [
943+ AUTH_INFO_RITAM ,
944+ AUTH_INFO_NATHAN ,
945+ AUTH_INFO_TIMOTHY ,
946+ ] ) ;
947+ // Setup attendees with different tiers
948+ await SupabaseDB . ATTENDEES . insert ( [
949+ { ...ATTENDEE_RITAM , currentTier : Tiers . Enum . TIER1 } ,
950+ { ...ATTENDEE_NATHAN , currentTier : Tiers . Enum . TIER2 } ,
951+ { ...ATTENDEE_TIMOTHY , currentTier : Tiers . Enum . TIER1 } ,
952+ ] ) ;
953+ } ) ;
954+
955+ it ( "should return the count of attendees in each tier" , async ( ) => {
956+ const response = await getAsStaff ( "/stats/tier-counts" ) . expect (
957+ StatusCodes . OK
958+ ) ;
959+ expect ( response . body ) . toEqual ( {
960+ TIER1 : 2 ,
961+ TIER2 : 1 ,
962+ TIER3 : 0 ,
963+ TIER4 : 0 ,
964+ } ) ;
965+ } ) ;
966+ } ) ;
967+
968+ describe ( "GET /stats/tag-counts" , ( ) => {
969+ beforeEach ( async ( ) => {
970+ await SupabaseDB . ATTENDEES . delete ( ) . neq ( "userId" , "non-existent" ) ;
971+ await SupabaseDB . AUTH_INFO . delete ( ) . neq ( "userId" , "non-existent" ) ;
972+
973+ await SupabaseDB . AUTH_INFO . insert ( [ AUTH_INFO_RITAM , AUTH_INFO_NATHAN ] ) ;
974+ // Setup attendees with overlapping tags
975+ await SupabaseDB . ATTENDEES . insert ( [
976+ { ...ATTENDEE_RITAM , tags : [ "AI" , "career_readiness" ] } ,
977+ { ...ATTENDEE_NATHAN , tags : [ "AI" , "networking" ] } ,
978+ ] ) ;
979+ } ) ;
980+
981+ it ( "should return the count of each tag used by attendees" , async ( ) => {
982+ const response = await getAsStaff ( "/stats/tag-counts" ) . expect (
983+ StatusCodes . OK
984+ ) ;
985+ expect ( response . body ) . toEqual ( {
986+ AI : 2 ,
987+ career_readiness : 1 ,
988+ networking : 1 ,
989+ } ) ;
990+ } ) ;
991+ } ) ;
0 commit comments