-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fixes from hba into core (#3910)
* fix: limit the characters for name on user (#667) * fix: fixes password out of date error messaging (#669) * fix: fixes password out of date error messaging * fix: prod error fixes * fix: test fix * fix: public site fix take 2 (#670) * feat: new endpoint, forgot pwd fix (#671) * feat: new endpoint, forgot pwd fix * feat: using new endpoint to public * fix: update per morgan * fix: updates to pr * fix: new test to get us over coverage * fix: update per morgan * fix: add all of the jurisdiction data to external (#672) * fix: add all of the jurisdiction data to external * fix: use correct field name * fix: add security around application list (#674) * fix: add security around application list * fix: test fixes * fix: coverage requirement drop --------- Co-authored-by: Morgan Ludtke <[email protected]>
- Loading branch information
1 parent
fcb3631
commit 71c8a12
Showing
18 changed files
with
190 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
api/src/dtos/applications/most-recent-application-query-params.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Expose } from 'class-transformer'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsString } from 'class-validator'; | ||
import { ValidationsGroupsEnum } from '../../enums/shared/validation-groups-enum'; | ||
export class MostRecentApplicationQueryParams { | ||
@Expose() | ||
@ApiProperty({ | ||
type: String, | ||
example: 'userId', | ||
}) | ||
@IsString({ groups: [ValidationsGroupsEnum.default] }) | ||
userId: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { | |
} from '@prisma/client'; | ||
import { randomUUID } from 'crypto'; | ||
import dayjs from 'dayjs'; | ||
import { Request as ExpressRequest } from 'express'; | ||
import { PrismaService } from '../../../src/services/prisma.service'; | ||
import { ApplicationService } from '../../../src/services/application.service'; | ||
import { ApplicationQueryParams } from '../../../src/dtos/applications/application-query-params.dto'; | ||
|
@@ -268,6 +269,12 @@ describe('Testing application service', () => { | |
}); | ||
|
||
it('should get applications from list() when applications are available', async () => { | ||
const requestingUser = { | ||
firstName: 'requesting fName', | ||
lastName: 'requesting lName', | ||
email: '[email protected]', | ||
jurisdictions: [{ id: 'juris id' }], | ||
} as unknown as User; | ||
const date = new Date(); | ||
const mockedValue = mockApplicationSet(3, date); | ||
prisma.applications.findMany = jest.fn().mockResolvedValue(mockedValue); | ||
|
@@ -284,7 +291,11 @@ describe('Testing application service', () => { | |
page: 1, | ||
}; | ||
|
||
expect(await service.list(params)).toEqual({ | ||
expect( | ||
await service.list(params, { | ||
user: requestingUser, | ||
} as unknown as ExpressRequest), | ||
).toEqual({ | ||
items: mockedValue.map((mock) => ({ ...mock, flagged: true })), | ||
meta: { | ||
currentPage: 1, | ||
|
@@ -1588,4 +1599,57 @@ describe('Testing application service', () => { | |
|
||
expect(canOrThrowMock).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('should get most recent application for a user', async () => { | ||
const date = new Date(); | ||
const mockedValue = mockApplication(3, date); | ||
prisma.applications.findUnique = jest.fn().mockResolvedValue(mockedValue); | ||
prisma.applications.findFirst = jest | ||
.fn() | ||
.mockResolvedValue({ id: mockedValue.id }); | ||
|
||
expect(await service.mostRecentlyCreated({ userId: 'example Id' })).toEqual( | ||
mockedValue, | ||
); | ||
expect(prisma.applications.findFirst).toHaveBeenCalledWith({ | ||
select: { | ||
id: true, | ||
}, | ||
orderBy: { createdAt: 'desc' }, | ||
where: { | ||
userId: 'example Id', | ||
}, | ||
}); | ||
expect(prisma.applications.findUnique).toHaveBeenCalledWith({ | ||
where: { | ||
id: mockedValue.id, | ||
}, | ||
include: { | ||
userAccounts: true, | ||
applicant: { | ||
include: { | ||
applicantAddress: true, | ||
applicantWorkAddress: true, | ||
}, | ||
}, | ||
applicationsMailingAddress: true, | ||
applicationsAlternateAddress: true, | ||
alternateContact: { | ||
include: { | ||
address: true, | ||
}, | ||
}, | ||
accessibility: true, | ||
demographics: true, | ||
householdMember: { | ||
include: { | ||
householdMemberAddress: true, | ||
householdMemberWorkAddress: true, | ||
}, | ||
}, | ||
listings: true, | ||
preferredUnitTypes: true, | ||
}, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.