Skip to content

TK-31: Add Automatic Group Creation for Information Sharing Agreements#36

Merged
klondikemarlen merged 16 commits intomainfrom
tk-31/automatic-group-creation
Feb 12, 2026
Merged

TK-31: Add Automatic Group Creation for Information Sharing Agreements#36
klondikemarlen merged 16 commits intomainfrom
tk-31/automatic-group-creation

Conversation

@klondikemarlen
Copy link
Member

@klondikemarlen klondikemarlen commented Feb 11, 2026

Fixes https://yg-hpw.atlassian.net/browse/TK-31

References:

Context

Implements automatic group creation when information sharing agreements is marked as signed. Previously, groups had to be manually created and associated with agreements, which was error-prone and inconsistent. This change automates the entire process, ensuring proper group creation, admin assignment, and also cleanup if agreements are reverted to draft.

Implementation

  1. Add automatic group creation service for information sharing agreements.
  2. Implement sharing and receiving group creation with proper admin assignment.
  3. Add group destruction when agreements are reverted to draft status.
  4. Refactor user group creation service to support mailer updates.
  5. Add comprehensive validation and error handling for group creation.
  6. Update information sharing agreement factory to remove optional associations.
  7. Add extensive test coverage for all group creation scenarios.

Screenshots

N/A - backend changes only

Testing Instructions

  1. Run the test suite via dev test.
  2. Boot the app via dev up.
  3. Log in to the app at http://localhost:3000.

Test Case 1: Signing an Agreement Creates Groups

  1. Navigate to AdministrationInformation Sharing Agreements.
  2. Click New to create a new agreement.
  3. Fill out Basic Information:
    • Enter a Title and Purpose.
    • Select a Sharing Group Contact (external/First Nation user).
    • Select a Receiving Group Contact (internal/YG user).
    • Select a Receiving Group Secondary Contact (YG Manager).
  4. Click Save to proceed to Agreement Duration & Expiration.
  5. Select an expiration condition and set an end date, then Save.
  6. Fill out Access and Confidentiality sections, saving each.
  7. From the agreement view page, click Sign Agreement.
  8. Upload a signed acknowledgement file (PDF or DOC) and submit.
  9. Verify the agreement status changes to Signed.
  10. On the agreement view page, verify that a Sharing Group chip and a Receiving Group chip now appear.
  11. Navigate to AdministrationGroups.
  12. Verify two new groups were created for this agreement.
  13. Click into the Sharing Group and go to the Users tab — verify the sharing group contact is listed as an admin.
  14. Click into the Receiving Group and go to the Users tab — verify both the receiving group contact and the secondary contact are listed as admins.

Test Case 2: Reverting to Draft Destroys Groups

  1. Navigate back to the agreement created in Test Case 1.
  2. Click Revert to Draft.
  3. Confirm the dialog by clicking Revert to Draft again.
  4. Verify the agreement status returns to Draft.
  5. Verify the Sharing Group and Receiving Group chips are no longer displayed on the agreement.
  6. Navigate to AdministrationGroups.
  7. Verify that both groups created in Test Case 1 have been removed.

Why? Vitest sometimes mangles names if resolution tree is complex.
This prevents tests from failing when the table name is incorrectly inferred.
Usually inferred as "_information_sharing_agreements" instead of "information_sharing_agreements".
Also add group destroy on ISA revert to draft.
Also fix some bugs in the implementation; sharing group is external.
All previous poolOptions are now top-level options.
Please, refer to the migration guide: https://vitest.dev/guide/migration#pool-rework
…when running multiple files.

Performance testing showed isolate true is ~17% faster than isolate false with vi.resetModules() (7.31s vs 8.86s).

Alternative solution for isolate: false:
- Add vi.resetModules() in beforeAll() hook in tests/setup.ts
- See: https://vitest.dev/guide/migration#pool-rework
@klondikemarlen klondikemarlen force-pushed the tk-31/automatic-group-creation branch from 403e143 to 83a2415 Compare February 12, 2026 17:11
Helps let AI Agents query database to find relevant info.
Why? I just wiped my database and don't want to re-enter test data manually.
Also because I'm from Dawson.
Must use object as parameter.
…module import failures occur.

Not sure if this is something that should only run in development?
@klondikemarlen klondikemarlen self-assigned this Feb 12, 2026
@klondikemarlen klondikemarlen added the enhancement New feature or request label Feb 12, 2026
@klondikemarlen klondikemarlen marked this pull request as ready for review February 12, 2026 17:53
…haring agreement.

Pretty fatal bug, good thing I QA-ed properly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant