Skip to content

refactor(frontend): Refactor tests to use Zustand's native state setting instead of vi.mock for stores#11980

Merged
amanape merged 5 commits intoOpenHands:mainfrom
KyeongJooni:refactor/remove-zustand-mocks
Dec 11, 2025
Merged

refactor(frontend): Refactor tests to use Zustand's native state setting instead of vi.mock for stores#11980
amanape merged 5 commits intoOpenHands:mainfrom
KyeongJooni:refactor/remove-zustand-mocks

Conversation

@KyeongJooni
Copy link
Copy Markdown
Contributor

@KyeongJooni KyeongJooni commented Dec 10, 2025

Summary of PR

Removed unnecessary vi.mock usage in Zustand store tests and switched to using store.setState() directly, since the project already includes an auto-reset mock in mocks/zustand.ts.

Files changed:

  • browser.test.tsx - removed vi.mock for browser-store
  • interactive-chat-box.test.tsx - removed vi.mock for conversation-store
  • chat-interface.test.tsx - removed vi.mock for error-message-store and optimistic-user-message-store
  • actions.test.tsx - removed vi.mock for command-store

Change Type

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Other (dependency update, docs, typo fixes, etc.)

Checklist

  • I have read and reviewed the code and I understand what the code is doing.
  • I have tested the code to the best of my ability and ensured it works as expected.

Fixes

Resolves #11951

Release Notes

  • Include this change in the Release Notes.

- Replace vi.mock with store.setState() in browser.test.tsx
- Replace vi.mock with store.setState() in interactive-chat-box.test.tsx
- Replace vi.mock with store.setState() in chat-interface.test.tsx
- Replace vi.mock with store.setState() in actions.test.tsx
- Use real store instances instead of mock objects
@KyeongJooni KyeongJooni requested a review from amanape as a code owner December 10, 2025 00:47
@KyeongJooni KyeongJooni changed the title refactor(frontend): remove unnecessary vi.mock for Zustand stores refactor(frontend): Refactor tests to use Zustand's native state setting instead of vi.mock for stores Dec 11, 2025
Copy link
Copy Markdown
Contributor

@amanape amanape left a comment

Choose a reason for hiding this comment

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

Thank you for this pull request and for promoting good practices in our codebase!

I also took the opportunity to remove two outdated slice mocks from stores that have since been eliminated.

@amanape amanape enabled auto-merge (squash) December 11, 2025 14:28
@amanape amanape self-assigned this Dec 11, 2025
@amanape amanape merged commit b16845f into OpenHands:main Dec 11, 2025
24 checks passed
abhayymishraa pushed a commit to abhayymishraa/OpenHands that referenced this pull request Dec 14, 2025
…ing instead of vi.mock for stores (OpenHands#11980)

Co-authored-by: amanape <83104063+amanape@users.noreply.github.com>
afanty2021 pushed a commit to afanty2021/OpenHands that referenced this pull request Dec 17, 2025
…ing instead of vi.mock for stores (OpenHands#11980)

Co-authored-by: amanape <83104063+amanape@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.

Refactor tests to use Zustand's native state setting instead of vi.mock for stores

2 participants