-
Notifications
You must be signed in to change notification settings - Fork 733
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
tests: add tests for some files in ContentRenderer
#12056
Conversation
Build Artifacts
|
I am not sure - but I suspect that you are mocking |
My bad @rtibbles! Since the composable itself operates on a |
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 @EshaanAgg! The tests look correct to me. Furthermore, the isAppContext
seems to be mocked correctly now.
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.
Hi @EshaanAgg! Thank you! This is looking fine! Just a couple of comments on some test names, and reminders that we dont need to include the import '@testing-library/jest-dom';
statement on every test suite 👐.
kolibri/core/assets/src/views/ContentRenderer/__tests__/ContentRendererError.spec.js
Outdated
Show resolved
Hide resolved
}); | ||
|
||
test('should not render if there are no downloadable files even if isAppContext is false', () => { | ||
renderComponent({ |
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 think we need to find a better way of passing the useUserMock values, because reading just the testcase I could think that isAppContext
is a prop of the component, but it isn't, so we can maybe wrap this value in a useUserMock
object? This way the name suggest that we are passing this value to a mock of a composable. And we can end up in something like:
renderComponent({
files: [],
useUserMock: { isAppContext: false }
});
Let me know what do you think, as we can standarize this way of passing composables mock values.
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.
Indeed, this looks better! This provides a clear boundary between the props of the component, and all the other configuration that might be required by it, making it easier to reason about. Will update!
props: { | ||
files: [], | ||
nodeTitle: '', | ||
...props, |
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.
Just flagging that we are still passing the isAppContext
as prop here. To prevent this from happening, we can use destructuring:
const renderComponent = props => {
const { isAppContext, ...componentProps } = props;
...
};
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.
Got it! Since how we are using the name useUserMock
for all the composable mocks, the structure would be a bit different, but I get the spirit. Thanks!
kolibri/core/assets/src/views/ContentRenderer/__tests__/utils.spec.js
Outdated
Show resolved
Hide resolved
kolibri/core/assets/src/views/ContentRenderer/__tests__/utils.spec.js
Outdated
Show resolved
Hide resolved
kolibri/core/assets/src/views/ContentRenderer/__tests__/ContentRendererLoading.spec.js
Outdated
Show resolved
Hide resolved
kolibri/core/assets/src/views/ContentRenderer/__tests__/DownloadButton.spec.js
Outdated
Show resolved
Hide resolved
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 @EshaanAgg! This looks great! LGTM.
Summary
ContentRenderer
directoryContentRenderer/DownloadButton
are not complete, as even when I pass valid files to the same, I can't see a dropdown being rendered in the DOM, and thus I am unable to test its user interaction. Would highly appreciate any help I can get on the same.Reviewer guidance
…
Testing checklist
PR process
Reviewer checklist
yarn
andpip
)