-
Notifications
You must be signed in to change notification settings - Fork 2
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
ISSUE-9: Add tests #10
Conversation
setIps((ps) => ({...ps, history: history, isLoading: isLoading, error: error?.message})); | ||
createIpsResource(uuid, abortController) | ||
.then((response) => { | ||
if (response.status === 200) { |
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.
What would happen if the response is not 200? I think we'd be better served by removing this check.
isLowContrast: true, | ||
kind: 'success', | ||
title: t('ipsCreated', 'IPS'), | ||
title: t('ipsCreationError', 'IPS'), |
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.
Shouldn't the title here be something like "Error updating IP"
'ipsNowAvailable', | ||
'The IPS has been updated and is now visible in the Patient History.', | ||
'checkForServerAvailability', | ||
'The Fhir server maybe unreachable or the IPS generation process exited with an error!', |
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.
FHIR like IPS is an acronym (Fast Healthcare Interoperability Resources)
'The Fhir server maybe unreachable or the IPS generation process exited with an error!', | |
'The FHIR server maybe unreachable or the IPS generation process exited with an error!', |
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.
It might be better to pass through a more detailed error from the backend. At the very least, the message should be logged to the console as an error.
subtitle: t('checkForServerAvailability', 'The Fhir server maybe unreachable or the IPS generation process exited with an error!'), | ||
}) | ||
.finally(() => { | ||
abortController.abort(); |
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.
It's actually kind of dangerous to call abort()
on an instance that might be reused since further requests will already be aborted. It's probably better just to remove the abort controller from here altogether.
src/history/patient-history.test.tsx
Outdated
const mockUsePatient = jest.mocked(usePatient); | ||
const mockUseIpsResource = jest.mocked(useIpsResource); |
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.
Why not create the mocks once, outside of the it()
block and then just change the return value?
src/history/patient-history.test.tsx
Outdated
|
||
describe('Display patient IPS', () => { | ||
beforeEach(() => { | ||
const mockUseParams = useParams as jest.Mock; |
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.
const mockUseParams = useParams as jest.Mock; | |
const mockUseParams = jest.mocked(useParams); |
src/test.util.tsx
Outdated
}, | ||
}; | ||
|
||
export const mockIPS = { |
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 usual convention would be to put this in a mocks folder rather than directly in src.
src/test.util.tsx
Outdated
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.
Use .ts
for anything that doesn't actually use JSX.
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.
Basically good. Two small things.
@@ -30,4 +33,5 @@ module.exports = { | |||
testEnvironmentOptions: { | |||
url: 'http://localhost/', | |||
}, | |||
}; | |||
testTimeout: 25000, | |||
}; |
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.
}; | |
}; | |
jest.config.js
Outdated
@@ -30,4 +33,5 @@ module.exports = { | |||
testEnvironmentOptions: { | |||
url: 'http://localhost/', | |||
}, | |||
}; | |||
testTimeout: 25000, |
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.
Is this timeout strictly necessary? Things like this tend to make builds take a long time (since it potentially pauses for 25 seconds for a unit tests, which feels excessive).
Requirements
For changes to apps
If applicable
Summary
Issue: #9
Screenshots
Related Issue
Other