-
Notifications
You must be signed in to change notification settings - Fork 43
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
👻 Add unit tests and hook for useAssessmentStatus #1758
👻 Add unit tests and hook for useAssessmentStatus #1758
Conversation
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 like this approach to have a bunch of unit tests running on a hook!
The next step would be to use MSW in jest and let the data come from that code set. That would even let us run the UI in MSW mode with the unit test data to live dev against!
426f36b
to
3074620
Compare
Does this also cover #1646? |
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 really like this approach and the unit tests. Being able to test against different application+archetype+assessment/questionnaire shapes makes me happy.
Only one comment about providing "generic fetch data" to the custom hook.
...ages/applications/components/application-assessment-status/application-assessment-status.tsx
Outdated
Show resolved
Hide resolved
6022220
to
c161f6f
Compare
fefce1f
to
4971b28
Compare
95d8c24
to
71f93a0
Compare
5378c83
to
4796ac1
Compare
510144a
to
1fbaffa
Compare
cecde39
to
818f1ee
Compare
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.
The tests and the hook look pretty good! MSW with the server.use()
as part of the test is super nice! I wonder if there is a nicer way to manage the input test data such that the objects can be defined more as a graph to keep it "simpler". That'll just stick in the back of my head for a bit...
A few very minor change requests.
if (isApplicationDirectlyAssessed) { | ||
statusPreset = "Completed"; | ||
} else if (allArchetypesAssessed) { | ||
statusPreset = "InheritedAssessments"; | ||
tooltipCount = assessedArchetypesWithARequiredAssessment.length; | ||
} else if (hasInProgressOrNotStartedRequiredAssessments) { | ||
tooltipCount = countOfFullyAssessedArchetypes; | ||
} else if (countOfArchetypesWithRequiredAssessments > 0) { | ||
statusPreset = "InProgressInheritedAssessments"; | ||
tooltipCount = assessedArchetypesWithARequiredAssessment.length; | ||
} else if ( | ||
applicationAssessments?.some( | ||
(assessment) => assessment.status === "started" | ||
) | ||
) { | ||
tooltipCount = countOfArchetypesWithRequiredAssessments; | ||
} else if (hasApplicationAssessmentInProgress) { | ||
statusPreset = "InProgress"; | ||
} |
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 to see the status inputs all boil down to the icon right here.
It may be worth thinking about putting these calculations right in the hook as something like "assessmentStatus" and have it be an Enum or similar (NotStarted, InProgress, Completed, InheritedInProgress, InheritedCompleted) that can match over to the IconedStatus preset. That would give another unit testable data point.
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'd like to revisit this further as well. Maybe in a future PR since this is stable & fixes the bugs referenced.
...ations/components/application-assessment-status/tests/application-assessment-status.test.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Ian Bolton <[email protected]>
Signed-off-by: Ian Bolton <[email protected]>
Signed-off-by: Ian Bolton <[email protected]>
ee62a47
to
235e8dd
Compare
Signed-off-by: Ian Bolton <[email protected]>
235e8dd
to
0eef349
Compare
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!
I'm excited now to be able to unit test data hooks following this pattern.
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.
Looks OK to me!
Inspired by latest QE issues surfacing around status regressions. Resolves https://issues.redhat.com/browse/MTA-2410 Resolves https://issues.redhat.com/browse/MTA-2409 Resolves #1646 ** Integrates MSW with unit test RTL framework to handle mock data without needing to add any extra stubs. --------- Signed-off-by: Ian Bolton <[email protected]> Signed-off-by: Cherry Picker <[email protected]>
Inspired by latest QE issues surfacing around status regressions. Resolves https://issues.redhat.com/browse/MTA-2410 Resolves https://issues.redhat.com/browse/MTA-2409 Resolves #1646 ** Integrates MSW with unit test RTL framework to handle mock data without needing to add any extra stubs. --------- Signed-off-by: Ian Bolton <[email protected]> Signed-off-by: Cherry Picker <[email protected]> Signed-off-by: Ian Bolton <[email protected]> Signed-off-by: Cherry Picker <[email protected]> Co-authored-by: Ian Bolton <[email protected]>
Inspired by latest QE issues surfacing around status regressions.
Resolves https://issues.redhat.com/browse/MTA-2410
Resolves https://issues.redhat.com/browse/MTA-2409
Resolves #1646
** Integrates MSW with unit test RTL framework to handle mock data without needing to add any extra stubs.