Skip to content

Fix institution mismatch after saving vetting-type-hint - #532

Open
kayjoosten wants to merge 2 commits into
mainfrom
feature/issue-409-vetting-type-hint-institution
Open

kayjoosten wants to merge 2 commits into
mainfrom
feature/issue-409-vetting-type-hint-institution

Conversation

@kayjoosten

Copy link
Copy Markdown
Contributor

Summary

  • After saving activation help text (vetting-type-hint) for an institution other than the RAA's home institution, the "Select institution" dropdown and page subtitle snapped back to the home institution while the displayed text stayed on the institution just edited.
  • Redirect to the same route with the saved institution on success (POST/Redirect/GET), so the dropdown and subtitle stay in sync with the saved hints.
  • On save failure, the form still re-renders in place so submitted input isn't lost.

Fixes #409

Test plan

  • As an RAA/SRAA with access to 2+ institutions, edit vetting-type-hint text for a non-home institution and save; confirm the dropdown and displayed text both show the edited institution afterwards.
  • Confirm a failed save keeps the submitted hint text on the form instead of clearing it.
  • COMPOSER_MEMORY_LIMIT=1G composer check-ci passes.

Redirect to the vetting-type-hint route with the saved institution on
success, instead of re-rendering directly. Previously the select
institution dropdown and page subtitle fell back to the RAA's home
institution on POST, while the hint text shown was for the institution
that was actually just edited, leaving the two out of sync. On save
failure the form still re-renders in place so the submitted hints are
not lost.

Fixes #409
@kayjoosten
kayjoosten requested a review from johanib September 7, 2026 09:04
$this->logger->debug('Vetting type hint saving failed, adding error to form');
$this->addFlash('error', 'ra.vetting_type_hint.error');

return $this->redirectToRoute('vetting_type_hint', ['institution' => $institution]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This does not seem to fix the issue. It seems, when you choose an institution, the URL does not change, which this fix relies on.

Also, can we add integration tests, like panther? So we can properly test this, instead of using the controller test that sets up a very specific scenario to test, which does not represent the real situation.

The previous version of this fix redirected using $institution, which
is only ever set from the URL's institution query param. Selecting a
non-home institution via the select-institution form never changes the
URL though (it re-renders in place), so any save made after switching
institutions redirected back to the RAA's home institution again,
reintroducing the original bug.

Use $command->institution (bound from the hint form's hidden field,
which does correctly carry the just-selected institution forward
across requests) for the redirect, but only when it is one of the
institutions this identity is actually authorized for. This keeps the
dropdown/subtitle in sync with the institution that was really saved,
while still refusing to trust a tampered hidden field.

Adds a WebTestCase-based functional test that exercises the real,
multi-request flow (select a non-home institution, then save) end to
end, since the existing controller test only covered a single-
institution scenario and could not catch this regression. This needed
symfony/browser-kit and symfony/css-selector as new dev dependencies,
and a fix to ci/qa/phpunit: it never exported APP_ENV as a real
environment variable, so config/bootstrap.php always fell back to the
"prod" environment for phpunit, and kernel-booting tests failed with
framework.test not being enabled.
@kayjoosten
kayjoosten force-pushed the feature/issue-409-vetting-type-hint-institution branch from 4e656f9 to b70f473 Compare September 16, 2026 11:56
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.

After setting vetting-type-hint "Select institution" returns to RAAs home institution

2 participants