@@ -2078,32 +2078,14 @@ describe('Application Controller Tests', () => {
20782078 } ) ;
20792079
20802080 describe ( 'publicAppsView endpoint' , ( ) => {
2081- const createAndLoginUser = async ( ) => {
2082- const user = await prisma . userAccounts . create ( {
2083- data : await userFactory ( {
2084- mfaEnabled : false ,
2085- confirmedAt : new Date ( ) ,
2086- } ) ,
2087- } ) ;
2088-
2089- const resLogIn = await request ( app . getHttpServer ( ) )
2090- . post ( '/auth/login' )
2091- . set ( { passkey : process . env . API_PASS_KEY || '' } )
2092- . send ( {
2093- email : user . email ,
2094- password : 'Abcdef12345!' ,
2095- } as Login )
2096- . expect ( 201 ) ;
2097-
2098- return { user, cookies : resLogIn . headers [ 'set-cookie' ] } ;
2099- } ;
2100-
21012081 it ( 'should retrieve applications and counts when they exist' , async ( ) => {
21022082 const unitTypeA = await unitTypeFactorySingle (
21032083 prisma ,
21042084 UnitTypeEnum . oneBdrm ,
21052085 ) ;
2106- const { user, cookies } = await createAndLoginUser ( ) ;
2086+ const user = await prisma . userAccounts . create ( {
2087+ data : await userFactory ( ) ,
2088+ } ) ;
21072089 const juris = await prisma . jurisdictions . create ( {
21082090 data : jurisdictionFactory ( ) ,
21092091 } ) ;
@@ -2170,7 +2152,7 @@ describe('Application Controller Tests', () => {
21702152 const res = await request ( app . getHttpServer ( ) )
21712153 . get ( `/applications/publicAppsView?${ query } ` )
21722154 . set ( { passkey : process . env . API_PASS_KEY || '' } )
2173- . set ( 'Cookie' , cookies )
2155+ . set ( 'Cookie' , adminCookies )
21742156 . expect ( 200 ) ;
21752157
21762158 expect ( res . body . applicationsCount . total ) . toEqual ( 3 ) ;
@@ -2186,10 +2168,12 @@ describe('Application Controller Tests', () => {
21862168 } ) ;
21872169
21882170 it ( 'should not retrieve applications nor error when none exist' , async ( ) => {
2189- const { user, cookies } = await createAndLoginUser ( ) ;
2171+ const userA = await prisma . userAccounts . create ( {
2172+ data : await userFactory ( ) ,
2173+ } ) ;
21902174
21912175 const queryParams : PublicAppsViewQueryParams = {
2192- userId : user . id ,
2176+ userId : userA . id ,
21932177 filterType : ApplicationsFilterEnum . all ,
21942178 includeLotteryApps : true ,
21952179 page : 1 ,
@@ -2200,67 +2184,14 @@ describe('Application Controller Tests', () => {
22002184 const res = await request ( app . getHttpServer ( ) )
22012185 . get ( `/applications/publicAppsView?${ query } ` )
22022186 . set ( { passkey : process . env . API_PASS_KEY || '' } )
2203- . set ( 'Cookie' , cookies )
2187+ . set ( 'Cookie' , adminCookies )
22042188 . expect ( 200 ) ;
22052189
22062190 expect ( res . body . applicationsCount . total ) . toEqual ( 0 ) ;
22072191 expect ( res . body . items . length ) . toEqual ( 0 ) ;
22082192 expect ( res . body . meta . currentPage ) . toEqual ( 1 ) ;
22092193 expect ( res . body . meta . totalItems ) . toEqual ( 0 ) ;
22102194 } ) ;
2211-
2212- it ( 'should ignore query userId and scope results to the authenticated user' , async ( ) => {
2213- const unitTypeA = await unitTypeFactorySingle (
2214- prisma ,
2215- UnitTypeEnum . oneBdrm ,
2216- ) ;
2217- const { user : authenticatedUser , cookies } = await createAndLoginUser ( ) ;
2218- const otherUser = await prisma . userAccounts . create ( {
2219- data : await userFactory ( ) ,
2220- } ) ;
2221- const juris = await prisma . jurisdictions . create ( {
2222- data : jurisdictionFactory ( ) ,
2223- } ) ;
2224- await reservedCommunityTypeFactoryAll ( juris . id , prisma ) ;
2225- const listingOpen = await listingFactory ( juris . id , prisma , {
2226- status : ListingsStatusEnum . active ,
2227- } ) ;
2228- const listingOpenCreated = await prisma . listings . create ( {
2229- data : listingOpen ,
2230- } ) ;
2231-
2232- const app = await applicationFactory ( {
2233- unitTypeId : unitTypeA . id ,
2234- userId : authenticatedUser . id ,
2235- listingId : listingOpenCreated . id ,
2236- } ) ;
2237-
2238- await prisma . applications . create ( {
2239- data : app ,
2240- include : {
2241- applicant : true ,
2242- } ,
2243- } ) ;
2244-
2245- const queryParams : PublicAppsViewQueryParams = {
2246- userId : otherUser . id ,
2247- filterType : ApplicationsFilterEnum . all ,
2248- includeLotteryApps : true ,
2249- page : 1 ,
2250- limit : 10 ,
2251- } ;
2252- const query = stringify ( queryParams as any ) ;
2253-
2254- const res = await request ( app . getHttpServer ( ) )
2255- . get ( `/applications/publicAppsView?${ query } ` )
2256- . set ( { passkey : process . env . API_PASS_KEY || '' } )
2257- . set ( 'Cookie' , cookies )
2258- . expect ( 200 ) ;
2259-
2260- expect ( res . body . applicationsCount . total ) . toEqual ( 1 ) ;
2261- expect ( res . body . items . length ) . toEqual ( 1 ) ;
2262- expect ( res . body . items [ 0 ] . userId ) . toEqual ( authenticatedUser . id ) ;
2263- } ) ;
22642195 } ) ;
22652196
22662197 describe ( 'removePIICronJob endpoint' , ( ) => {
0 commit comments