Skip to content

#5849 - Form Submissions, Appeals and Change requests notifications#5895

Open
tiago-graf wants to merge 17 commits intomainfrom
feature/#5849-appeal-notification
Open

#5849 - Form Submissions, Appeals and Change requests notifications#5895
tiago-graf wants to merge 17 commits intomainfrom
feature/#5849-appeal-notification

Conversation

@tiago-graf
Copy link
Collaborator

@tiago-graf tiago-graf commented Mar 13, 2026

Summary

Introduces email notifications via GC Notify for key events in the form submission, student appeal, and application change request workflows.

New notification types (IDs 36–39):

MinistryChangeRequestSubmitted (36) — Notifies the ministry when a student submits a legacy change request.
StudentChangeRequestReviewCompleted (37) — Notifies the student when their change request or appeal review is complete.
MinistryFormSubmitted (38) — Notifies the ministry when a student submits a new appeal or standard form, including the form category (application appeal, other appeal, or standard form) and human-readable form names.
StudentFormCompleted (39) — Notifies the student when their submitted form adjudication is finalized.

Updated notification types (IDs 5, 18)

MinistryAppealCompleted (5) - Renamed from "MinistryCompletesChange"
StudentAppealSubmitted (18) - Renamed from "StudentSubmittedChangeRequestNotification"

@tiago-graf tiago-graf self-assigned this Mar 14, 2026
@tiago-graf tiago-graf requested a review from Copilot March 15, 2026 22:46
@tiago-graf tiago-graf added E2E/Unit tests Backend Used by the dependabot pull requests to identify PRs related to the backend. labels Mar 15, 2026
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

Adds new GC Notify email notifications to support the updated workflows around form submissions, student appeals, and application change requests.

Changes:

  • Introduced 4 new NotificationMessageType values (36–39) and seeded notification_messages with corresponding templates.
  • Added notification action methods to create ministry/student notifications for change requests and form/appeal submissions/completions.
  • Updated student appeal, form submission, and change request services + e2e specs to generate/validate the new notifications (including friendly form names and category labels).

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
sources/packages/backend/libs/sims-db/src/entities/notification.model.ts Adds new notification message type IDs (36–39).
sources/packages/backend/libs/services/src/notifications/notification/notification.model.ts Adds the payload model for “ministry form submitted” notifications.
sources/packages/backend/libs/services/src/notifications/notification/notification-actions.service.ts Implements new notification creation methods for change requests and form/appeal events.
sources/packages/backend/libs/services/src/constants/notification.constants.ts Adds constants used by tests for template IDs and ministry-facing form category labels.
sources/packages/backend/libs/services/src/constants/index.ts Exposes the new notification constants.
sources/packages/backend/apps/db-migrations/src/sql/NotificationMessages/Insert-appeal-change-request-notification-messages.sql Seeds notification message records for IDs 36–39.
sources/packages/backend/apps/db-migrations/src/sql/NotificationMessages/Rollback-insert-appeal-change-request-notification-messages.sql Rollback script for the new seed data.
sources/packages/backend/apps/db-migrations/src/migrations/1773355579843-InsertAppealChangeRequestNotificationMessages.ts Migration to apply/rollback the new notification message seeds.
sources/packages/backend/apps/api/src/services/student-appeal/student-appeal.service.ts Sends either legacy change-request or new appeal “form submitted” ministry notification based on program year; maps technical to friendly form names.
sources/packages/backend/apps/api/src/services/student-appeal/student-appeal-assessment/student-appeal-assessment.service.ts Sends the correct student notification on assessment completion (legacy vs new).
sources/packages/backend/apps/api/src/services/form-submission/form-submission.models.ts Extends submission config typing to include formType for friendly names.
sources/packages/backend/apps/api/src/services/form-submission/form-submission-submit.service.ts Sends ministry “form submitted” notification on submission creation.
sources/packages/backend/apps/api/src/services/form-submission/form-submission-approval.service.ts Sends student “form completed” notification when adjudication completes.
sources/packages/backend/apps/api/src/services/dynamic-form-configuration/dynamic-form-configuration.service.ts Adds lookup by form definition name to support friendly form name mapping.
sources/packages/backend/apps/api/src/services/application/application.service.ts Sends ministry change request submitted notification when change request is created.
sources/packages/backend/apps/api/src/services/application-change-request/application-change-request.service.ts Sends student change request review completed notification when assessed.
sources/packages/backend/apps/api/src/route-controllers/student-appeal/tests/e2e/student-appeal.students.controller.submitStudentAppeal.e2e-spec.ts Updates/validates ministry notification for student-only appeals (Other appeal).
sources/packages/backend/apps/api/src/route-controllers/student-appeal/tests/e2e/student-appeal.students.controller.submitApplicationAppeal.e2e-spec.ts Adds coverage for legacy vs 2025-26+ program year notifications on submission.
sources/packages/backend/apps/api/src/route-controllers/student-appeal/tests/e2e/student-appeal.aest.controller.approveStudentAppealRequests.e2e-spec.ts Validates student notifications for completed appeal assessment (legacy vs new).
sources/packages/backend/apps/api/src/route-controllers/application-change-request/tests/e2e/application-change-request.aest.controller.assessApplicationChangeRequest.e2e-spec.ts Validates student notification for change request review completion.

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

@tiago-graf tiago-graf marked this pull request as ready for review March 15, 2026 23:27
@andrewsignori-aot andrewsignori-aot self-requested a review March 16, 2026 18:36
formCategory: FormCategory,
entityManager: EntityManager,
): Promise<void> {
// Load student info required for the notification.
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two queries can be executed as follows and provide friendly error messages.

const student = await entityManager.getRepository(Student).findOneOrFail({
  select: {
    id: true,
    birthDate: true,
    user: { id: true, firstName: true, lastName: true, email: true },
    applications: { id: true, applicationNumber: true },
  },
  relations: { user: true, applications: true },
  where: {
    id: studentId,
    applications: { id: applicationId },
  },
});
if(!student){
  throw new Error("Student not found while sending notification.");
}
if(applicationId && !student.application){
  throw new Error("Application not found found while sending notification.");
}

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot Mar 17, 2026

Choose a reason for hiding this comment

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

Was this suggestion accepted? I am not able to see the change.

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 had to adapt it since the applications is 1-N relation

* Student submitted appeal.
*/
StudentSubmittedChangeRequestNotification = 18,
StudentSubmittedAppealNotification = 18,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed since this is now a appeal specific notification

* Ministry completes updating an appeal requested by student.
*/
MinistryCompletesChange = 5,
MinistryCompletesAppeal = 5,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed since this is now a appeal specific notification

}

/**
* Sends a ministry notification when a student submits a new program year change request.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The "program year" in the comment seems to be misleading.
Please adjust it as follows.

Sends a ministry notification when a student submits a change request (edit post-COE).

* @param formDefinitionName form definition name.
* @returns dynamic form configuration for the requested form definition name.
*/
getFormByDefinitionName(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This method can be removed now.

Comment on lines +262 to +265
* Ministry notification data when a student submits a form or appeal,
* with form type categorization (application appeal, other appeal, standard form),
* a comma-separated list of human-readable form names, and the related application number.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comments should be reviewed: "(application appeal, other appeal, standard form)" is no longer valid, and "form or appeal" is not required.

beforeEach(async () => {
MockDate.reset();
// Mark all existing student appeal notifications as sent to isolate test assertions.
await db.notification.update(
Copy link
Collaborator

Choose a reason for hiding this comment

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

These can be combined as below.

await db.notification.update(
  {
    notificationMessage: {
      id: In([
        NotificationMessageType.StudentChangeRequestReviewCompleted,
        NotificationMessageType.MinistryAppealCompleted,
      ]),
    },
  },
  { dateSent: new Date() },
);

studentFileRepo = dataSource.getRepository(StudentFile);
recentActiveProgramYear = await getRecentActiveProgramYear(db);
// Update fake email contacts to send ministry notifications.
await db.notificationMessage.update(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

@andrewsignori-aot andrewsignori-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 and for the effort in tracking the different notifications for the different features. Minor comments left, please take a look.

@sh16011993 sh16011993 self-requested a review March 17, 2026 20:37
@sonarqubecloud
Copy link

@github-actions
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 20.12% ( 4572 / 22725 )
Methods: 9.47% ( 262 / 2767 )
Lines: 24.48% ( 3924 / 16032 )
Branches: 9.83% ( 386 / 3926 )

@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: 64.62% ( 12793 / 19796 )
Methods: 61.15% ( 1497 / 2448 )
Lines: 68.41% ( 9319 / 13623 )
Branches: 53.07% ( 1977 / 3725 )

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

Labels

Backend Used by the dependabot pull requests to identify PRs related to the backend. E2E/Unit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants