Skip to content

#5878 - Student Forms e2e Tests - getFormSubmission#5924

Open
andrewsignori-aot wants to merge 10 commits intomainfrom
feature/#5878-forms-e2e-tests-part-2
Open

#5878 - Student Forms e2e Tests - getFormSubmission#5924
andrewsignori-aot wants to merge 10 commits intomainfrom
feature/#5878-forms-e2e-tests-part-2

Conversation

@andrewsignori-aot
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot commented Mar 18, 2026

PR Goal

Add some level of API endpoints E2E tests to all new endpoints introduced during the new forms implementation. At least one scenario for each endpoint must be present, and more scenarios can be added if time allows it. Suggestions for scenarios not covered are appreciated, but will be taken care of based on criticality and time available 😉

getFormSubmission

Ministry

  • Should get a form submission as pending, its decisions and history when the form has multiple decisions and the user has approval authorization.
  • Should get a form submission as pending, and its decisions as pending without history when the form has multiple decisions, including an approved decision, and the user does not have approval authorization.
  • Should get a form submission as completed, and its decision statuses, including current notes when the user does not have approval authorization.
  • Should get a form submission as completed, and its decision statuses, including current notes and audit when the user has approval authorization.
  • Should get a form submission item, and its decision statuses, including current notes and audit when the user has approval authorization and an item ID was provided.
  • Should throw a not found exception when the form submission ID does not exist.
  • Should throw a not found exception when the form submission ID or the item ID does not exist.

Institution

  • Should get a form submission as pending and its decisions as pending when the final decision is not yet made and there is an approved and a pending decision (no decision set).
  • Should get a form submission as completed and its decision statuses, including the decision notes, when form submission is completed.
  • Should throw a not found exception when the form submission ID exists for the student but the user does not have access to the location.

Students

  • Should get a form submission as pending and its decisions as pending when the final decision is not yet made and there is an approved and a pending decision (no decision set).
  • Should get a form submission as completed and its decision statuses when form submission is completed.
  • Should throw a not found exception when the form submission ID belongs to another student.
  • Should throw a not found exception when the form submission ID does not exist.

Fix

Ministry's approval visualization

Users without approval roles were not able to see the final decision once the form submissions were completed.
The image below is what Ministry users without approval roles will be able to see, similar to BC Public Institutions.
They have access to the decision statuses and final note only when the submission is completed, following the same idea from the BC Public Institutions.

image

Ministry's history view

The history visualization was also adapted to behave similarly to BC Public Institutions, where the "temporary" decision status is not displayed until the final decision is made.

@andrewsignori-aot andrewsignori-aot self-assigned this Mar 18, 2026
@andrewsignori-aot andrewsignori-aot added Student Student Features Institution Institution Features Ministry Ministry Features E2E/Unit tests labels Mar 18, 2026
@andrewsignori-aot andrewsignori-aot marked this pull request as ready for review March 19, 2026 02:29
Copilot AI review requested due to automatic review settings March 19, 2026 02:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds e2e coverage for the new getFormSubmission endpoints across clients (students/institutions/ministry) and adjusts Ministry decision-visibility rules so non-approval roles can see final decision info once a submission is completed.

Changes:

  • Added e2e specs for getFormSubmission for Students, Institutions, and AEST, plus a small assertion style tweak in an existing student spec.
  • Refactored form-submission approval-role authorization into a dedicated helper and updated controller/service mapping to use role-based decision-detail restrictions.
  • Updated the Ministry UI approval component to hide decision controls for users without approval authorization.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
sources/packages/web/src/components/form-submissions/FormSubmissionApproval.vue Adjusts what decision UI is rendered based on approval authorization/submission status.
sources/packages/backend/libs/test-utils/src/factories/form-submission.ts Adds a richer factory helper to create submissions/items/decisions for e2e tests.
sources/packages/backend/libs/test-utils/src/factories/form-submission-item.ts Extends factory to support audit user/decision array initialization.
sources/packages/backend/libs/test-utils/src/factories/dynamic-form-configuration.ts Extends dynamic form configuration helpers to support more flexible setup for tests.
sources/packages/backend/apps/api/src/services/index.ts Exposes the new form-submission authorization helper via barrel export.
sources/packages/backend/apps/api/src/services/form-submission/form-submission.models.ts Removes embedded approval-role map (moved to authorization helper).
sources/packages/backend/apps/api/src/services/form-submission/form-submission.authorization.ts Introduces shared approval-authorization helper and roles map.
sources/packages/backend/apps/api/src/services/form-submission/form-submission-approval.service.ts Switches authorization checks to use the shared helper.
sources/packages/backend/apps/api/src/route-controllers/form-submission/form-submission.controller.service.ts Updates decision mapping logic to restrict details based on user roles + submission status.
sources/packages/backend/apps/api/src/route-controllers/form-submission/form-submission.aest.controller.ts Uses shared authorization logic and controller-service decision mapping for Ministry output.
sources/packages/backend/apps/api/src/route-controllers/form-submission/tests/e2e/form-submission.students.controller.getSubmissionForms.e2e-spec.ts Minor assertion style change (toStrictEqual).
sources/packages/backend/apps/api/src/route-controllers/form-submission/tests/e2e/form-submission.students.controller.getFormSubmission.e2e-spec.ts New Students e2e coverage for getFormSubmission scenarios.
sources/packages/backend/apps/api/src/route-controllers/form-submission/tests/e2e/form-submission.institutions.controller.getFormSubmission.e2e-spec.ts New Institutions e2e coverage for getFormSubmission scenarios.
sources/packages/backend/apps/api/src/route-controllers/form-submission/tests/e2e/form-submission.aest.controller.getFormSubmission.e2e-spec.ts New AEST e2e coverage for getFormSubmission scenarios.
Comments suppressed due to low confidence (1)

sources/packages/backend/apps/api/src/route-controllers/form-submission/form-submission.controller.service.ts:36

  • The JSDoc for getFormSubmissions still references keepPendingDecisionsWhilePendingFormSubmission, but this option was removed from the method signature. Please update/remove this part of the comment to avoid misleading API/controller behavior documentation.
   * - `userRoles` when provided, it will be used to determine the access to the decision details
   * that the consumer has based on their roles and the form category.
   * - `includeBasicDecisionDetails` optional flag to include basic decision details, besides
   * the decision status. Used for institutions to have access to more details than the student
   * to better support them. Default to false when not provided to expose less information. When keepPendingDecisionsWhilePendingFormSubmission
   * is true, the decision details will not be included while the form submission is pending to avoid showing non-final decisions
   * to be exposed.

You can also share your feedback on Copilot code review. Take the survey.

@dheepak-aot dheepak-aot self-requested a review March 19, 2026 20:59
@tiago-graf tiago-graf self-requested a review March 19, 2026 21:53

// Mock the user received in the token.
await mockJWTUserInfo(appModule, formSubmission.student.user);

Copy link
Collaborator

Choose a reason for hiding this comment

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

The mockJWTUserInfo is still there. Isn't it supposed 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.

I guess I got them all removed now 😉

);
});

it("Should get a form submission as completed, and its decision statuses, including current notes when the user does not have approval authorization.", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor. current decision notes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed.

Comment on lines +189 to +190
formCategory: formSubmission.formCategory,
status: formSubmission.submissionStatus,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor and not blocker. Form category and submission status can be used as values.

Copy link
Collaborator Author

@andrewsignori-aot andrewsignori-aot Mar 20, 2026

Choose a reason for hiding this comment

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

I tried to change them all across all the files.

const collegeFAlternativeLocation = createFakeInstitutionLocation({
institution: collegeF,
});
const application = await saveFakeApplication(db.dataSource, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is as good as const application = await saveFakeApplication(db.dataSource); for the test and alternative location is not required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it would work, but the idea was to have a location under the same institution being used for the other for the same scenario.

formCategory: FormCategory.StudentAppeal,
status: FormSubmissionStatus.Completed,
submittedDate: formSubmission.submittedDate.toISOString(),
assessedDate: formSubmission.assessedDate?.toISOString(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

The optional chaining operation is not required 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.

Removed the "?".

configurations: [
.expect(({ body }) =>
expect(body.configurations).toEqual(
expect.arrayContaining([
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to use arrayContaining?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the DB now has other dynamic configurations added along with the tests that would be retrieved by this method. The idea was to keep the validation to ensure the PROD ones are present.

const formSubmission = await saveFakeFormSubmissionFromInputTestData(db, {
formCategory: FormCategory.StudentAppeal,
submissionStatus: FormSubmissionStatus.Pending,
auditUser: ministryUser,
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: creator should be a student

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am changing to internally use the student for the form submission creation and audit user for the Ministry scope, for instance, while saving the decision.

Comment on lines +136 to +139
!hasFormSubmissionApprovalAuthorization(
submissionItem.dynamicFormConfiguration.formCategory,
userRoles,
) && submissionStatus === FormSubmissionStatus.Pending;
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

): DynamicFormConfiguration {
const dynamicFormConfiguration = new DynamicFormConfiguration();
dynamicFormConfiguration.formType = formType;
dynamicFormConfiguration.formType = formType as DynamicFormType;
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

/**
* Gets the list of form submissions for a student,
* including the individual form items and their details.
* @param studentId student ID to retrieve the form submission history for.
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: missing userToken comment definition

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We refrain from adding it. There will be many endpoints missing it.

@dheepak-aot
Copy link
Collaborator

Nice work. Just a few minor comments.

@sonarqubecloud
Copy link

@github-actions
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 20.12% ( 4577 / 22747 )
Methods: 9.47% ( 262 / 2768 )
Lines: 24.49% ( 3929 / 16045 )
Branches: 9.81% ( 386 / 3934 )

@github-actions
Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 48.25% ( 2712 / 5621 )
Methods: 38.2% ( 285 / 746 )
Lines: 55.11% ( 2049 / 3718 )
Branches: 32.67% ( 378 / 1157 )

@github-actions
Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 79.31% ( 9155 / 11543 )
Methods: 78.42% ( 1181 / 1506 )
Lines: 82.64% ( 6881 / 8326 )
Branches: 63.88% ( 1093 / 1711 )

@github-actions
Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 65.55% ( 12995 / 19824 )
Methods: 62.3% ( 1527 / 2451 )
Lines: 69.14% ( 9431 / 13640 )
Branches: 54.57% ( 2037 / 3733 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

E2E/Unit tests Institution Institution Features Ministry Ministry Features Student Student Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants