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

#1791 - Enable Assessments tab view and NOA view for Public Institution Users - Part 4 #1976

Merged
merged 10 commits into from
Jun 2, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feedback
ann-aot committed Jun 1, 2023
commit 22446b86b0a57fa5dea3ccc5c7593eab40eb2fac
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { HttpStatus, INestApplication } from "@nestjs/common";
import * as request from "supertest";
import {
AESTGroups,
authorizeUserTokenForLocation,
BEARER_AUTH_TYPE,
createTestingAppModule,
getAESTToken,
getAuthRelatedEntities,
getInstitutionToken,
INSTITUTION_BC_PUBLIC_ERROR_MESSAGE,
@@ -30,6 +32,7 @@ import {
} from "@sims/sims-db";
import { saveStudentApplicationForCollegeC } from "../../../student/_tests_/e2e/student.institutions.utils";
import { createFakeOfferingRequestChange } from "@sims/test-utils/factories/offering-change-request";
import { RequestAssessmentTypeAPIOutDTO } from "../../models/assessment.dto";

describe("AssessmentInstitutionsController(e2e)-getRequestedAssessmentSummary", () => {
let app: INestApplication;
@@ -139,7 +142,9 @@ describe("AssessmentInstitutionsController(e2e)-getRequestedAssessmentSummary",
const offeringRequestOfferings = createFakeOfferingRequestChange({
currentOffering: application.currentAssessment.offering,
});
await db.educationProgramOffering.save(offeringRequestOfferings);
const [, requestedOffering] = await db.educationProgramOffering.save(
offeringRequestOfferings,
);
const endpoint = `/institutions/assessment/student/${student.id}/application/${application.id}/requests`;
const institutionUserToken = await getInstitutionToken(
InstitutionTokenTypes.CollegeFUser,
@@ -151,6 +156,27 @@ describe("AssessmentInstitutionsController(e2e)-getRequestedAssessmentSummary",
.auth(institutionUserToken, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect([]);

// Checking the same scenario with the ministry user, to make sure that a fake offering change was created.
// Arrange.
const ministryEndpoint = `/aest/assessment/application/${application.id}/requests`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing a ministry endpoint at assessment.institutions.controller.*spec is against the pattern that we have been following in e2e.

I am not able to follow the reason for doing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @andrewsignori-aot mentioned #1976 (comment) and the comment stated in the code, it's not a aest endpoint check, it is just to validate the scenario, whether the offering change was actually created and that's is the reason, the institution endpoint is returning empty list (result without an offering change)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not able to follow @ann-aot . To validate a scenario we are are calling an endpoint here which I feel is an E2E test for an endpoint even though the intention is to validate a scenario.

const ministryToken = await getAESTToken(
AESTGroups.BusinessAdministrators,
);
// Act/Assert
await request(app.getHttpServer())
.get(ministryEndpoint)
.auth(ministryToken, BEARER_AUTH_TYPE)
.expect(HttpStatus.OK)
.expect([
{
id: requestedOffering.id,
submittedDate: requestedOffering.submittedDate.toISOString(),
status: requestedOffering.offeringStatus,
requestType: RequestAssessmentTypeAPIOutDTO.OfferingRequest,
programId: requestedOffering.educationProgram.id,
},
]);
},
);

Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ export class AssessmentAESTController extends BaseController {
return this.assessmentControllerService.requestedStudentAssessmentSummary(
applicationId,
{
showOfferingChange: true,
includeOfferingChanges: true,
},
);
}
Original file line number Diff line number Diff line change
@@ -322,20 +322,19 @@ export class AssessmentControllerService {
* @param applicationId application id.
* @param options options for request assessments,
* - `studentId` student id.
* - `showOfferingChange` will decide weather to show assessment
* - `includeOfferingChanges` will decide whether to include assessment
* request for offering change.
* @returns assessment requests or exceptions for the student application.
*/
async requestedStudentAssessmentSummary(
applicationId: number,
options?: {
studentId?: number;
showOfferingChange?: boolean;
includeOfferingChanges?: boolean;
},
): Promise<RequestAssessmentSummaryAPIOutDTO[]> {
const showOfferingChange = options?.showOfferingChange ? true : false;
const requestAssessmentSummary: RequestAssessmentSummaryAPIOutDTO[] = [];
if (showOfferingChange) {
if (options?.includeOfferingChanges) {
const offeringChange =
await this.educationProgramOfferingService.getOfferingRequestsByApplicationId(
applicationId,
Original file line number Diff line number Diff line change
@@ -2,25 +2,27 @@ import { EducationProgramOffering, OfferingStatus } from "@sims/sims-db";

/**
* Create a fake offering request change.
* @param relations dependencies:
* - `currentOffering` current offering, which is requested for the changed.
* @param options dependencies:
* - `currentOffering` current offering, which is requested for the changed, which is
* already saved in the DB.
* @returns the current and requested offering.
*/
export function createFakeOfferingRequestChange(relations: {
export function createFakeOfferingRequestChange(options: {
currentOffering: EducationProgramOffering;
}): EducationProgramOffering[] {
const now = new Date();
const requestedOfferingId = relations.currentOffering.id;
const requestedOffering = relations.currentOffering;
const requestedOfferingId = options.currentOffering.id;
const requestedOffering = options.currentOffering;
delete requestedOffering.id;
requestedOffering.offeringStatus = OfferingStatus.ChangeAwaitingApproval;
requestedOffering.parentOffering =
relations.currentOffering.parentOffering ??
options.currentOffering.parentOffering ??
({ id: requestedOfferingId } as EducationProgramOffering);
requestedOffering.precedingOffering = {
id: requestedOfferingId,
} as EducationProgramOffering;
requestedOffering.createdAt = now;
requestedOffering.submittedDate = now;

// Update the status and audit details of current offering.
const precedingOffering = new EducationProgramOffering();