-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Port ExportProject to use redux-toolkit; Remove redux from CreateProject #2747
Conversation
Codecov ReportAttention:
... and 2 files with indirect coverage changes 📢 Thoughts on this report? Let us know!. |
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.
Reviewed 4 of 11 files at r1, 11 of 11 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @imnasnainaec)
src/components/ProjectExport/Redux/ExportProjectActions.ts
line 21 at r2 (raw file):
export function downloading(projectId: string): PayloadAction { return downloadingAction(projectId); }
Since these names are inherited I am fine with leaving them but exporting
and downloading
do not sound like actions - they describe the current status of the project. Better names might be exportProject
and downloadProject
. Your call - you work with these more than I.
Suggestion:
export function exporting(projectId: string): PayloadAction {
return exportingAction(projectId);
}
export function downloading(projectId: string): PayloadAction {
return downloadingAction(projectId);
}`
src/components/ProjectExport/Redux/tests/ExportProjectActions.test.tsx
line 1 at r2 (raw file):
import configureMockStore from "redux-mock-store";
I think a better test is to use the actual redux store and verify that the state changes. This verifies that the correct action is dispatched by the dispatch methods but if you use the actual store, you can also test the action and reducer code at the same time.
You can use setupStore()
from store
to create the redux store. Since you don't need to have preset values (none of the reducers depend on the current state) you won't need to create a preloaded state. Even that is not difficult - you can see an example in src/goals/MergeDuplicates/Redux/tests/MergeDupsReducer.test.tsx
.
Code quote:
import configureMockStore from "redux-mock-store";
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.
Reviewable status: 13 of 15 files reviewed, all discussions resolved (waiting on @jmgrady)
src/components/ProjectExport/Redux/ExportProjectActions.ts
line 21 at r2 (raw file):
Previously, jmgrady (Jim Grady) wrote…
Since these names are inherited I am fine with leaving them but
exporting
anddownloading
do not sound like actions - they describe the current status of the project. Better names might beexportProject
anddownloadProject
. Your call - you work with these more than I.
The action is only to update the status to "exporting" or "downloading".
src/components/ProjectExport/Redux/tests/ExportProjectActions.test.tsx
line 1 at r2 (raw file):
Previously, jmgrady (Jim Grady) wrote…
I think a better test is to use the actual redux store and verify that the state changes. This verifies that the correct action is dispatched by the dispatch methods but if you use the actual store, you can also test the action and reducer code at the same time.
You can use
setupStore()
fromstore
to create the redux store. Since you don't need to have preset values (none of the reducers depend on the current state) you won't need to create a preloaded state. Even that is not difficult - you can see an example insrc/goals/MergeDuplicates/Redux/tests/MergeDupsReducer.test.tsx
.
Good idea. Done.
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.
Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @imnasnainaec)
src/components/ProjectExport/Redux/tests/ExportProjectActions.test.tsx
line 33 at r3 (raw file):
const mockStore = setupStore(); mockDownloadList.mockResolvedValueOnce({}); await mockStore.dispatch<any>(asyncDownloadExport(mockProjId));
Since you are using a store with the actual type, you don't need to use <any>
with the dispatch
functions, i.e. can be changed to:
await mockStore.dispatch(asyncDownloadExport(mockProjId));
(and probably should be).
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.
Reviewable status: 14 of 15 files reviewed, 1 unresolved discussion (waiting on @jmgrady)
src/components/ProjectExport/Redux/tests/ExportProjectActions.test.tsx
line 33 at r3 (raw file):
Previously, jmgrady (Jim Grady) wrote…
Since you are using a store with the actual type, you don't need to use
<any>
with thedispatch
functions, i.e. can be changed to:await mockStore.dispatch(asyncDownloadExport(mockProjId));
(and probably should be).
Done.
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.
Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @imnasnainaec)
Parts of #1953
This change is