Skip to content

Commit a811d58

Browse files
committed
feat(api): added the old prefix to certificationAuthorityStructure.certificationAuthorities and CertificationAuthority.certificationAuthorityStructure prisma field. They will be superceded by fields allowing multiple structures for a certification authority
1 parent ab0ea31 commit a811d58

11 files changed

+31
-24
lines changed

packages/reva-api/modules/candidacy/security/candidacy.security.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ test("Certification local account of the feasibility file of the candidacy shoul
195195
const certification = await createCertificationHelper({
196196
certificationAuthorityStructureId:
197197
certificationAuthorityLocalAccount.certificationAuthority
198-
.certificationAuthorityStructureId,
198+
.oldCertificationAuthorityStructureId,
199199
});
200200
const candidacyInput = await createCandidacyHelper({
201201
candidacyArgs: {

packages/reva-api/modules/certification-authority/certification-authority.resolvers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ const unsafeResolvers = {
5353
certificationAuthorityId: parent.id,
5454
}),
5555
certificationAuthorityStructure: ({
56-
certificationAuthorityStructureId,
56+
oldCertificationAuthorityStructureId,
5757
}: CertificationAuthority) =>
5858
getCertificationAuthorityStructureById({
59-
certificationAuthorityStructureId,
59+
certificationAuthorityStructureId: oldCertificationAuthorityStructureId,
6060
}),
6161
account: (parent: CertificationAuthority) =>
6262
getAccountByCertificationAuthorityId({

packages/reva-api/modules/certification-authority/certification-authority.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export interface CertificationAuthority {
33
label: string;
44
contactFullName: string | null;
55
contactEmail: string | null;
6-
certificationAuthorityStructureId: string;
6+
oldCertificationAuthorityStructureId: string;
77
}
88

99
export interface CertificationAuthorityOrLocalAccount {

packages/reva-api/modules/certification-authority/features/createCertificationAuthority.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const createCertificationAuthority = async ({
4141
})),
4242
},
4343
},
44-
certificationAuthorityStructureId,
44+
oldCertificationAuthorityStructureId: certificationAuthorityStructureId,
4545
label,
4646
contactEmail,
4747
contactFullName,

packages/reva-api/modules/certification-authority/features/getCertificationAuthoritiesByStructureId.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export async function getCertificationAuthoritiesByStructureId(
1010
id: structureId,
1111
},
1212
})
13-
.certificationAuthorities();
13+
.oldCertificationAuthorities();
1414
}

packages/reva-api/modules/feasibility/feasibility.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ test("should count all (2) feasibilities for admin user", async () => {
4646
test("should count all (1) available feasibility for certificator user even if other exists on the same scope", async () => {
4747
const certification = await createCertificationHelper({});
4848
const certificationAuthority =
49-
certification.certificationAuthorityStructure?.certificationAuthorities[0];
49+
certification.certificationAuthorityStructure
50+
?.oldCertificationAuthorities[0];
5051
const candidacy = await createCandidacyHelper({
5152
candidacyArgs: {
5253
certificationId: certification.id,
@@ -107,7 +108,8 @@ test("should count no available feasibility for certificator user since he doesn
107108
test("should return a feasibilty for certificator since he is allowed to handle it", async () => {
108109
const certification = await createCertificationHelper({});
109110
const certificationAuthority =
110-
certification.certificationAuthorityStructure?.certificationAuthorities[0];
111+
certification.certificationAuthorityStructure
112+
?.oldCertificationAuthorities[0];
111113
const candidacy = await createCandidacyHelper({
112114
candidacyArgs: {
113115
certificationId: certification.id,
@@ -167,7 +169,8 @@ test("should return a feasibility error for certificator 3 since he doesn't hand
167169
test("should return all (1) available feasibility for certificateur user", async () => {
168170
const certification = await createCertificationHelper({});
169171
const certificationAuthority =
170-
certification.certificationAuthorityStructure?.certificationAuthorities[0];
172+
certification.certificationAuthorityStructure
173+
?.oldCertificationAuthorities[0];
171174
const candidacy = await createCandidacyHelper({
172175
candidacyArgs: {
173176
certificationId: certification.id,
@@ -253,7 +256,8 @@ const postFeasibilityDecision = ({
253256
test("should validate a feasibility since certificator is allowed to do so", async () => {
254257
const certification = await createCertificationHelper({});
255258
const certificationAuthority =
256-
certification.certificationAuthorityStructure?.certificationAuthorities[0];
259+
certification.certificationAuthorityStructure
260+
?.oldCertificationAuthorities[0];
257261
const candidacy = await createCandidacyHelper({
258262
candidacyArgs: {
259263
certificationId: certification.id,
@@ -318,7 +322,8 @@ test("should not validate a feasibility since certificator 3 doesn't handle it",
318322
test("should reject a feasibility since certificator is allowed to do so", async () => {
319323
const certification = await createCertificationHelper({});
320324
const certificationAuthority =
321-
certification.certificationAuthorityStructure?.certificationAuthorities[0];
325+
certification.certificationAuthorityStructure
326+
?.oldCertificationAuthorities[0];
322327
const candidacy = await createCandidacyHelper({
323328
candidacyArgs: {
324329
certificationId: certification.id,

packages/reva-api/prisma/schema.prisma

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -910,10 +910,11 @@ model ExamInfo {
910910
}
911911

912912
model CertificationAuthorityStructure {
913-
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
914-
label String @unique @db.VarChar(200)
915-
certifications Certification[]
916-
certificationAuthorities CertificationAuthority[]
913+
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
914+
label String @unique @db.VarChar(200)
915+
certifications Certification[]
916+
oldCertificationAuthorities CertificationAuthority[] @relation("old_certification_authority_on_certification_authority_structure")
917+
917918
certificationRegistryManager CertificationRegistryManager?
918919
919920
@@map("certification_authority_structure")
@@ -933,9 +934,10 @@ model CertificationAuthority {
933934
certificationAuthorityLocalAccount CertificationAuthorityLocalAccount[]
934935
DossierDeValidation DossierDeValidation[]
935936
Jury Jury[]
936-
certificationAuthorityStructure CertificationAuthorityStructure @relation(fields: [certificationAuthorityStructureId], references: [id], onDelete: Restrict)
937-
certificationAuthorityStructureId String @map("certification_authority_structure_id") @db.Uuid
938-
showLocalAccountsContactInfo Boolean @default(true) @map("show_local_accounts_contact_info")
937+
oldCertificationAuthorityStructure CertificationAuthorityStructure @relation(fields: [oldCertificationAuthorityStructureId], references: [id], onDelete: Restrict, name: "old_certification_authority_on_certification_authority_structure")
938+
oldCertificationAuthorityStructureId String @map("certification_authority_structure_id") @db.Uuid
939+
940+
showLocalAccountsContactInfo Boolean @default(true) @map("show_local_accounts_contact_info")
939941
940942
@@map("certification_authority")
941943
}

packages/reva-api/test/helpers/entities/create-candidacy-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const createCandidacyHelper = async (args?: {
8080
include: {
8181
certificationAuthorityStructure: {
8282
include: {
83-
certificationAuthorities: { include: { Account: true } },
83+
oldCertificationAuthorities: { include: { Account: true } },
8484
certificationRegistryManager: { include: { account: true } },
8585
},
8686
},

packages/reva-api/test/helpers/entities/create-certification-authority-helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const createCertificationAuthorityHelper = async (
1414
contactEmail: faker.internet.email(),
1515
contactFullName: faker.person.fullName(),
1616
label: faker.company.name(),
17-
certificationAuthorityStructureId: certificationAuthorityStructure.id,
17+
oldCertificationAuthorityStructureId: certificationAuthorityStructure.id,
1818
...certificationAuthorityArgs,
1919
Account: {
2020
create: {
@@ -26,7 +26,7 @@ export const createCertificationAuthorityHelper = async (
2626
},
2727
},
2828
include: {
29-
certificationAuthorityStructure: true,
29+
oldCertificationAuthorityStructure: true,
3030
Account: true,
3131
},
3232
});

packages/reva-api/test/helpers/entities/create-certification-authority-local-account-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const createCertificationAuthorityLocalAccountHelper = async (
2020
certificationAuthority: {
2121
include: {
2222
Account: true,
23-
certificationAuthorityStructure: {
23+
oldCertificationAuthorityStructure: {
2424
include: { certifications: true },
2525
},
2626
},

0 commit comments

Comments
 (0)