Skip to content

feat: publish visit updated for approved visit registration updates and align seed data#1524

Open
yoganandaness wants to merge 5 commits into
developfrom
SWAP-5322-uo-officer-should-be-able-to-change-approved-visi
Open

feat: publish visit updated for approved visit registration updates and align seed data#1524
yoganandaness wants to merge 5 commits into
developfrom
SWAP-5322-uo-officer-should-be-able-to-change-approved-visi

Conversation

@yoganandaness
Copy link
Copy Markdown
Contributor

Description

Publish VISIT_UPDATED for approved visit-registration updates, include id in visit payload, and update seed data for visit template activation and approved proposals.

Motivation and Context

Ensure downstream systems receive visit update events (not only create/delete) and improve local test data readiness.

How Has This Been Tested

  • Verified updated backend files show no editor/type errors.
  • Validated message broker routing and payload changes.
  • Confirmed SQL seed updates are syntactically valid.

Fixes

Enables visit sync on approved registration updates via VISIT_UPDATED.

Changes

  • Updated RabbitMQ publish logic for visit registration events.
  • Added id to visit event JSON payload.
  • Added active visit template seed.
  • Marked seeded proposals as management-approved.

Depends on

None.

Tests included/Docs Updated?

  • I have added tests to cover my changes.
  • All relevant doc has been updated

@yoganandaness yoganandaness requested a review from a team as a code owner May 21, 2026 07:37
@yoganandaness yoganandaness requested review from TCMeldrum and removed request for a team May 21, 2026 07:37
Copy link
Copy Markdown
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 extends the visit-registration event flow so downstream systems can receive “visit updated” notifications (not only create/delete) when an already-approved visit registration is edited. It also introduces a stable id for visit registrations across backend, frontend, messaging payloads, and seed data to improve local/dev readiness.

Changes:

  • Backend: add VISIT_REGISTRATION_UPDATED event and publish VISIT_UPDATED to RabbitMQ when an approved registration is updated; include registration id in the message payload.
  • Backend/DB: introduce a UUID primary key id on visits_has_users and propagate it through models/records/GraphQL types.
  • Frontend/E2E: query and use visitRegistration.id for in-place updates; allow editing approved registrations and add Cypress coverage; align seed data (active visit template + approved proposals).

Reviewed changes

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

Show a summary per file
File Description
apps/frontend/src/hooks/visit/useBlankVisitRegistration.ts Adds id field to the locally-created visit registration stub.
apps/frontend/src/hooks/proposalBooking/useActionButtons.tsx Uses registration id (instead of userId) when replacing updated/cancelled registrations in state.
apps/frontend/src/graphql/visitRegistration/fragment.visitRegistration.graphql Adds id to the visit registration fragment so clients receive it.
apps/frontend/src/components/visit/VisitRegistrationReview.tsx Adds UI label for APPROVED status.
apps/frontend/src/components/proposalBooking/UserUpcomingExperimentsTable.tsx Adjusts Dialog sizing props (maxWidth, fullWidth).
apps/frontend/src/components/experiment/ExperimentVisitsTable.tsx Uses id for replacement logic; enables edit button for APPROVED registrations; adds data-cy hook.
apps/e2e/cypress/e2e/visits.cy.ts Adds Cypress test for editing an approved visit registration.
apps/backend/src/resolvers/types/VisitRegistration.ts Exposes visit registration id in GraphQL type.
apps/backend/src/mutations/VisitMutations.ts Publishes VISIT_REGISTRATION_UPDATED when updating visit registrations.
apps/backend/src/models/VisitRegistration.ts Adds id to the VisitRegistration model constructor/signature.
apps/backend/src/events/event.enum.ts Adds new VISIT_REGISTRATION_UPDATED event enum value.
apps/backend/src/events/applicationEvents.ts Extends ApplicationEvent union with VisitRegistrationUpdatedEvent.
apps/backend/src/eventHandlers/messageBroker.ts Maps approved registration updates to RabbitMQ VISIT_UPDATED and adds id to payload.
apps/backend/src/datasources/postgres/records.ts Adds id to VisitRegistrationRecord and mapping constructor call.
apps/backend/src/datasources/mockups/VisitDataSource.ts Generates mock string ids for registrations and updates constructor calls.
apps/backend/db_patches/db_seeds/0008_VisitTemplate.sql Adds a seeded active VISIT_REGISTRATION template.
apps/backend/db_patches/db_seeds/0001_ProposalForScheduling.sql Marks seeded proposals as management-decision submitted.
apps/backend/db_patches/0210_AddIdPkToVisitsHasUsers.sql Adds UUID id PK to visits_has_users and retains uniqueness on (visit_id, user_id).

Comment on lines +5 to +11
BEGIN
ALTER TABLE visits_has_users
ADD COLUMN id UUID;

UPDATE visits_has_users
SET id = uuid_generate_v4()
WHERE id IS NULL;
Comment on lines +222 to +225
cy.get('[data-cy="save-and-continue-button"]').click();
cy.get('[data-cy="visit-status"]').should('have.text', 'APPROVED');

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants