-
Notifications
You must be signed in to change notification settings - Fork 55
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
Refactor test card #6653
Refactor test card #6653
Conversation
FYI on |
c31ac0f
to
bb43a29
Compare
8fcf902
to
42c812e
Compare
I didn't see the ticket or design specify whether the test cards should default to the collapsed state or the expanded one. It looks like they're expanded by default? Just wanting to call this out to confirm 👍 |
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [testOrder]); |
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.
I know I've had to disable this linting error before, but with how consistently we're ignoring it - is there a more correct way of doing this? Or can we update the linter to not complain about this if its not actually an issue?
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.
Thanks for mentioning this! After I looked into it a bit more, the React team strongly recommends keeping the rule and reworking the code to handle it properly. I'm experimenting with the code and we may be able to remove some of these useEffects entirely, so I'll create a follow up PR for this.
Some of this effect code will benefit significantly when React officially releases the new useEffectEvent
hook on a stable version. For example, we need to control for race conditions between the frontend saving edits and the periodic live sync with any updates from the backend.
When we get new values from the backend, we have to check whether the mutations are still loading and although those loading booleans are reactive values that React says should be included in the dependency array, we don't want those in the array because then the effect will be triggered whenever those change and potentially cause sync issues.
useEffect(() => {
// don't update if there are unsaved dirty changes or if still awaiting saved edits
if (state.dirty || editQueueItemMutationLoading || updateAoeMutationLoading)
return;
dispatch({
type: TestFormActionCase.UPDATE_WITH_CHANGES_FROM_SERVER,
payload: testOrder,
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [testOrder]);
So once useEffectEvent
is officially added, we'll be able to separate reactive values that are actual effect dependencies from ones that are only used for conditional logic.
…to mike/6079-refactor-test-card
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.
Nice work, Mike! Left my first bunch of comments.
Do you have access to Deque's axe dev tool? I think it will be helpful to run particularly against multiple test cards in the conduct test page.
@@ -240,8 +242,10 @@ export const TestTimerWidget = ({ timer, context }: Props) => { | |||
data-testid="timer" | |||
aria-label="Start timer" |
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.
can we pass in the patient's name so if there are multiple test timer buttons on a conduct page we know which person's test the timer is for?
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.
I agree this should be added on the aria label, although I think we should create a separate ticket for it since it'll also affect the existing queue item component which will still be used in prod until the new test card feature flag is enabled
@emyl3 thanks for the reminder about the axe devtools extension! I pushed some updates that improve accessibility. Once the PR is approved, the design team will be conducting usability testing using the demo environment. The new test card feature flag will remain disabled in the prod environment |
Kudos, SonarCloud Quality Gate passed! |
const areAllResultsRequired = | ||
isSomeFluFilled || !deviceSupportsCovidOnlyResult; | ||
|
||
return ( |
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.
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.
that's a good catch 🔍
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.
We're likely going to remove that inconclusive checkbox altogether in favor of simplifying the result validation rules for multiplex devices. That change should be in the upcoming PR for supporting HIV on the test card
name={patientFullName} | ||
removeTestFromQueue={removeTestFromQueue} | ||
/> | ||
<Card className={"list-style-none margin-bottom-1em test-card-container"}> |
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.
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.
Noticed this on the axe scan, but holding off on changing it until the follow-up PR because a few issues popped up with nesting the queue under a single ul
so additional refactor and updating some tests would be needed
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.
flagged a couple more things but am approving since it sounds like we'll be doing more work on this later and we need to get this out for design/research soon! functionality-wise looks good
FRONTEND PULL REQUEST
Related Issue
Changes Proposed
TestCard
component used instead of the existingQueueItem
if thetestCardRefactorEnabled
feature flag is active.TestCard
uses a collapisble design which will display theTestCardForm
as a child component when the card is expanded. TestCardForm is where the majority of the conduct tests business logic is used while TestCard primarily serves as the header and overall form container.AOE
TestCardForm
. The COVID AOE questions are used by default, but other disease specific AOE form components can be swapped when additional supported diseases are added.Test Results
Timer
TestCard
and existingQueueItem
.Additional Information
useReducer
to manage the form state instead of multipleuseState
hooks. This was chosen because some state properties depend on each other or on the previous state and encapsulating this state management in a reducer with discrete dispatch actions improves the testability and readability of the main TestCardForm.TestCardForm.utils
contains some custom hooks and helper functions with the goal of balancing just enough abstraction to improve readability and understanding of how the test card works overall.Testing
TestCard
andTestCardForm
is still in progress.Screenshots / Demos
Multiplex with all results
Multiplex missing results
Flu only device and custom backdate
Incomplete AOE questions confirmation modal before submitting
Invalid test date
Collapsed view