Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1978 - Request an Offering Change: Student View Request - e2e tests (Part 2) #2240

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ba537ab
#1978 - Request an Offering Change: Student View Request - e2e tests …
sh16011993 Aug 31, 2023
1f18dc7
Merge branch 'main' into 1978_request_offering_change_student_view_re…
sh16011993 Aug 31, 2023
8380025
Increased memory heap size to 12288
sh16011993 Aug 31, 2023
f5950e3
Code Update
sh16011993 Sep 1, 2023
480d499
test
sh16011993 Sep 1, 2023
e91183a
code update
sh16011993 Sep 1, 2023
3f834c5
Code Update
sh16011993 Sep 1, 2023
7d5ebbb
Code Update
sh16011993 Sep 1, 2023
ce01977
Code Update as per review comments
sh16011993 Sep 6, 2023
dfa051a
Code Update
sh16011993 Sep 6, 2023
50f2a60
Code Update
sh16011993 Sep 6, 2023
4f147d7
test
sh16011993 Sep 6, 2023
65a6c98
reverting test
sh16011993 Sep 6, 2023
0ab77d7
test
sh16011993 Sep 6, 2023
c3f68df
test
sh16011993 Sep 6, 2023
2f2a465
test
sh16011993 Sep 6, 2023
bc23848
test
sh16011993 Sep 6, 2023
cae43fc
test
sh16011993 Sep 6, 2023
15bf78d
test
sh16011993 Sep 6, 2023
817b775
test
sh16011993 Sep 6, 2023
0e3499e
test
sh16011993 Sep 6, 2023
15c924c
test
sh16011993 Sep 6, 2023
74037e0
test
sh16011993 Sep 6, 2023
7aa27bc
test
sh16011993 Sep 6, 2023
cb3280d
test
sh16011993 Sep 6, 2023
b31e548
test
sh16011993 Sep 6, 2023
b35cce3
test
sh16011993 Sep 6, 2023
e20b372
test
sh16011993 Sep 6, 2023
f8b2be0
test
sh16011993 Sep 6, 2023
f894927
test
sh16011993 Sep 6, 2023
6bd105d
Code Update
sh16011993 Sep 7, 2023
9e8221a
test
sh16011993 Sep 7, 2023
a91a41c
Code review update
sh16011993 Sep 7, 2023
4fe1d4e
Code review changes
sh16011993 Sep 7, 2023
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
@@ -0,0 +1,97 @@
import { HttpStatus, INestApplication } from "@nestjs/common";
import * as request from "supertest";
import {
BEARER_AUTH_TYPE,
createTestingAppModule,
FakeStudentUsersTypes,
getStudentToken,
getStudentByFakeStudentUserType,
} from "../../../../testHelpers";
import {
saveFakeApplicationOfferingRequestChange,
createE2EDataSources,
E2EDataSources,
saveFakeApplication,
} from "@sims/test-utils";
import { ApplicationStatus, Student } from "@sims/sims-db";

describe("ApplicationOfferingChangeRequestStudentsController(e2e)-getApplicationOfferingChangeRequest", () => {
let app: INestApplication;
let student: Student;
let db: E2EDataSources;

beforeAll(async () => {
const { nestApplication, dataSource } = await createTestingAppModule();
app = nestApplication;
db = createE2EDataSources(dataSource);
student = await getStudentByFakeStudentUserType(
FakeStudentUsersTypes.FakeStudentUserType1,
dataSource,
);
});

it("Should return the application offering change request details when provided with the application offering change request id.", async () => {
// Arrange
const application = await saveFakeApplication(
db.dataSource,
{
student,
},
{ applicationStatus: ApplicationStatus.Completed },
);
const applicationOfferingChangeRequest =
await saveFakeApplicationOfferingRequestChange(db, {
application,
});
const token = await getStudentToken(
FakeStudentUsersTypes.FakeStudentUserType1,
);
const endpoint = `/students/application-offering-change-request/${applicationOfferingChangeRequest.id}`;
// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect({
status:
applicationOfferingChangeRequest.applicationOfferingChangeRequestStatus,
applicationNumber:
applicationOfferingChangeRequest.application.applicationNumber,
locationName:
applicationOfferingChangeRequest.application.location.name,
requestedOfferingId:
applicationOfferingChangeRequest.requestedOffering.id,
activeOfferingId: applicationOfferingChangeRequest.activeOffering.id,
reason: applicationOfferingChangeRequest.reason,
});
});

it("Should throw a HttpStatus Not Found (404) when the application offering change request is not associated with the authenticated student.", async () => {
// Arrange
const application = await saveFakeApplication(db.dataSource, undefined, {
applicationStatus: ApplicationStatus.Completed,
});
const applicationOfferingChangeRequest =
await saveFakeApplicationOfferingRequestChange(db, {
application,
});
const token = await getStudentToken(
FakeStudentUsersTypes.FakeStudentUserType1,
);
const endpoint = `/students/application-offering-change-request/${applicationOfferingChangeRequest.id}`;
// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.NOT_FOUND)
.expect({
statusCode: HttpStatus.NOT_FOUND,
message: "Not able to find an Application Offering Change Request.",
error: "Not Found",
});
});

afterAll(async () => {
await app?.close();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { HttpStatus, INestApplication } from "@nestjs/common";
import * as request from "supertest";
import {
BEARER_AUTH_TYPE,
createTestingAppModule,
FakeStudentUsersTypes,
getStudentToken,
getStudentByFakeStudentUserType,
} from "../../../../testHelpers";
import {
saveFakeApplicationOfferingRequestChange,
createE2EDataSources,
E2EDataSources,
saveFakeApplication,
} from "@sims/test-utils";
import { ApplicationStatus, Student } from "@sims/sims-db";

describe("ApplicationOfferingChangeRequestStudentsController(e2e)-getApplicationOfferingChangeRequestStatus", () => {
let app: INestApplication;
let student: Student;
let db: E2EDataSources;

beforeAll(async () => {
const { nestApplication, dataSource } = await createTestingAppModule();
app = nestApplication;
db = createE2EDataSources(dataSource);
student = await getStudentByFakeStudentUserType(
FakeStudentUsersTypes.FakeStudentUserType1,
dataSource,
);
});

it("Should return the application offering change request status when provided with the application offering change request id.", async () => {
// Arrange
const application = await saveFakeApplication(
db.dataSource,
{
student,
},
{ applicationStatus: ApplicationStatus.Completed },
);
const applicationOfferingChangeRequest =
await saveFakeApplicationOfferingRequestChange(db, {
application,
});
const token = await getStudentToken(
FakeStudentUsersTypes.FakeStudentUserType1,
);
const endpoint = `/students/application-offering-change-request/${applicationOfferingChangeRequest.id}/application-offering-change-request-status`;
// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect({
status:
applicationOfferingChangeRequest.applicationOfferingChangeRequestStatus,
});
});

it("Should throw a HttpStatus Not Found (404) when the application offering status change request is not associated with the authenticated student.", async () => {
// Arrange
const application = await saveFakeApplication(db.dataSource, undefined, {
applicationStatus: ApplicationStatus.Completed,
});
const applicationOfferingChangeRequest =
await saveFakeApplicationOfferingRequestChange(db, {
application,
});
const token = await getStudentToken(
FakeStudentUsersTypes.FakeStudentUserType1,
);
const endpoint = `/students/application-offering-change-request/${applicationOfferingChangeRequest.id}/application-offering-change-request-status`;
// Act/Assert
await request(app.getHttpServer())
.get(endpoint)
.auth(token, BEARER_AUTH_TYPE)
.expect(HttpStatus.NOT_FOUND)
.expect({
statusCode: HttpStatus.NOT_FOUND,
message: "Application Offering Change Request not found.",
error: "Not Found",
});
});

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