Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ import {
BEARER_AUTH_TYPE,
createTestingAppModule,
getAESTToken,
getExpectedOfferingNameAndPeriod,
} from "../../../../testHelpers";
import {
createE2EDataSources,
createFakeEducationProgramOffering,
createFakeStudentAssessment,
E2EDataSources,
saveFakeApplication,
} from "@sims/test-utils";
import {
Application,
ApplicationData,
ApplicationStatus,
AssessmentTriggerType,
EducationProgramOffering,
OfferingIntensity,
ProgramInfoStatus,
} from "@sims/sims-db";
import { getUserFullName } from "../../../../utilities";
import { addDays, getISODateOnlyString } from "@sims/utilities";
Expand Down Expand Up @@ -255,6 +260,118 @@ describe("ApplicationAESTController(e2e)-getApplicationDetails", () => {
]);
});

it("Should return PIR summary in application data when the application has PIR status completed and dynamic data is loaded.", async () => {
// Arrange
const application = await saveFakeApplication(
db.dataSource,
{},
{
applicationStatus: ApplicationStatus.Assessment,
offeringIntensity: OfferingIntensity.fullTime,
pirStatus: ProgramInfoStatus.completed,
},
);

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

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect(({ body }) =>
expect(body).toMatchObject({
data: {
pirSummary: {
programName: savedOffering.educationProgram.name,
offeringName: getExpectedOfferingNameAndPeriod(savedOffering),
},
},
}),
);
});

it("Should not return PIR summary in application data when the application does not have PIR status completed.", async () => {
// Arrange
const application = await saveFakeApplication(
db.dataSource,
{},
{
applicationStatus: ApplicationStatus.Assessment,
offeringIntensity: OfferingIntensity.fullTime,
pirStatus: ProgramInfoStatus.notRequired,
},
);
const token = await getAESTToken(AESTGroups.BusinessAdministrators);
const endpoint = `/aest/application/${application.id}`;

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect(({ body }) => expect(body.data.pirSummary).toBeUndefined());
});

it("Should return the PIR summary from the original assessment offering even when the application has a later reassessment with a different offering.", async () => {
// Arrange
// Create an application with PIR completed (original assessment).
const application = await saveFakeApplication(
db.dataSource,
{},
{
applicationStatus: ApplicationStatus.Assessment,
offeringIntensity: OfferingIntensity.fullTime,
pirStatus: ProgramInfoStatus.completed,
},
);
const originalOffering = application.currentAssessment!.offering!;
// Create a different offering for the reassessment to confirm that the
// PIR summary always reflects the original assessment's offering.
// PIR is assessed once per application (tied to the original assessment),
// so a subsequent reassessment with a new offering must not affect the PIR summary.
const differentOffering = createFakeEducationProgramOffering({
auditUser: application.student.user,
});
differentOffering.parentOffering = differentOffering;
const savedDifferentOffering =
await db.educationProgramOffering.save(differentOffering);
const reassessment = createFakeStudentAssessment(
{
auditUser: application.student.user,
application,
offering: savedDifferentOffering,
},
{
initialValue: {
triggerType: AssessmentTriggerType.StudentAppeal,
},
},
);
application.currentAssessment = reassessment;
await db.application.save(application);
const token = await getAESTToken(AESTGroups.BusinessAdministrators);
const endpoint = `/aest/application/${application.id}`;

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect(({ body }) =>
expect(body).toMatchObject({
data: {
pirSummary: {
programName: originalOffering.educationProgram.name,
offeringName: getExpectedOfferingNameAndPeriod(originalOffering),
},
},
}),
);
});

afterAll(async () => {
await app?.close();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BEARER_AUTH_TYPE,
createTestingAppModule,
getAuthRelatedEntities,
getExpectedOfferingNameAndPeriod,
getInstitutionToken,
INSTITUTION_BC_PUBLIC_ERROR_MESSAGE,
INSTITUTION_STUDENT_DATA_ACCESS_ERROR_MESSAGE,
Expand All @@ -22,6 +23,7 @@ import {
EducationProgramOffering,
InstitutionLocation,
OfferingIntensity,
ProgramInfoStatus,
} from "@sims/sims-db";
import { addDays, getISODateOnlyString } from "@sims/utilities";
import { getUserFullName } from "../../../../utilities";
Expand Down Expand Up @@ -275,6 +277,68 @@ describe("ApplicationInstitutionsController(e2e)-getApplicationDetails", () => {
);
});

it("Should return PIR summary in application data when the application has PIR status completed.", async () => {
// Arrange
const savedApplication = await saveFakeApplication(
db.dataSource,
{ institutionLocation: collegeFLocation },
{
applicationStatus: ApplicationStatus.Assessment,
offeringIntensity: OfferingIntensity.fullTime,
pirStatus: ProgramInfoStatus.completed,
},
);
const savedOffering = savedApplication.currentAssessment!.offering!;
const student = savedApplication.student;
const endpoint = `/institutions/application/student/${student.id}/application/${savedApplication.id}`;
const institutionUserToken = await getInstitutionToken(
InstitutionTokenTypes.CollegeFUser,
);

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(institutionUserToken, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect(({ body }) =>
expect(body).toMatchObject({
data: {
pirSummary: {
programName: savedOffering.educationProgram.name,
offeringName: getExpectedOfferingNameAndPeriod(savedOffering),
},
},
}),
);
});
Comment thread
andrewsignori-aot marked this conversation as resolved.

it("Should not return PIR summary in application data when the application does not have PIR status completed.", async () => {
// Arrange
const savedApplication = await saveFakeApplication(
db.dataSource,
{ institutionLocation: collegeFLocation },
{
applicationStatus: ApplicationStatus.Assessment,
offeringIntensity: OfferingIntensity.fullTime,
pirStatus: ProgramInfoStatus.notRequired,
},
);
const student = savedApplication.student;
const endpoint = `/institutions/application/student/${student.id}/application/${savedApplication.id}`;
const institutionUserToken = await getInstitutionToken(
InstitutionTokenTypes.CollegeFUser,
);

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(institutionUserToken, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect(({ body }) => {
expect(body.data.pirSummary).toBeUndefined();
});
});

afterAll(async () => {
await app?.close();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
BEARER_AUTH_TYPE,
createTestingAppModule,
FakeStudentUsersTypes,
getExpectedOfferingNameAndPeriod,
getStudentToken,
mockJWTUserInfo,
resetMockJWTUserInfo,
Expand Down Expand Up @@ -203,6 +204,13 @@ describe("ApplicationStudentsController(e2e)-getApplication", () => {
programName: "My Program",
workflowName: "",
programDescription: "This is my program.",
pirSummary: {
programName:
application.currentAssessment!.offering!.educationProgram.name,
offeringName: getExpectedOfferingNameAndPeriod(
application.currentAssessment!.offering!,
),
},
},
applicationStatus: application.applicationStatus,
applicationEditStatus: application.applicationEditStatus,
Expand Down Expand Up @@ -308,6 +316,66 @@ describe("ApplicationStudentsController(e2e)-getApplication", () => {
});
});

it("Should return PIR summary in application data when the application has PIR status completed.", async () => {
// Arrange
const application = await saveFakeApplication(
db.dataSource,
{ student },
{
applicationStatus: ApplicationStatus.Assessment,
offeringIntensity: OfferingIntensity.fullTime,
pirStatus: ProgramInfoStatus.completed,
},
);
const savedOffering = application.currentAssessment!.offering!;
const endpoint = `/students/application/${application.id}`;
const token = await getStudentToken(
FakeStudentUsersTypes.FakeStudentUserType1,
);
await mockJWTUserInfo(appModule, application.student.user);

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect(({ body }) =>
expect(body).toMatchObject({
data: {
pirSummary: {
programName: savedOffering.educationProgram.name,
offeringName: getExpectedOfferingNameAndPeriod(savedOffering),
},
},
}),
);
});

it("Should not return PIR summary in application data when the application does not have PIR status completed.", async () => {
// Arrange
const application = await saveFakeApplication(
db.dataSource,
{ student },
{
applicationStatus: ApplicationStatus.Assessment,
offeringIntensity: OfferingIntensity.fullTime,
pirStatus: ProgramInfoStatus.notRequired,
},
);
const endpoint = `/students/application/${application.id}`;
const token = await getStudentToken(
FakeStudentUsersTypes.FakeStudentUserType1,
);
await mockJWTUserInfo(appModule, application.student.user);

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect(({ body }) => expect(body.data.pirSummary).toBeUndefined());
});

afterAll(async () => {
await app?.close();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ export class ApplicationAESTController extends BaseController {
));
const currentReadOnlyDataPromise =
this.applicationControllerService.generateApplicationFormData(
application.data,
application,
Comment thread
andrewsignori-aot marked this conversation as resolved.
);
// If there is a previous application, generate its read-only data.
const previousReadOnlyDataPromise =
previousApplicationVersion &&
this.applicationControllerService.generateApplicationFormData(
previousApplicationVersion.data,
previousApplicationVersion,
);
// Wait for both promises to resolve.
[currentReadOnlyData, previousReadOnlyData] = await Promise.all([
Expand Down
Loading
Loading