fix: useExamAccess hook does not make call to fetchExamAccessToken after isExam changes.#1644
Merged
michaelroytman merged 1 commit intomasterfrom Mar 20, 2025
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1644 +/- ##
=======================================
Coverage 90.08% 90.08%
=======================================
Files 338 338
Lines 5782 5782
Branches 1410 1410
=======================================
Hits 5209 5209
Misses 556 556
Partials 17 17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
varshamenon4
approved these changes
Mar 20, 2025
Contributor
varshamenon4
left a comment
There was a problem hiding this comment.
Nice! Just one nit/typo!
| }); | ||
| } | ||
| }, [id]); | ||
| }, [id, isExam]); |
| const [isExam, setIsExam] = useState(initialState); | ||
|
|
||
| // This setTimeout block is intended to replicate the case where a unit is an exam, but | ||
| // the call to fetch exam metada has not yet completed. That is the value of isExam starts |
Contributor
There was a problem hiding this comment.
Is this supposed to be metadata?
Suggested change
| // the call to fetch exam metada has not yet completed. That is the value of isExam starts | |
| // the call to fetch exam metadata has not yet completed. That is the value of isExam starts |
Contributor
Author
There was a problem hiding this comment.
Thanks for catching that! I'll push up a fix.
| expect(blockAccess).toBe(true); | ||
| expect(mockFetchExamAccessToken).toHaveBeenCalled(); | ||
|
|
||
| // This is to get rid of the act(...) warning. |
…ter isExam changes This commit fixes a bug that prevents the fetchExamAccessToken hook in the useExamAccess hook from running. This occurs when the value of isExam returned by the useIsExam hook changes from false to true. Because the dependency array of the useEffect hook within the useExamAccess hook was ['id'], the useEffect hook would not rerun on changes to isExam. The fix is to add isExam to the dependency array.
4a16065 to
f098b74
Compare
KristinAoki
pushed a commit
that referenced
this pull request
Mar 25, 2025
…ter isExam changes (#1644) This commit fixes a bug that prevents the fetchExamAccessToken hook in the useExamAccess hook from running. This occurs when the value of isExam returned by the useIsExam hook changes from false to true. Because the dependency array of the useEffect hook within the useExamAccess hook was ['id'], the useEffect hook would not rerun on changes to isExam. The fix is to add isExam to the dependency array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This commit fixes a bug that prevents the
fetchExamAccessTokenhook in theuseExamAccesshook from running. This occurs when the value ofisExamreturned by theuseIsExamhook changes fromfalsetotrue. Because the dependency array of theuseEffecthook within theuseExamAccesshook was['id'], theuseEffecthook would not rerun on changes toisExam. The fix is to addisExamto the dependency array.Jira: COSMO-673 (private)