Improve SaveButton Redux tests with modern store patterns#1392
Draft
zetter-rpf wants to merge 6 commits intomainfrom
Draft
Improve SaveButton Redux tests with modern store patterns#1392zetter-rpf wants to merge 6 commits intomainfrom
zetter-rpf wants to merge 6 commits intomainfrom
Conversation
Extract a shared render helper for the mock Redux store and Provider wiring. This removes repetitive setup from each test case so scenarios focus on state differences instead of store plumbing, which aligns with Redux testing guidance to keep tests maintainable. Co-authored-by: Chris Zetter <zetter-rpf@users.noreply.github.com>
Replace redux-mock-store with configureStore + root reducer so tests exercise real reducer behavior, matching Redux's recommended integration testing pattern. Assertions now verify observable store state changes instead of mocked dispatched-action arrays, which reduces false confidence and avoids mock-store deprecation warnings. Co-authored-by: Chris Zetter <zetter-rpf@users.noreply.github.com>
Create a reusable Redux-aware render helper so component tests can share one Provider/store setup pattern. Updating SaveButton to use this keeps Redux test wiring consistent with the recommended real-store approach while reducing per-test boilerplate and making future migrations easier. Co-authored-by: Chris Zetter <zetter-rpf@users.noreply.github.com>
Remove the local renderSaveButton wrapper and call renderWithProviders directly in each setup block. This keeps the test aligned to the shared utility API, avoids an extra indirection layer, and makes the common pattern easier to copy into other Redux-connected tests. Co-authored-by: Chris Zetter <zetter-rpf@users.noreply.github.com>
Use preloadedState naming and object shorthand when calling renderWithProviders. This matches Redux Toolkit terminology and removes repetitive key:value syntax, making each setup block clearer and more consistent. Co-authored-by: Chris Zetter <zetter-rpf@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
Remove unused store bindings in scenarios that only verify rendered button classes. This resolves no-unused-vars warnings from yarn lint and keeps the setup focused on the behavior each test actually asserts. Co-authored-by: Chris Zetter <zetter-rpf@users.noreply.github.com>
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.
Summary
SaveButton.test.jsand align it with a shared test utilitySaveButton.test.jsfromredux-mock-storeto a real Redux ToolkitconfigureStoreinstance usingrootReducereditor.saveTriggered)renderWithProvidersutility insrc/utils/renderWithProviders.jsrenderSaveButtonwrapper and callrenderWithProvidersdirectly in setup blocksinitialStatetopreloadedStateand use object shorthandstorebindings in setup blocks that only assert rendered class namesWhy this is an improvement
preloadedState) for clearer intentTesting
CI=true yarn test --runInBand --runTestsByPath src/components/SaveButton/SaveButton.test.jsyarn lint