-
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.
Merge branch 'main' into feature/#3260-cas-create-new-supplier
- Loading branch information
Showing
48 changed files
with
1,726 additions
and
550 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.