Skip to content

Commit

Permalink
Merge branch 'main' into feature/#1862-uxui-for-ignore-restriction-by…
Browse files Browse the repository at this point in the history
…pass-list
  • Loading branch information
lewischen-aot committed Sep 27, 2024
2 parents 4fad8d2 + 9344186 commit 34c9ec5
Show file tree
Hide file tree
Showing 17 changed files with 817 additions and 229 deletions.
3 changes: 3 additions & 0 deletions sources/packages/backend/apps/api/src/app.aest.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
ProgramYearService,
CASSupplierService,
ApplicationRestrictionBypassService,
CRAIncomeVerificationService,
} from "./services";
import {
SupportingUserAESTController,
Expand Down Expand Up @@ -191,6 +192,8 @@ import { ECertIntegrationModule } from "@sims/integrations/esdc-integration";
ProgramYearService,
CASSupplierService,
ApplicationRestrictionBypassService,
CRAIncomeVerificationService,
SupportingUserService,
],
})
export class AppAESTModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
ApplicationBulkWithdrawalImportValidationService,
ProgramYearService,
AnnouncementService,
CRAIncomeVerificationService,
SupportingUserService,
} from "./services";
import {
ApplicationControllerService,
Expand Down Expand Up @@ -186,6 +188,8 @@ import { ECertIntegrationModule } from "@sims/integrations/esdc-integration";
ProgramYearService,
ReportControllerService,
ReportService,
CRAIncomeVerificationService,
SupportingUserService,
],
})
export class AppInstitutionsModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { HttpStatus, INestApplication } from "@nestjs/common";
import * as request from "supertest";
import {
AESTGroups,
BEARER_AUTH_TYPE,
createTestingAppModule,
getAESTToken,
} from "../../../testHelpers";
import {
E2EDataSources,
MSFAAStates,
createE2EDataSources,
createFakeMSFAANumber,
saveFakeApplicationDisbursements,
saveFakeStudent,
} from "@sims/test-utils";
import {
ApplicationStatus,
AssessmentTriggerType,
COEStatus,
MSFAANumber,
OfferingIntensity,
ProgramInfoStatus,
Student,
} from "@sims/sims-db";

describe("ApplicationAESTController(e2e)-getApplicationProgressDetails", () => {
let app: INestApplication;
let db: E2EDataSources;
let sharedStudent: Student;
let sharedPartTimeSignedMSFAANumber: MSFAANumber;

beforeAll(async () => {
const { nestApplication, dataSource } = await createTestingAppModule();
app = nestApplication;
db = createE2EDataSources(dataSource);
// Create a student with valid SIN and valid MSFAA number.
sharedStudent = await saveFakeStudent(db.dataSource);
sharedPartTimeSignedMSFAANumber = createFakeMSFAANumber(
{ student: sharedStudent },
{
msfaaState: MSFAAStates.Signed,
msfaaInitialValues: { offeringIntensity: OfferingIntensity.partTime },
},
);
await db.msfaaNumber.save(sharedPartTimeSignedMSFAANumber);
});

it(
"Should get the status of all requests and confirmations in student application" +
" when the application is in 'Completed' status with original assessment and valid MSFAA Number" +
" and COE is completed and offering intensity is part-time.",
async () => {
// Arrange
const application = await saveFakeApplicationDisbursements(
db.dataSource,
{
student: sharedStudent,
msfaaNumber: sharedPartTimeSignedMSFAANumber,
},
{
offeringIntensity: OfferingIntensity.partTime,
applicationStatus: ApplicationStatus.Completed,
pirStatus: ProgramInfoStatus.notRequired,
firstDisbursementInitialValues: { coeStatus: COEStatus.completed },
},
);

const endpoint = `/aest/application/${application.id}/progress-details`;
// As the feature is accessible for all groups, using a group other than business administrators.
const token = await getAESTToken(AESTGroups.Operations);

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect({
applicationStatus: ApplicationStatus.Completed,
applicationStatusUpdatedOn:
application.applicationStatusUpdatedOn.toISOString(),
pirStatus: ProgramInfoStatus.notRequired,
firstCOEStatus: COEStatus.completed,
assessmentTriggerType: AssessmentTriggerType.OriginalAssessment,
hasBlockFundingFeedbackError: false,
hasECertFailedValidations: false,
});
},
);

it("Should throw not found error when application is not found.", async () => {
// Arrange
const endpoint = "/aest/application/99999999/progress-details";
const token = await getAESTToken(AESTGroups.BusinessAdministrators);

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.NOT_FOUND)
.expect({
statusCode: HttpStatus.NOT_FOUND,
message: "Application id 99999999 was not found.",
error: "Not Found",
});
});

afterAll(async () => {
await app?.close();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { HttpStatus, INestApplication } from "@nestjs/common";
import * as request from "supertest";
import {
AESTGroups,
BEARER_AUTH_TYPE,
createTestingAppModule,
getAESTToken,
} from "../../../testHelpers";
import {
E2EDataSources,
MSFAAStates,
createE2EDataSources,
createFakeMSFAANumber,
saveFakeApplicationDisbursements,
saveFakeStudent,
} from "@sims/test-utils";
import {
ApplicationStatus,
AssessmentTriggerType,
COEStatus,
DisbursementScheduleStatus,
MSFAANumber,
OfferingIntensity,
Student,
} from "@sims/sims-db";

describe("ApplicationAESTController(e2e)-getCompletedApplicationDetails", () => {
let app: INestApplication;
let db: E2EDataSources;
let sharedStudent: Student;
let sharedPartTimeSignedMSFAANumber: MSFAANumber;

beforeAll(async () => {
const { nestApplication, dataSource } = await createTestingAppModule();
app = nestApplication;
db = createE2EDataSources(dataSource);
// Create a student with valid SIN and valid MSFAA number.
sharedStudent = await saveFakeStudent(db.dataSource);
sharedPartTimeSignedMSFAANumber = createFakeMSFAANumber(
{ student: sharedStudent },
{
msfaaState: MSFAAStates.Signed,
msfaaInitialValues: { offeringIntensity: OfferingIntensity.partTime },
},
);
await db.msfaaNumber.save(sharedPartTimeSignedMSFAANumber);
});

it(
"Should get application details when application is in 'Completed' status" +
" with original assessment and valid MSFAA Number and offering intensity is part-time.",
async () => {
// Arrange
const application = await saveFakeApplicationDisbursements(
db.dataSource,
{
student: sharedStudent,
msfaaNumber: sharedPartTimeSignedMSFAANumber,
},
{
offeringIntensity: OfferingIntensity.partTime,
applicationStatus: ApplicationStatus.Completed,
firstDisbursementInitialValues: { coeStatus: COEStatus.completed },
},
);

const endpoint = `/aest/application/${application.id}/completed`;
const token = await getAESTToken(AESTGroups.BusinessAdministrators);

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect({
firstDisbursement: {
coeStatus: COEStatus.completed,
disbursementScheduleStatus: DisbursementScheduleStatus.Pending,
},
assessmentTriggerType: AssessmentTriggerType.OriginalAssessment,
hasBlockFundingFeedbackError: false,
eCertFailedValidations: [],
});
},
);

it("Should throw not found error when application is not found.", async () => {
// Arrange
const endpoint = "/aest/application/99999999/completed";
const token = await getAESTToken(AESTGroups.BusinessAdministrators);

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.NOT_FOUND)
.expect({
statusCode: HttpStatus.NOT_FOUND,
message: "Application not found or not on Completed status.",
error: "Not Found",
});
});

afterAll(async () => {
await app?.close();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { HttpStatus, INestApplication } from "@nestjs/common";
import * as request from "supertest";
import {
AESTGroups,
BEARER_AUTH_TYPE,
createTestingAppModule,
getAESTToken,
} from "../../../testHelpers";
import {
E2EDataSources,
createE2EDataSources,
saveFakeApplicationDisbursements,
} from "@sims/test-utils";
import {
ApplicationStatus,
AssessmentTriggerType,
COEStatus,
DisbursementScheduleStatus,
OfferingIntensity,
} from "@sims/sims-db";

describe("ApplicationAESTController(e2e)-getEnrolmentApplicationDetails", () => {
let app: INestApplication;
let db: E2EDataSources;

beforeAll(async () => {
const { nestApplication, dataSource } = await createTestingAppModule();
app = nestApplication;
db = createE2EDataSources(dataSource);
});

it(
"Should get application enrolment details when the application is in 'Enrolment' status" +
" with original assessment and offering intensity is part-time.",
async () => {
// Arrange
const application = await saveFakeApplicationDisbursements(
db.dataSource,
undefined,
{
offeringIntensity: OfferingIntensity.partTime,
applicationStatus: ApplicationStatus.Enrolment,
firstDisbursementInitialValues: { coeStatus: COEStatus.required },
},
);

const endpoint = `/aest/application/${application.id}/enrolment`;
const token = await getAESTToken(AESTGroups.BusinessAdministrators);

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect({
firstDisbursement: {
coeStatus: COEStatus.required,
disbursementScheduleStatus: DisbursementScheduleStatus.Pending,
},
assessmentTriggerType: AssessmentTriggerType.OriginalAssessment,
});
},
);

it("Should throw not found error when application is not found.", async () => {
// Arrange
const endpoint = "/aest/application/99999999/enrolment";
const token = await getAESTToken(AESTGroups.BusinessAdministrators);

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.NOT_FOUND)
.expect({
statusCode: HttpStatus.NOT_FOUND,
message:
"Application id 99999999 not found or not in relevant status to get enrolment details.",
error: "Not Found",
});
});

afterAll(async () => {
await app?.close();
});
});
Loading

0 comments on commit 34c9ec5

Please sign in to comment.