-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2568 - Minimum validation for the date entered on scholastic standin…
…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
Showing
13 changed files
with
795 additions
and
174 deletions.
There are no files selected for viewing
157 changes: 157 additions & 0 deletions
157
...tests_/e2e/institution-location.institutions.controller.getActiveApplications.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.