Skip to content

Commit

Permalink
#2568 - Minimum validation for the date entered on scholastic standin…
Browse files Browse the repository at this point in the history
…g creation (#3766)

- [x] Added validation in the formio "Report Scholastic Standing Change"
on the date parameters for Scholastic Standings when they are created
- [x] API validation is also changed with respect to the formio
validation, so the logic which fetches the study start and end date has
been included and the service is moved with respect to it, without
making additional calls.
- [x] The archived check for the list of applications shown in the
'Available to Report ' tab is already implemented.
- [x] E2E test cases where expanded and included for the scholastic
standing related to date like School Transfer, Student Withdrawal and
Student completed early with the dates between the study start , end
period and current date.
- [x] Added E2E test cases for the list that shows active applications
in Report a Change 'Available to Report' tab.

---------

Co-authored-by: guru-aot <[email protected]>
  • Loading branch information
guru-aot and guru-aot authored Oct 8, 2024
1 parent 0464a84 commit 411d242
Show file tree
Hide file tree
Showing 13 changed files with 795 additions and 174 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import { HttpStatus, INestApplication } from "@nestjs/common";
import * as request from "supertest";
import {
authorizeUserTokenForLocation,
BEARER_AUTH_TYPE,
createTestingAppModule,
getAuthRelatedEntities,
getInstitutionToken,
InstitutionTokenTypes,
} from "../../../../testHelpers";
import {
E2EDataSources,
createE2EDataSources,
createFakeInstitutionLocation,
saveFakeApplication,
} from "@sims/test-utils";
import { ApplicationStatus, InstitutionLocation } from "@sims/sims-db";
import { getUserFullName } from "../../../../utilities";
import { ApplicationScholasticStandingStatus } from "../../../../services/application/application.models";

describe("InstitutionLocationInstitutionsController(e2e)-getActiveApplications", () => {
let app: INestApplication;
let db: E2EDataSources;
let collegeFLocation: InstitutionLocation;
let collegeDLocation: InstitutionLocation;

beforeAll(async () => {
const { nestApplication, dataSource } = await createTestingAppModule();
app = nestApplication;
db = createE2EDataSources(dataSource);
// College F.
const { institution: collegeF } = await getAuthRelatedEntities(
db.dataSource,
InstitutionTokenTypes.CollegeFUser,
);
collegeFLocation = createFakeInstitutionLocation({
institution: collegeF,
});
await authorizeUserTokenForLocation(
db.dataSource,
InstitutionTokenTypes.CollegeFUser,
collegeFLocation,
);
// College D.
const { institution: collegeD } = await getAuthRelatedEntities(
db.dataSource,
InstitutionTokenTypes.CollegeDUser,
);
collegeDLocation = createFakeInstitutionLocation({
institution: collegeD,
});
await authorizeUserTokenForLocation(
db.dataSource,
InstitutionTokenTypes.CollegeDUser,
collegeDLocation,
);
});

it("Should get the list of all applications which are not archived when requested for not archived application in Report a Change", async () => {
// Arrange
const completedApplication = await saveFakeApplication(
db.dataSource,
{
institutionLocation: collegeFLocation,
},
{ applicationStatus: ApplicationStatus.Completed },
);

await saveFakeApplication(
db.dataSource,
{
institutionLocation: collegeFLocation,
},
{ isArchived: true, applicationStatus: ApplicationStatus.Completed },
);

// Institution token.
const institutionUserToken = await getInstitutionToken(
InstitutionTokenTypes.CollegeFUser,
);
const endpoint = `/institutions/location/${collegeFLocation.id}/active-applications?archived=false&page=0&pageLimit=10&sortField=applicationNumber&sortOrder=ASC`;

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(institutionUserToken, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect({
count: 1,
results: [
{
applicationId: completedApplication.id,
applicationNumber: completedApplication.applicationNumber,
applicationScholasticStandingStatus:
ApplicationScholasticStandingStatus.Available,
fullName: getUserFullName(completedApplication.student.user),
studyEndPeriod:
completedApplication.currentAssessment.offering.studyEndDate,
studyStartPeriod:
completedApplication.currentAssessment.offering.studyStartDate,
},
],
});
});

it("Should get the list of all applications which are archived when requested for archived applications in Report a Change", async () => {
// Arrange
const archivedApplication = await saveFakeApplication(
db.dataSource,
{
institutionLocation: collegeDLocation,
},

{ isArchived: true, applicationStatus: ApplicationStatus.Completed },
);

await saveFakeApplication(
db.dataSource,
{
institutionLocation: collegeDLocation,
},
{ applicationStatus: ApplicationStatus.Completed },
);

// Institution token.
const institutionUserToken = await getInstitutionToken(
InstitutionTokenTypes.CollegeDUser,
);
const endpoint = `/institutions/location/${collegeDLocation.id}/active-applications?archived=true&page=0&pageLimit=10&sortField=applicationNumber&sortOrder=ASC`;

// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(institutionUserToken, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect({
count: 1,
results: [
{
applicationId: archivedApplication.id,
applicationNumber: archivedApplication.applicationNumber,
applicationScholasticStandingStatus:
ApplicationScholasticStandingStatus.Unavailable,
fullName: getUserFullName(archivedApplication.student.user),
studyEndPeriod:
archivedApplication.currentAssessment.offering.studyEndDate,
studyStartPeriod:
archivedApplication.currentAssessment.offering.studyStartDate,
},
],
});
});

afterAll(async () => {
await app?.close();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export const transformToActiveApplicationDataAPIOutDTO = (
applicationStatus: application.applicationStatus,
applicationNumber: application.applicationNumber,
applicationOfferingIntensity: offering.offeringIntensity,
applicationOfferingStartDate: getISODateOnlyString(offering.studyStartDate),
applicationOfferingEndDate: getISODateOnlyString(offering.studyEndDate),
applicationOfferingStartDate: offering.studyStartDate,
applicationOfferingEndDate: offering.studyEndDate,
applicationLocationName: offering.institutionLocation.name,
applicationStudentName: getUserFullName(application.student.user),
applicationOfferingName: offering.name,
Expand Down
Loading

0 comments on commit 411d242

Please sign in to comment.