Skip to content

#5106 - Institution restriction institution impacts - Create offering API validations#5634

Merged
dheepak-aot merged 13 commits intomainfrom
feature/#5106-institution-restriction-institution-impacts-2
Jan 20, 2026
Merged

#5106 - Institution restriction institution impacts - Create offering API validations#5634
dheepak-aot merged 13 commits intomainfrom
feature/#5106-institution-restriction-institution-impacts-2

Conversation

@dheepak-aot
Copy link
Collaborator

@dheepak-aot dheepak-aot commented Jan 16, 2026

Institution restriction institution impacts - Create offering API validations

Offering validation

  • On all persistent actions (Create, update, request change) and on validate, the effective restrictions for program and location are provided to Offering validation modal
  • Added a custom validator IsActionAllowed to validate if the action is allowed. As of now restriction action is the only blocking factor to stop an action.
image

E2E tests

  • Added E2E test for create offering and update offering API to block and allow the operations respectively when effective restriction with action type Stop create offering is present.
EducationProgramOfferingInstitutionsController(e2e)-createOffering                                                                                                                                       
    √ Should throw bad request error on create new offering when the offering location and program has effective restriction with action type Stop offering create. (255 ms)
EducationProgramOfferingInstitutionsController(e2e)-updateProgramOffering                                                                                                    
    √ Should update an existing offering without any restriction impact when the offering location and program have effective restriction with action type Stop offering create. (395 ms)
  • Added E2E test for bulk offering create when effective restriction with action type Stop create offering is present.
EducationProgramOfferingInstitutionsController(e2e)-bulkInsert                                  
    √ Should return validation error when one or more records have effective restriction on location and program with action type Stop offering create. (252 ms)

@dheepak-aot dheepak-aot self-assigned this Jan 16, 2026
@dheepak-aot dheepak-aot added the SIMS-Api SIMS-Api label Jan 16, 2026
@dheepak-aot dheepak-aot requested a review from Copilot January 17, 2026 00:59
@dheepak-aot dheepak-aot marked this pull request as ready for review January 17, 2026 01:01
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 pull request implements validation to prevent creating or updating education program offerings when institution restrictions are in place. The core change is the addition of a custom validator IsActionAllowed that checks if offering actions (create, update, request change, validate) are blocked by effective restriction actions, specifically the StopOfferingCreate restriction type.

Changes:

  • Added a custom validator IsActionAllowed to check if offering actions are allowed based on effective restriction actions
  • Extended the OfferingValidationModel to include effectiveRestrictionActions and actionType fields
  • Updated offering creation, update, and validation flows to retrieve and validate against institution restrictions
  • Added comprehensive E2E tests for create, update, and bulk insert scenarios with restrictions

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
education-program-offering-validation.models.ts Added OfferingActionType enum, effectiveRestrictionActions and actionType properties to OfferingValidationModel, and return type annotations to helper functions
is-action-allowed.ts New custom validator that checks if offering actions are blocked by restriction actions, with specific error messaging for create operations
education-program-offering-import-csv.service.ts Updated CSV import to fetch institution restrictions and populate effectiveRestrictionActions and actionType for bulk offering validation
education-program-offering.controller.service.ts Modified buildOfferingValidationModel to accept actionType parameter and retrieve effective restrictions for location and program combinations
education-program-offering.institutions.controller.ts Updated all offering endpoints (validate, create, update, request change) to pass appropriate OfferingActionType to the validation model builder
education-program-offering.institutions.controller.createOffering.e2e-spec.ts Added E2E test verifying that creating an offering is blocked when StopOfferingCreate restriction is active
education-program-offering.institutions.controller.updateProgramOffering.e2e-spec.ts Added E2E test confirming that updating an offering is allowed even when StopOfferingCreate restriction is active (only blocks creation)
education-program-offering.institutions.controller.bulkInsert.e2e-spec.ts Added E2E test for bulk offering validation with restrictions, plus refactored setup to improve test isolation

})
institutionContext?: InstitutionValidationContext;
/**
* Effective restriction actions for the local and program.
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

The JSDoc comment has a typo: "local" should be "location".

Suggested change
* Effective restriction actions for the local and program.
* Effective restriction actions for the location and program.

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +28
const blockingRestrictionActionMap = new Map([
[OfferingActionType.Create, RestrictionActionType.StopOfferingCreate],
]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The map can be a const outside the method.

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 was going back and forth between keeping the map outside the method or within the constraint, but I do not see any benefit of keeping the map outside and passing it to the decorator. Let me know if there are any benefits keeping the map outside

Copy link
Collaborator

@weskubo-cgi weskubo-cgi Jan 19, 2026

Choose a reason for hiding this comment

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

For consistency's sake, I think that constant Arrays/Sets/Maps should follow constant naming conventions and defined at file level. That being see, I realize that this Map won't be used outside of this method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

To be clear, the below was the suggestion. I believed there was a misunderstanding.

image

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.

Great work, please take a look at the comments.

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, looks good 👍

@sonarqubecloud
Copy link

@github-actions
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 20.21% ( 4339 / 21471 )
Methods: 9.68% ( 254 / 2625 )
Lines: 24.34% ( 3719 / 15278 )
Branches: 10.26% ( 366 / 3568 )

@github-actions
Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 75.41% ( 1055 / 1399 )
Methods: 79.31% ( 115 / 145 )
Lines: 78.79% ( 769 / 976 )
Branches: 61.51% ( 171 / 278 )

@github-actions
Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 85.68% ( 1616 / 1886 )
Methods: 85% ( 187 / 220 )
Lines: 88.64% ( 1287 / 1452 )
Branches: 66.36% ( 142 / 214 )

@github-actions
Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 77.22% ( 8876 / 11494 )
Methods: 76.9% ( 1055 / 1372 )
Lines: 81.26% ( 6442 / 7928 )
Branches: 62.85% ( 1379 / 2194 )

@dheepak-aot dheepak-aot added this pull request to the merge queue Jan 20, 2026
Merged via the queue into main with commit 68f5018 Jan 20, 2026
22 checks passed
@dheepak-aot dheepak-aot deleted the feature/#5106-institution-restriction-institution-impacts-2 branch January 20, 2026 02:18
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.

3 participants