Skip to content

Commit

Permalink
Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bottle7 committed Jul 26, 2023
1 parent 6493458 commit 28c64a7
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 189 deletions.
20 changes: 9 additions & 11 deletions src/backend/src/modules/pia-intake/pia-intake.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,17 @@ export class PiaIntakeService {
) {
// skip this where clause
} else {
const allStatuses = Object.values(PiaIntakeStatusEnum);
const exceptions = [
PiaIntakeStatusEnum.INCOMPLETE, // can never see PIAs of other users in Incomplete status
PiaIntakeStatusEnum.COMPLETE, // can only see complete if explicitly requested
];
const statusIn = allStatuses.filter((s) => !exceptions.includes(s));
whereClause.push({
...commonWhereClause,
ministry: In(mpoMinistries),
status: Not(PiaIntakeStatusEnum.INCOMPLETE),
});
}
status: In(statusIn),
});}
}

// Scenario 3: As a CPO, retrieve all pia-intakes in CPO_Review
Expand All @@ -290,16 +295,9 @@ export class PiaIntakeService {
invitee: {
createdByGuid: user.idir_user_guid,
},
status: Not(PiaIntakeStatusEnum.COMPLETE),
});

// Scenario 5: Return COMPLETE PIAs only if queried and if the user is a drafter, invitee, or MPO on the PIA
if (query.filterByStatus === PiaIntakeStatusEnum.COMPLETE) {
whereClause.push({
...commonWhereClause,
status: PiaIntakeStatusEnum.COMPLETE,
});
}

// searchText logic - if there is a search text, find the matching titles OR drafter names
if (query.searchText) {
const searchOperator = ILike(`%${query.searchText}%`);
Expand Down
Loading

0 comments on commit 28c64a7

Please sign in to comment.