Skip to content

fix: improve usage tests by mocking localStorage and enhancing cleanup#995

Open
sachinkmrsin wants to merge 3 commits intostagefrom
fix/broken-usage-test
Open

fix: improve usage tests by mocking localStorage and enhancing cleanup#995
sachinkmrsin wants to merge 3 commits intostagefrom
fix/broken-usage-test

Conversation

@sachinkmrsin
Copy link
Copy Markdown
Member

@sachinkmrsin sachinkmrsin commented Apr 10, 2026

Description

This PR hotfixes the issues in usage tests in ui.

What type of PR is this? (Check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📄 Documentation Update
  • 👨‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🛠️ CI/CD

Screenshots (if applicable)

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copilot AI review requested due to automatic review settings April 10, 2026 16:58
@github-actions
Copy link
Copy Markdown

No linked issues found. Please add the corresponding issues in the pull request description.
Use GitHub automation to close the issue when a PR is merged

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the UI Usage component tests to be more reliable by explicitly mocking localStorage and improving per-test cleanup to avoid state leakage between test cases.

Changes:

  • Add a dedicated localStorage mock (backed by an in-memory store) and stub it globally for the test file.
  • Adjust beforeEach cleanup to reset the mocked localStorage state and toast mocks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/ui/__tests__/components/Usage.test.jsx
Comment thread packages/ui/__tests__/components/Usage.test.jsx Outdated
@sonarqubecloud
Copy link
Copy Markdown

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