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

#2322 - IER12 E2E Tests - First scenarios #2461

Merged
merged 20 commits into from
Nov 1, 2023

Conversation

andrewsignori-aot
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot commented Oct 30, 2023

Followed a similar idea used for MSFAA E2E tests where a controlled data set was created to allow easy file record validation with minimal variables. So, in the same way, MSFAA is using saveMSFAATestInputData, the IER12 E2E is using saveIER12TestInputData.

Small helper methods were created in separate files with the idea of sharing with other E2E test files for IER12.

The payload is supposed to be expressive and clearly define the IER12 data, as shown below. Constants like JOHN_DOE_FROM_CANADA or JANE_MONONYMOUS_FROM_OTHER_COUNTRY were created to allow the reuse of some basic data sets.

const testInputData = {
  student: JOHN_DOE_FROM_CANADA,
  application: {
    applicationNumber: defaultApplicationNumber,
    studentNumber: "12345678",
    relationshipStatus: RelationshipStatus.Single,
    applicationStatus: ApplicationStatus.Completed,
    applicationStatusUpdatedOn: undefined,
  },
  assessment: {
    triggerType: AssessmentTriggerType.OriginalAssessment,
    assessmentDate: undefined,
    workflowData: WORKFLOW_DATA_SINGLE_INDEPENDENT_WITH_NO_DEPENDENTS,
    assessmentData: ASSESSMENT_DATA_SINGLE_INDEPENDENT,
    disbursementSchedules: [
      {
        coeStatus: COEStatus.completed,
        disbursementScheduleStatus: DisbursementScheduleStatus.Sent,
        disbursementDate: undefined,
        updatedAt: undefined,
        dateSent: undefined,
        disbursementValues: AWARDS_ONE_OF_TWO_DISBURSEMENT,
      },
      {
        coeStatus: COEStatus.required,
        disbursementScheduleStatus: DisbursementScheduleStatus.Pending,
        disbursementDate: undefined,
        updatedAt: undefined,
        dateSent: undefined,
        disbursementValues: AWARDS_TWO_OF_TWO_DISBURSEMENT,
      },
    ],
  },
educationProgram: PROGRAM_UNDERGRADUATE_CERTIFICATE_WITHOUT_INSTITUTION_PROGRAM_CODE,
offering: OFFERING_FULL_TIME,
};

As much as possible the IR12 models use the DB models as a reference (e.g. using Pick<>) and the overall idea is that these models represent the specific set of properties that would impact the IER12 file content directly or participate in its calculations.

First E2E scenarios for IER12.

  • Should generate an IER12 file with two records for a single student with no dependents and two disbursements, one sent and one pending.
  • Should generate an IER12 file with one record for a married student (mononymous) with dependents, applications still in assessment, and one pending disbursement.
  • Should generate an IER12 file with one record for a dependant and living with parents student with no dependents and one sent disbursement with no BC funding.
  • Should generate an IER12 file with one record for a student with one pending disbursement due to a restriction.

Refactors

  • Changed the student number source from application dynamic data to the application table.

Upcoming PR

  • A closer look at the expect for the line assertion (need further review with documentation.).
  • More scenarios like (to be done as per time allows):
    • Generate records from multiple institutions/locations.
    • Has multiple application submissions.
    • Has full-time disbursement feedback errors.
    • Do not select part-time applications.
    • Has a disbursement that withheld funding.

PS.: The acceptance criteria Create factory to generate the workflow_data information was replaced by the idea of creating a factory for the entire IER12, the saveIER12TestInputData. Please let me know if there is a concern that this is not achieving the goal for the IER12 effort.

* would create a program year 2000-2001.
* @returns program year with the prefix.
*/
export async function ensureProgramYearExists(
Copy link
Contributor

Choose a reason for hiding this comment

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

how about the method name getOrCreateProgramYear

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Either way would work for me. Lest see if there is any input from other devs and please let me know if it would be a blocker 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

no, its a suggestion

const createSecondDisbursement =
testInputData.assessment.disbursementSchedules.length === 2;
// Set the number of weeks to some number beyond 17 if there are two disbursements
// since two disbursements are supposed to be create to offerings longer than 17 weeks.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

@guru-aot guru-aot left a comment

Choose a reason for hiding this comment

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

LGTM, very nice work on creating the factories and arranging them. @andrewsignori-aot


// Act
const ier12Results = await processor.processIER12File(job);
db.application.createQueryBuilder();
Copy link
Collaborator

Choose a reason for hiding this comment

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

left over to be removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed, nice catch 😉

const [line1] = uploadedFile.fileLines;
const [firstDisbursement] =
application.currentAssessment.disbursementSchedules;
const assessmentId = numberToText(application.currentAssessment.id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why didn't we re-use the string builder(or specialized string builder) methods here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To avoid using the code that would also potentially be validated. If we introduce an error in the StringBuilder we may end up not catching it in the E2Es. Same reason that we reuse code from the application but with caution, try to keep the E2E assertion validations as "raw" as possible.

testInputData.assessment.disbursementSchedules.length === 2;
// Set the number of weeks to some number beyond 17 if there are two disbursements
// since two disbursements are supposed to be create to offerings longer than 17 weeks.
const offeringEndDateWeeks = createSecondDisbursement ? 18 : 10;
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

);
// Location
const institutionLocation = createFakeInstitutionLocation();
institutionLocation.institutionCode = "ZZZY";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor. ZZZY could be constant

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It can be, but taking a look at the factories we do assign the values directly almost all the time, I just did not see a benefit here. It would be a different conversation if it was a production code.

@@ -42,6 +42,7 @@ export class StudentAssessmentService extends RecordDataModelService<StudentAsse
submittedDate: true,
applicationStatus: true,
applicationStatusUpdatedOn: true,
studentNumber: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for taking care of this.

import { DisbursementValueType } from "@sims/sims-db";
import { IERAward } from "@sims/integrations/institution-integration/ier12-integration";

export const AWARDS_SINGLE_DISBURSEMENT: IERAward[] = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see almost a full fledged QA work happening in an E2E. Great work.

@dheepak-aot
Copy link
Collaborator

Great and exhaustive work @andrewsignori-aot . I see you have addressed most of the comments. added little more.

Copy link
Collaborator

@sh16011993 sh16011993 left a comment

Choose a reason for hiding this comment

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

Nice work @andrewsignori-aot 👍

@andrewsignori-aot andrewsignori-aot removed the request for review from andrepestana-aot November 1, 2023 18:14
Copy link

sonarqubecloud bot commented Nov 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
1.9% 1.9% Duplication

Copy link

github-actions bot commented Nov 1, 2023

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 18.18% ( 2341 / 12879 )
Methods: 9.28% ( 151 / 1628 )
Lines: 20.7% ( 2016 / 9741 )
Branches: 11.52% ( 174 / 1510 )

Copy link

github-actions bot commented Nov 1, 2023

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 52.62% ( 341 / 648 )
Methods: 50% ( 40 / 80 )
Lines: 56.85% ( 282 / 496 )
Branches: 26.39% ( 19 / 72 )

Copy link

github-actions bot commented Nov 1, 2023

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 76.94% ( 564 / 733 )
Methods: 71.59% ( 63 / 88 )
Lines: 78.75% ( 493 / 626 )
Branches: 42.11% ( 8 / 19 )

Copy link

github-actions bot commented Nov 1, 2023

E2E SIMS API Coverage Report

Totals Coverage
Statements: 55.59% ( 4088 / 7354 )
Methods: 52.88% ( 505 / 955 )
Lines: 60.3% ( 3313 / 5494 )
Branches: 29.83% ( 270 / 905 )

Copy link
Collaborator

@dheepak-aot dheepak-aot left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes. 👍

@andrewsignori-aot andrewsignori-aot merged commit 5283a12 into main Nov 1, 2023
@andrewsignori-aot andrewsignori-aot deleted the feature/#2322-ier12-e2e-tests branch November 1, 2023 19:16
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV November 1, 2023 19:27 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV November 1, 2023 19:29 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV November 1, 2023 19:29 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV November 1, 2023 19:29 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV November 1, 2023 19:29 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV November 1, 2023 19:31 — with GitHub Actions Inactive
@andrewsignori-aot andrewsignori-aot temporarily deployed to DEV November 1, 2023 19:31 — with GitHub Actions Inactive
andrewsignori-aot added a commit that referenced this pull request Nov 3, 2023
- Created two more scenarios from the previous PR (#2461) to-do list.
  - Has full-time disbursement feedback errors (DISE).
- Has a disbursement that withheld funding due to a restriction (DISW).
  
- The first E2E above is invoking the processor without specifying the
date as per [previous PR
comment](#2461 (comment)).
- New E2E factory created `createDisbursementFeedbackError`.
- Added an exception in case `getUploadedFile` was invoked but it was
never called. The tests were failing with a not-so-clear error.
- Fixed an error in the IER12 query `BETWEEN` operator and removed a
code TODO.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants