-
Notifications
You must be signed in to change notification settings - Fork 80
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
Fix warnings in Problem Editor [FC-0062] #1280
Fix warnings in Problem Editor [FC-0062] #1280
Conversation
Thanks for the pull request, @bradenmacdonald! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
4a708bb
to
d05cbd1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1280 +/- ##
==========================================
+ Coverage 92.34% 92.38% +0.04%
==========================================
Files 1023 1023
Lines 18877 18930 +53
Branches 4025 4026 +1
==========================================
+ Hits 17432 17489 +57
+ Misses 1376 1373 -3
+ Partials 69 68 -1 ☔ View full report in Codecov by Sentry. |
45ef259
to
f80de14
Compare
f80de14
to
7d57d4e
Compare
7d57d4e
to
64be177
Compare
declare module '*.png' { | ||
const content: string; | ||
export default content; | ||
} |
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.
This tells typescript that when we import PNG files, that import is getting a string
(from webpack, which is the URL to the image file)
}; | ||
|
||
export const SelectTypeFooterInternal = SelectTypeFooter; // For testing only | ||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(SelectTypeFooter)); | ||
export default SelectTypeFooter; |
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 modernized this component by:
- changing from
propTypes
to TypeScriptProps
- Changing
injectIntl
touseIntl
- Changing
connect
touseSelector
anduseDispatch
- Testing it in an actual browser in
src/editors/containers/ProblemEditor/components/SelectTypeModal/index.test.tsx
rather than shallow snapshot testing
There is no change to the actual code within the component itself.
@@ -17,6 +17,7 @@ exports[`SelectTypeWrapper snapshot 1`] = ` | |||
className="pgn__modal-close-container" | |||
> | |||
<IconButton | |||
alt="Exit the editor" |
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.
a11y fix: several of these icon buttons had no alt text!
selected, | ||
setSelected, | ||
}) => { | ||
const handleChange = e => setSelected(e.target.value); | ||
const handleClick = () => setSelected(AdvanceProblemKeys.BLANK); | ||
const settings = { 'aria-label': 'checkbox', type: 'radio' }; | ||
const settings = { type: 'radio' }; |
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.
a11y fix: in the "problem types" menu, every option had the same label for screen readers: 'checkbox'. This was worse than no label at all. Now they are labelled by their inner text ("Multiple choice", "Single select", etc.)
const selectBtn = screen.getByRole('button', { name: 'Select' }); | ||
fireEvent.click(selectBtn); | ||
expect(mockSelect).toHaveBeenLastCalledWith(expect.objectContaining({ selected: 'numericalresponse' })); | ||
}); |
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.
In order to fix some test coverage issues, I replaced the (almost useless) existing test here with this test which actually interacts with all of these components in a browser, and uses all the new best practices and utils from testUtils
. This also let me get rid of the ugly module
self-import pattern and the weird custom state hooks.
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.
👍 Massive cleanup here, thank you @bradenmacdonald ! All is working fine.
- I tested this by adding and editing problem components in a course. All still works as expected.
- I read through the code
- I checked for accessibility issues by using my keyboard to navigate and by checking the "accessibility properties" for the affected elements.
-
Includes documentationN/A - User-facing strings are extracted for translation
// rerandomize: PropTypes.string, | ||
// showResetButton: PropTypes.bool, | ||
// showanswer: PropTypes.string, | ||
// }).isRequired, |
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.
These commented-out lines can be removed now that you're using selectors instead.
@@ -88,6 +88,10 @@ export const AdvanceProblemKeys = StrictDict({ | |||
} as const); | |||
export type AdvancedProblemType = typeof AdvanceProblemKeys[keyof typeof AdvanceProblemKeys]; | |||
|
|||
export function isAdvancedProblemType(pt: ProblemType | AdvancedProblemType): pt is AdvancedProblemType { |
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.
Interesting.. I hadn't seen user type predicates before.
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.
They're quite useful!
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.
@bradenmacdonald Looks good 👍 I think you need to delete the comments that Jill mentioned and it will be ready to merge
Description
When you open a blank capa problem XBlock for editing, a ton of
propTypes
validation warnings appear in the console. This PR fixes those warnings and converts the validation to TypeScript (which is better than propTypes because TypeScript gets checked during CI, but propTypes warnings can easily be ignored).Supporting information
Part of my work toward #1086
Private ref: FAL-3825
Testing instructions
(Focus on testing from a course more so than from a library - at this point it's more important we don't break the course workflow)
Full list of warnings fixed
and when clicking on "Advanced problem types", the following warnings: