-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix establishment tutor can get conventions
- Loading branch information
1 parent
41ae377
commit c7bee69
Showing
2 changed files
with
52 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,17 @@ describe("Get Convention", () => { | |
.withValidatorEmails(["[email protected]"]) | ||
.build(); | ||
const convention = new ConventionDtoBuilder().withAgencyId(agency.id).build(); | ||
const conventionWithEstablishmentTutor = new ConventionDtoBuilder() | ||
.withAgencyId(agency.id) | ||
.withEstablishmentTutor({ | ||
email: "[email protected]", | ||
firstName: "John", | ||
lastName: "Doe", | ||
role: "establishment-tutor", | ||
phone: "+33602010203", | ||
job: "Job", | ||
}) | ||
.build(); | ||
let getConvention: GetConvention; | ||
let uow: InMemoryUnitOfWork; | ||
|
||
|
@@ -257,6 +268,42 @@ describe("Get Convention", () => { | |
}); | ||
}); | ||
|
||
it("that establishment tutor is also the inclusion connected user", async () => { | ||
uow.conventionRepository.setConventions([ | ||
conventionWithEstablishmentTutor, | ||
]); | ||
const user: InclusionConnectedUser = { | ||
id: "my-tutor-user-id", | ||
email: conventionWithEstablishmentTutor.establishmentTutor.email, | ||
firstName: "John", | ||
lastName: "Doe", | ||
agencyRights: [], | ||
dashboards: { agencies: {}, establishments: {} }, | ||
externalId: "john-tutor-external-id", | ||
createdAt: new Date().toISOString(), | ||
}; | ||
uow.userRepository.setInclusionConnectedUsers([user]); | ||
|
||
const jwtPayload: InclusionConnectDomainJwtPayload = { | ||
userId: user.id, | ||
}; | ||
|
||
const fetchedConvention = await getConvention.execute( | ||
{ conventionId: conventionWithEstablishmentTutor.id }, | ||
jwtPayload, | ||
); | ||
|
||
expectToEqual(fetchedConvention, { | ||
...conventionWithEstablishmentTutor, | ||
agencyName: agency.name, | ||
agencyDepartment: agency.address.departmentCode, | ||
agencyKind: agency.kind, | ||
agencySiret: agency.agencySiret, | ||
agencyCounsellorEmails: agency.counsellorEmails, | ||
agencyValidatorEmails: agency.validatorEmails, | ||
}); | ||
}); | ||
|
||
it("the user is backofficeAdmin", async () => { | ||
const backofficeAdminUser = new InclusionConnectedUserBuilder() | ||
.withIsAdmin(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