Skip to content
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

Refactor use of frontend-lib-special-exams public API to use hooks. #1284

Merged

Conversation

michaelroytman
Copy link
Contributor

Description:

Jira: COSMO-175

NOTE: The corresponding pull request in frontend-lib-special-exams is a prerequisite to these changes: openedx/frontend-lib-special-exams#134. Those changes must be merged and deployed and the version of the library updated here before these changes can be merged.

This commit refactors the use of the frontend-lib-special-exams public API to use hooks.

This commit also imports the root reducer from the frontend-lib-special-exams library. This root reducer is used for the specialExams slice when configuring the store for this application.

@michaelroytman michaelroytman force-pushed the michaelroytman/COSMO-175-use-refactored-exams-API-hooks branch from c829607 to ff7f9cd Compare February 6, 2024 19:39
@@ -12,14 +12,23 @@ export const stateKeys = StrictDict({
const useExamAccess = ({
id,
}) => {
const [accessToken, setAccessToken] = useKeyedState(stateKeys.accessToken, '');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need to maintain this as state, since the useExamAccessToken hook takes care of getting the updated values from the specialExams store.

@@ -1,98 +0,0 @@
import React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff is showing up this way, because I had to rename this from a js file to a jsx file.

@@ -0,0 +1,88 @@
import { logError } from '@edx/frontend-platform/logging';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the article How to test custom React hooks to decide how to test this hook. I decided to focus on testing the return values instead of the internals of the hook, since that may change (as it did in this pull request). I think these tests will be more stables this way.

@michaelroytman michaelroytman marked this pull request as ready for review February 8, 2024 18:25
michaelroytman and others added 2 commits February 8, 2024 13:28
This commit refactors the use of the frontend-lib-special-exams public API to use hooks.

This commit also imports the root reducer from the frontend-lib-special-exams library. This root reducer is used for the specialExams slice when configuring the store for this application.
@alangsto alangsto force-pushed the michaelroytman/COSMO-175-use-refactored-exams-API-hooks branch from 64fa556 to a8fcd75 Compare February 8, 2024 18:30
@alangsto alangsto merged commit 170cbe1 into master Feb 8, 2024
4 checks passed
@alangsto alangsto deleted the michaelroytman/COSMO-175-use-refactored-exams-API-hooks branch February 8, 2024 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants