fix: use allowedPartyTypes to filter valid parties #2309
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Our form at Digital gravferdsmelding has suddenly startet displaying this error message locally, and it seems like this started in version 4.4.0.
I think the issue was introduced in this PR but I am not quite sure if this is a bug in the app frontend or if our app is providing incorrect data.
The issue occurs because when the frontend is reducing valid parties it filters each party on a condition
partyTypeFilters[party.partyTypeName]
from line 38 inpartyProviderUtils
. The issue with this is thatpartyTypeFilters
is an object that is contructed in this util function like this:Where
PartyType
looks like this:This, in my case, evaluates to a filter like this:
However,
party.partyTypeName
is not an int representing one of these values, but rather a string"person"
, which means that line 38 will always evaluate tofalse
for every party, even though that party should be valid.So I am wondering if the
partyTypeName
should actually be the string"person"
, and there is a bug in the code, or are we doing something incorrectly in our form that makes the/parties
-endpoint return incorrect data?EDIT: I see that the cypress tests are all failing, and that the types for
IParty
suggest thatpartyTypeName
should in fact bePartyTypes
(enum integer value). Can someone confirm if this is correct? 😅Verification/QA
kind/*
label to this PR for proper release notes grouping