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
Baseline tests for image picker component #34622
Conversation
I also feel like there's testing missing here that confirms that the modal opens when a user clicks "Choose..." in the imagePickerPropertyRow component, and closes once an asset is chosen: Neither imagePickerPropertyRow (the component that represents where you enter an image URL and the "Choose..." link, or the show.js file that actually is responsible for showing the modal have tests. Thoughts on where it would be appropriate to add such testing? |
Both of those files could probably use unit tests, but both are also tied into some global state which might be why they don't have tests now. I'd start with I don't think that should block this change though - these new tests look good on their own. |
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 adding coverage here! Looks like the four tests you added bring coverage to 83% for ImagePicker.jsx, which is great for initial coverage.
For my knowledge, how did you get that test coverage metric? |
Generate a coverage report by prefixing
This generates an HTML report in
You'll enter at a top-level view of the apps directory, and since in this example we only ran the one test file, coverage will look pretty dismal. In fact, this report won't include files that weren't touched at all by this test run, so don't be surprised if it seems like folders are missing. But if you drill down you can find the particular file you intended to test: You can even open up the file and view line-by-line coverage: |
Because it may be interesting: I ran our full unit test suite today (no storybook or integration tests) with coverage, and it reports 54% of statements covered right now. That varies a lot for different parts of our code, and is including some third-party code that is copied into our repo. Here is the coverage of some sibling components to |
Add some basic tests for the imagePicker component, which is used in Applab to pick an image:
Pre-work for updates to
imagePicker
to show students it's possible to add an image directly from a URL.Testing story
New tests passed locally.
Reviewer Checklist: