Skip to content

Improve SaveButton Redux tests with modern store patterns#1392

Draft
zetter-rpf wants to merge 6 commits intomainfrom
cursor/redux-test-patterns-530b
Draft

Improve SaveButton Redux tests with modern store patterns#1392
zetter-rpf wants to merge 6 commits intomainfrom
cursor/redux-test-patterns-530b

Conversation

@zetter-rpf
Copy link
Contributor

@zetter-rpf zetter-rpf commented Mar 18, 2026

Summary

  • reduce repeated setup in SaveButton.test.js and align it with a shared test utility
  • migrate SaveButton.test.js from redux-mock-store to a real Redux Toolkit configureStore instance using rootReducer
  • replace dispatched-action-list assertions with reducer outcome assertions (editor.saveTriggered)
  • add reusable renderWithProviders utility in src/utils/renderWithProviders.js
  • remove local renderSaveButton wrapper and call renderWithProviders directly in setup blocks
  • rename local fixture objects from initialState to preloadedState and use object shorthand
  • fix lint warnings by removing unused store bindings in setup blocks that only assert rendered class names

Why this is an improvement

  • follows Redux’s recommended integration-style testing with a real store
  • verifies observable state outcomes instead of mock action internals
  • reduces Redux test boilerplate and standardizes setup around one shared helper API
  • uses Redux Toolkit terminology (preloadedState) for clearer intent
  • keeps lint output clean and avoids warning noise in CI and local runs

Testing

  • CI=true yarn test --runInBand --runTestsByPath src/components/SaveButton/SaveButton.test.js
  • yarn lint
Open in Web Open in Cursor 

cursoragent and others added 5 commits March 18, 2026 11:19
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>
@zetter-rpf zetter-rpf temporarily deployed to previews/1392/merge March 18, 2026 11:49 — with GitHub Actions Inactive
@cursor
Copy link

cursor bot commented Mar 18, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

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>
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