Skip to content

Commit fb1d641

Browse files
committed
Merge branch 'main' into feature/#1959-Staging-SIMS-Prod-Environment
2 parents 5a54dfd + a494bfa commit fb1d641

9 files changed

+157
-39
lines changed

devops/Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ define DB_MIGRATIONS
4343
endef
4444

4545
define DB_MIGRATIONS_JOB_NAME
46-
"db.migrations"
46+
"$(HOST_PREFIX)db.migrations"
4747
endef
4848

4949
define API
@@ -322,12 +322,12 @@ run-db-migrations:
322322
| oc -n $(NAMESPACE) apply -f -
323323

324324
wait-for-db-migrations:
325-
while [ "$$(oc get job $(DB_MIGRATIONS_JOB_NAME) -o=jsonpath='{.status.conditions[?(@.type=="Complete")].status}' || echo "None")" != "True" ] && [ "$$WAIT_TIME" -lt "$$MAX_WAIT" ]; do sleep 5; WAIT_TIME=$$((WAIT_TIME+5)); done
326-
if [ "$$(oc get job $(DB_MIGRATIONS_JOB_NAME) -o=jsonpath='{.status.conditions[?(@.type=="Complete")].status}' || echo "None")" != "True" ]; then echo "Error: Job $(DB_MIGRATIONS_JOB_NAME) failed to complete within the specified timeout"; exit 1; fi
325+
while [ "$$(oc -n $(NAMESPACE) get job $(DB_MIGRATIONS_JOB_NAME) -o=jsonpath='{.status.conditions[?(@.type=="Complete")].status}' || echo "None")" != "True" ] && [ "$$WAIT_TIME" -lt "$$MAX_WAIT" ]; do sleep 5; WAIT_TIME=$$((WAIT_TIME+5)); done
326+
if [ "$$(oc -n $(NAMESPACE) get job $(DB_MIGRATIONS_JOB_NAME) -o=jsonpath='{.status.conditions[?(@.type=="Complete")].status}' || echo "None")" != "True" ]; then echo "Error: Job $(DB_MIGRATIONS_JOB_NAME) failed to complete within the specified timeout"; exit 1; fi
327327

328328
delete-db-migrations:
329-
@if [ -n "$(shell oc get job $(DB_MIGRATIONS_JOB_NAME) -o name 2>/dev/null)" ]; then \
330-
oc delete job $(DB_MIGRATIONS_JOB_NAME); \
329+
@if [ -n "$(shell oc -n $(NAMESPACE) get job $(DB_MIGRATIONS_JOB_NAME) -o name 2>/dev/null)" ]; then \
330+
oc -n $(NAMESPACE) delete job $(DB_MIGRATIONS_JOB_NAME); \
331331
echo "Job deleted."; \
332332
else \
333333
echo "Job not found."; \

sources/packages/backend/apps/api/src/route-controllers/assessment/_tests_/e2e/assessment.institutions.controller.getAssessmentAwardDetails.e2e-spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ describe("AssessmentInstitutionsController(e2e)-getAssessmentAwardDetails", () =
9696
disbursement.valueAmount;
9797
disbursementReceiptsValues.push(
9898
createFakeDisbursementReceiptValue(
99-
{ disbursementReceipt },
10099
{
101100
grantType: disbursement.valueCode,
102101
grantAmount: disbursement.valueAmount,
103102
},
103+
{ disbursementReceipt },
104104
),
105105
);
106106
});

sources/packages/backend/apps/api/src/route-controllers/assessment/_tests_/e2e/assessment.institutions.controller.getRequestedAssessmentSummary.e2e-spec.ts

+74-1
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,24 @@ import {
2929
StudentAppealStatus,
3030
} from "@sims/sims-db";
3131
import { saveStudentApplicationForCollegeC } from "../../../student/_tests_/e2e/student.institutions.utils";
32+
import { createFakeOfferingRequestChange } from "@sims/test-utils/factories/offering-change-request";
33+
import { TestingModule } from "@nestjs/testing";
34+
import { EducationProgramOfferingService } from "../../../../../src/services";
3235

3336
describe("AssessmentInstitutionsController(e2e)-getRequestedAssessmentSummary", () => {
3437
let app: INestApplication;
3538
let db: E2EDataSources;
3639
let collegeF: Institution;
3740
let collegeFLocation: InstitutionLocation;
41+
let appModule: TestingModule;
3842

3943
beforeAll(async () => {
40-
const { nestApplication, dataSource } = await createTestingAppModule();
44+
const { nestApplication, module, dataSource } =
45+
await createTestingAppModule();
4146
app = nestApplication;
47+
appModule = module;
4248
db = createE2EDataSources(dataSource);
49+
4350
// College F.
4451
const { institution: collegeF } = await getAuthRelatedEntities(
4552
db.dataSource,
@@ -106,6 +113,72 @@ describe("AssessmentInstitutionsController(e2e)-getRequestedAssessmentSummary",
106113
]);
107114
});
108115

116+
it(
117+
"Should not get the 'offering change' assessment requests details in the request summary " +
118+
"for an eligible application when an eligible public institution user tries to access it and " +
119+
"student offering change is pending with the ministry.",
120+
async () => {
121+
// Arrange
122+
123+
// Student has an application to the institution.
124+
const student = await saveFakeStudent(db.dataSource);
125+
126+
const currentMSFAA = createFakeMSFAANumber(
127+
{ student },
128+
{
129+
state: MSFAAStates.Signed,
130+
},
131+
);
132+
await db.msfaaNumber.save(currentMSFAA);
133+
const application = await saveFakeApplicationDisbursements(
134+
db.dataSource,
135+
{
136+
institution: collegeF,
137+
institutionLocation: collegeFLocation,
138+
student,
139+
msfaaNumber: currentMSFAA,
140+
},
141+
{ applicationStatus: ApplicationStatus.Completed },
142+
);
143+
144+
// Create pending offering change.
145+
const offeringRequestOfferings = createFakeOfferingRequestChange({
146+
currentOffering: application.currentAssessment.offering,
147+
});
148+
const [, requestedOffering] = await db.educationProgramOffering.save(
149+
offeringRequestOfferings,
150+
);
151+
const endpoint = `/institutions/assessment/student/${student.id}/application/${application.id}/requests`;
152+
const institutionUserToken = await getInstitutionToken(
153+
InstitutionTokenTypes.CollegeFUser,
154+
);
155+
156+
// Act/Assert
157+
await request(app.getHttpServer())
158+
.get(endpoint)
159+
.auth(institutionUserToken, BEARER_AUTH_TYPE)
160+
.expect(HttpStatus.OK)
161+
.expect([]);
162+
163+
// Checking the same scenario with the educationProgramOfferingService service, to make sure that a fake offering change was created.
164+
const educationProgramOfferingService = appModule.get(
165+
EducationProgramOfferingService,
166+
);
167+
const offeringChange =
168+
await educationProgramOfferingService.getOfferingRequestsByApplicationId(
169+
application.id,
170+
student.id,
171+
);
172+
173+
expect(offeringChange).toMatchObject({
174+
id: requestedOffering.id,
175+
submittedDate: requestedOffering.submittedDate,
176+
offeringStatus: requestedOffering.offeringStatus,
177+
educationProgram: { id: requestedOffering.educationProgram.id },
178+
});
179+
},
180+
);
181+
109182
it("Should throw forbidden error when the institution type is not BC Public.", async () => {
110183
// Arrange
111184
// Student submitting an application to College C.

sources/packages/backend/apps/api/src/route-controllers/assessment/assessment.aest.controller.ts

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export class AssessmentAESTController extends BaseController {
4040
): Promise<RequestAssessmentSummaryAPIOutDTO[]> {
4141
return this.assessmentControllerService.requestedStudentAssessmentSummary(
4242
applicationId,
43+
{
44+
includeOfferingChanges: true,
45+
},
4346
);
4447
}
4548

sources/packages/backend/apps/api/src/route-controllers/assessment/assessment.controller.service.ts

+25-17
Original file line numberDiff line numberDiff line change
@@ -320,32 +320,40 @@ export class AssessmentControllerService {
320320
* Get all pending and declined requests related to an application which would result
321321
* a new assessment when that request is approved.
322322
* @param applicationId application id.
323-
* @param studentId student id.
323+
* @param options options for request assessments,
324+
* - `studentId` student id.
325+
* - `includeOfferingChanges` will decide whether to include assessment
326+
* request for offering change.
324327
* @returns assessment requests or exceptions for the student application.
325328
*/
326329
async requestedStudentAssessmentSummary(
327330
applicationId: number,
328-
studentId?: number,
331+
options?: {
332+
studentId?: number;
333+
includeOfferingChanges?: boolean;
334+
},
329335
): Promise<RequestAssessmentSummaryAPIOutDTO[]> {
330336
const requestAssessmentSummary: RequestAssessmentSummaryAPIOutDTO[] = [];
331-
const offeringChange =
332-
await this.educationProgramOfferingService.getOfferingRequestsByApplicationId(
333-
applicationId,
334-
studentId,
335-
);
336-
if (offeringChange) {
337-
requestAssessmentSummary.push({
338-
id: offeringChange.id,
339-
submittedDate: offeringChange.submittedDate,
340-
status: offeringChange.offeringStatus,
341-
requestType: RequestAssessmentTypeAPIOutDTO.OfferingRequest,
342-
programId: offeringChange.educationProgram.id,
343-
});
337+
if (options?.includeOfferingChanges) {
338+
const offeringChange =
339+
await this.educationProgramOfferingService.getOfferingRequestsByApplicationId(
340+
applicationId,
341+
options?.studentId,
342+
);
343+
if (offeringChange) {
344+
requestAssessmentSummary.push({
345+
id: offeringChange.id,
346+
submittedDate: offeringChange.submittedDate,
347+
status: offeringChange.offeringStatus,
348+
requestType: RequestAssessmentTypeAPIOutDTO.OfferingRequest,
349+
programId: offeringChange.educationProgram.id,
350+
});
351+
}
344352
}
345353
const applicationExceptions =
346354
await this.applicationExceptionService.getExceptionsByApplicationId(
347355
applicationId,
348-
studentId,
356+
options?.studentId,
349357
ApplicationExceptionStatus.Pending,
350358
ApplicationExceptionStatus.Declined,
351359
);
@@ -363,7 +371,7 @@ export class AssessmentControllerService {
363371
}
364372
const appeals = await this.getPendingAndDeniedAppeals(
365373
applicationId,
366-
studentId,
374+
options?.studentId,
367375
);
368376
return requestAssessmentSummary.concat(appeals);
369377
}

sources/packages/backend/apps/api/src/route-controllers/assessment/assessment.institutions.controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class AssessmentInstitutionsController extends BaseController {
4949
): Promise<RequestAssessmentSummaryAPIOutDTO[]> {
5050
return this.assessmentControllerService.requestedStudentAssessmentSummary(
5151
applicationId,
52-
studentId,
52+
{ studentId },
5353
);
5454
}
5555

Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
import { DisbursementReceipt, DisbursementReceiptValue } from "@sims/sims-db";
2+
import faker from "faker";
23

34
/**
45
* Create fake disbursement receipt value.
6+
* @param initialValues initial values that need to be assigned
7+
* while creating a fake disbursement receipt value.
58
* @param relations dependencies.
69
* - `disbursementReceipt` related disbursement receipt.
7-
* @param options options
8-
* - `grantType` type of grant to be created.
9-
* - `grantAmount` grant amount to be created.
1010
* @returns disbursement receipt value.
1111
*/
1212
export function createFakeDisbursementReceiptValue(
13+
initialValues: Partial<DisbursementReceiptValue>,
1314
relations: {
1415
disbursementReceipt: DisbursementReceipt;
1516
},
16-
options: {
17-
grantType: string;
18-
grantAmount: number;
19-
},
2017
): DisbursementReceiptValue {
2118
const disbursementReceiptValue = new DisbursementReceiptValue();
22-
disbursementReceiptValue.grantType = options.grantType;
23-
disbursementReceiptValue.grantAmount = options.grantAmount;
19+
disbursementReceiptValue.grantType =
20+
initialValues.grantType ?? faker.random.alpha({ count: 4 });
21+
disbursementReceiptValue.grantAmount =
22+
initialValues.grantAmount ??
23+
faker.random.number({
24+
min: 1000,
25+
max: 9999,
26+
});
2427
disbursementReceiptValue.disbursementReceipt = relations.disbursementReceipt;
2528
return disbursementReceiptValue;
2629
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { EducationProgramOffering, OfferingStatus } from "@sims/sims-db";
2+
3+
/**
4+
* Create a fake offering request change.
5+
* @param options options:
6+
* - `currentOffering` current offering, which is requested for the changed, which is
7+
* already saved in the DB.
8+
* @returns the current and requested offering.
9+
*/
10+
export function createFakeOfferingRequestChange(options: {
11+
currentOffering: EducationProgramOffering;
12+
}): EducationProgramOffering[] {
13+
const now = new Date();
14+
const requestedOfferingId = options.currentOffering.id;
15+
const requestedOffering = options.currentOffering;
16+
delete requestedOffering.id;
17+
requestedOffering.offeringStatus = OfferingStatus.ChangeAwaitingApproval;
18+
requestedOffering.parentOffering =
19+
options.currentOffering.parentOffering ??
20+
({ id: requestedOfferingId } as EducationProgramOffering);
21+
requestedOffering.precedingOffering = {
22+
id: requestedOfferingId,
23+
} as EducationProgramOffering;
24+
requestedOffering.createdAt = now;
25+
requestedOffering.submittedDate = now;
26+
27+
// Update the status and audit details of current offering.
28+
const precedingOffering = new EducationProgramOffering();
29+
precedingOffering.id = requestedOfferingId;
30+
precedingOffering.offeringStatus = OfferingStatus.ChangeUnderReview;
31+
precedingOffering.updatedAt = now;
32+
return [precedingOffering, requestedOffering];
33+
}

sources/packages/web/src/views/institution/student/applicationDetails/InstitutionAssessmentsSummary.vue

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<history-assessment
1818
:applicationId="applicationId"
1919
:studentId="studentId"
20-
:viewRequestTypes="assessmentRequestTypes"
20+
:viewRequestTypes="assessmentRequestViewTypes"
2121
@viewStudentAppeal="goToStudentAppeal"
2222
@viewAssessment="gotToViewAssessment"
2323
@viewApplicationException="goToApplicationException"
@@ -51,10 +51,8 @@ export default defineComponent({
5151
setup(props) {
5252
const router = useRouter();
5353
// The assessment trigger types for which the request form must be visible by default.
54-
const assessmentRequestTypes = [
54+
const assessmentRequestViewTypes = [
5555
AssessmentTriggerType.StudentAppeal,
56-
AssessmentTriggerType.OfferingChange,
57-
AssessmentTriggerType.ScholasticStandingChange,
5856
AssessmentTriggerType.OriginalAssessment,
5957
];
6058
@@ -103,7 +101,7 @@ export default defineComponent({
103101
goToStudentAppeal,
104102
gotToViewAssessment,
105103
goToApplicationException,
106-
assessmentRequestTypes,
104+
assessmentRequestViewTypes,
107105
backRoute,
108106
};
109107
},

0 commit comments

Comments
 (0)