Skip to content

Commit 6b7060f

Browse files
committed
feat(api):improve feasibility filtering logic and update tests
1 parent c4e6389 commit 6b7060f

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,32 @@ beforeAll(async () => {
4343
createFeasibilityUploadedPdfHelper({
4444
decision: "COMPLETE",
4545
}),
46+
// The status of below candidacies is incompatible with the decision
47+
// about the feasibility file. They should be ignored by the API (not counted, not returned)
48+
createFeasibilityUploadedPdfHelper(
49+
{
50+
decision: "PENDING",
51+
},
52+
"PROJET",
53+
),
54+
createFeasibilityUploadedPdfHelper(
55+
{
56+
decision: "PENDING",
57+
},
58+
"PARCOURS_ENVOYE",
59+
),
60+
createFeasibilityUploadedPdfHelper(
61+
{
62+
decision: "PENDING",
63+
},
64+
"PARCOURS_CONFIRME",
65+
),
66+
createFeasibilityUploadedPdfHelper(
67+
{
68+
decision: "PENDING",
69+
},
70+
"DOSSIER_DE_VALIDATION_ENVOYE",
71+
),
4672
]);
4773
await createCandidacyHelper({
4874
candidacyActiveStatus: "ARCHIVE",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ test("should count all (1) available feasibility for certificator user even if o
5252
const candidacy = await createCandidacyHelper({
5353
candidacyArgs: {
5454
certificationId: certification.id,
55+
status: "DOSSIER_FAISABILITE_ENVOYE",
5556
},
5657
});
5758
await createFeasibilityUploadedPdfHelper({
@@ -178,6 +179,7 @@ test("should return all (1) available feasibility for certificateur user", async
178179
candidacyArgs: {
179180
certificationId: certification.id,
180181
},
182+
candidacyActiveStatus: "DOSSIER_FAISABILITE_ENVOYE",
181183
});
182184
const feasibility = await createFeasibilityUploadedPdfHelper({
183185
decision: "PENDING",

packages/reva-api/modules/feasibility/utils/feasibility.helper.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ export type FeasibilityStatusFilter =
99
export const excludeArchivedAndDroppedOutCandidacy: Prisma.FeasibilityWhereInput =
1010
{
1111
candidacy: {
12-
candidacyStatuses: { none: { isActive: true, status: "ARCHIVE" } },
1312
candidacyDropOut: { is: null },
13+
status: {
14+
in: [
15+
"DOSSIER_FAISABILITE_ENVOYE",
16+
"DOSSIER_FAISABILITE_COMPLET",
17+
"DOSSIER_FAISABILITE_INCOMPLET",
18+
"DOSSIER_FAISABILITE_RECEVABLE",
19+
"DOSSIER_FAISABILITE_NON_RECEVABLE",
20+
],
21+
},
1422
},
1523
};
1624

@@ -21,11 +29,13 @@ export const excludeRejectedArchivedDraftAndDroppedOutCandidacy: Prisma.Feasibil
2129
decision: { in: ["REJECTED", "DRAFT"] },
2230
},
2331
candidacy: {
24-
candidacyStatuses: {
25-
none: {
26-
isActive: true,
27-
status: "ARCHIVE",
28-
},
32+
status: {
33+
in: [
34+
"DOSSIER_FAISABILITE_ENVOYE",
35+
"DOSSIER_FAISABILITE_COMPLET",
36+
"DOSSIER_FAISABILITE_INCOMPLET",
37+
"DOSSIER_FAISABILITE_RECEVABLE",
38+
],
2939
},
3040
candidacyDropOut: { is: null },
3141
},

packages/reva-api/test/helpers/entities/create-feasibility-uploaded-pdf-helper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import { Feasibility } from "@prisma/client";
1+
import { CandidacyStatusStep, Feasibility } from "@prisma/client";
22
import { prismaClient } from "../../../prisma/client";
33
import { createCandidacyHelper } from "./create-candidacy-helper";
44
import { createFileHelper } from "./create-file-helper";
55

66
export const createFeasibilityUploadedPdfHelper = async (
77
feasibilityArgs?: Partial<Feasibility>,
8+
candidacyActiveStatus?: CandidacyStatusStep,
89
) => {
9-
const candidacy = await createCandidacyHelper();
10+
const candidacy = await createCandidacyHelper({
11+
candidacyActiveStatus:
12+
candidacyActiveStatus ?? "DOSSIER_FAISABILITE_ENVOYE",
13+
});
1014
const file = await createFileHelper();
1115

1216
return prismaClient.feasibility.create({

0 commit comments

Comments
 (0)