-
Notifications
You must be signed in to change notification settings - Fork 133
feat: add new unit test to check if request data is formatted in updateCourseAdvancedSettings #2193
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
base: master
Are you sure you want to change the base?
feat: add new unit test to check if request data is formatted in updateCourseAdvancedSettings #2193
Conversation
…teCourseAdvancedSettings
Thanks for the pull request, @jignaciopm! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are 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. 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. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2193 +/- ##
==========================================
- Coverage 94.09% 94.09% -0.01%
==========================================
Files 1164 1164
Lines 24493 24493
Branches 5196 5195 -1
==========================================
- Hits 23047 23046 -1
- Misses 1378 1379 +1
Partials 68 68 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@bradenmacdonald @arbrandes What do you think? Does it make sense to you? |
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 don't think this test is particularly realistic.
I was thinking something like this:
- Create a mock based on the actual data from the API
{
"display_name": {
"value": "Test Course Name",
"display_name": "Course Display Name",
"help": "Enter the name of the course as it should appear in the course list.",
"deprecated": false,
"hide_on_enabled_publisher": false
},
"course_edit_method": {
"value": "Studio",
"display_name": "Course Editor",
"help": "Enter the method by which this course is edited (\"XML\" or \"Studio\").",
"deprecated": true,
"hide_on_enabled_publisher": false
},
"showanswer": {
"value": "after_all_attempts_or_correct",
"display_name": "Show Answer",
"help": "Specify when the Show Answer button appears for each problem. Valid values are \"always\", \"answered\", \"attempted\", \"closed\", \"finished\", \"past_due\", \"correct_or_past_due\", \"after_all_attempts\", \"after_all_attempts_or_correct\", \"attempted_no_past_due\", and \"never\".",
"deprecated": false,
"hide_on_enabled_publisher": false
},
"advanced_modules": {
"value": ["poll", "lti_consumer", "survey", "google-document"],
"display_name": "Advanced Module List",
"help": "Enter the names of the advanced modules to use in your course.",
"deprecated": false,
"hide_on_enabled_publisher": false
},
"cert_html_view_overrides": {
"value": {
"accomplishment_banner_opening": "{fullname}, congrats on this certificate!",
"camelCaseKey": "camel case keys should be preserved if used",
},
"display_name": "Certificate Web/HTML View Overrides",
"help": "Enter course-specific overrides for the Web/HTML template parameters here (JSON format)",
"deprecated": false,
"hide_on_enabled_publisher": false
}
}
- Mock the HTTP endpoint for
/api/contentstore/v0/advanced_settings/:course_id
with that value - Call
getCourseAdvancedSettings()
, modify one or two values. - Call
updateCourseAdvancedSettings()
with the new values. - Assert that it calls the axios POST mock with the exact same data as in the mock (1) except for the changed values.
The mock includes: plain values, object values, deprecated value, and a JSON object value with both snake_case
and camelCase
so it should be a thorough test.
Then we can use the same mock to create an accurate test on the settings page itself: mock the endpoint, render the settings UI, make a couple changes, "click" on the Save button, and assert that the POST request to the server matches the original mock exactly except for the changes.
What do you think?
test_camel_case: { value: 'To come snake_case' }, | ||
pascal_case: { value: true }, | ||
kebab_case: { | ||
value: { nestedOption: 'This key must not be formatted' }, |
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 we have a value
with a nested option in snake_case
?
Description
This PR adds a unit test to check whether the request body of
updateCourseAdvancedSettings
is formatted insnake_case
.Supporting information
This PR is based on the suggestion in this comment
Testing instructions
N/A
Other information
N/A