-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CST] Override the display name and status of "PMR Pending" requests. #32256
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Louis Fettet <louis@adhocteam.us>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review!
return items.map(item => { | ||
const newItem = { ...item }; | ||
const associatedDocs = getDocsAssociatedWithTrackedItem(newItem, docs); | ||
newItem.documents = associatedDocs || []; | ||
newItem.date = getTrackedItemDate(item); | ||
return newItem; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned this up a little to make it more concise. Notable changes are:
- I removed the
|| []
for assigningdocuments
, since I don't believe we can get here with a falsy return value forgetDocsAssoociatedWithTrackedItems
(sincedocs
need to be an array already to runfilter
on them). For additional safety, I went ahead and added a default value (empty array) for bothsupportingDocuments
andtrackedItems
at the beginning of theserializeClaim
function. - I moved setting
date
on the tracked item into the transform function, as I don't believe it's related to associating docs with the tracked item.
const transformUnassociatedDocs = docs => | ||
docs.map(doc => ({ | ||
...doc, | ||
date: doc.uploadDate, | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was moved into its own function from the original return of serializeClaim
.
const transformAssociatedTrackedItems = items => | ||
items.map(item => ({ | ||
...item, | ||
// <tempfix> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an established pattern I should use here for marking code as temporary? Ideally this would be some sort of consistent token we can search for during clean-up work.
supportingDocuments: transformedUnassociatedDocuments, | ||
trackedItems: transformedAssociatedTrackedItems, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables are a bit wordy; if we don't find the labeling helpful, we can just run the relevant functions like so:
supportingDocuments: transformUnassociatedDocs(
filterAssociatedDocs(supportingDocuments),
),
trackedItems: transformAssociatedTrackedItems(
associatedTrackedItems,
),
The result is the same regardless.
// <tempfix> | ||
// See notes on PMR Pending in serialize.js | ||
it('should manually override the status of PMR Pending requests', () => { | ||
const claim = { | ||
id: 1, | ||
type: 'claim', | ||
attributes: { | ||
trackedItems: [ | ||
{ | ||
id: 1, | ||
displayName: 'PMR Pending', | ||
status: 'NEEDED_FROM_YOU', | ||
}, | ||
], | ||
}, | ||
}; | ||
const serializedClaim = serializeClaim(claim); | ||
const trackedItem1 = serializedClaim.attributes.trackedItems.find( | ||
d => d.id === 1, | ||
); | ||
expect(trackedItem1.status).to.eql('NEEDED_FROM_OTHERS'); | ||
}); | ||
// </tempfix> | ||
|
||
it('should replace the display name of some types of tracked items', () => { | ||
const claim = { | ||
id: 1, | ||
type: 'claim', | ||
attributes: { | ||
trackedItems: [ | ||
{ | ||
id: 1, | ||
displayName: 'PMR Pending', | ||
}, | ||
], | ||
}, | ||
}; | ||
const serializedClaim = serializeClaim(claim); | ||
const trackedItem1 = serializedClaim.attributes.trackedItems.find( | ||
d => d.id === 1, | ||
); | ||
expect(trackedItem1.displayName).to.eql('Private Medical Record'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are basically doing the same thing, but one tests the status
while the other tests the displayName
. Since testing the status is temporary, I kept them separate so that we can just remove that whole test case down the road.
@LouisFettet looks good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
The change here for the end-user is very simple:
The changes under the hood are:
serialize
reducer.serializeClaim
function uses other functions. These changes should be aesthetic only and shouldn't impact the result of the function.<tempfix>
comment block to make it clear that this is not a permanent solution to the problem.Related issue(s)
Testing done
@jerekshoe added a PMR Pending tracked item on claim
600555011
on user23
(Kyle Cole) in staging.It's possible that this tracked item appears on other pages that I'm unaware of, but the idea is that it should render properly as a third-party request with the updated display name across the app (since we're modifying it as soon as we receive data from the Lighthouse API).
A search for
PMR Pending
of the app returned no results, so it doesn't seem like there is any existing logic depending on the original display name or status (which should make this a safe change).Screenshots
What areas of the site does it impact?
Claim Status Tool
Acceptance criteria
Quality Assurance & Testing
Error Handling
Authentication
Requested Feedback
See self-review!