Skip to content

Fix/add unit testing coverage#4032

Open
pigchip wants to merge 4 commits intodevfrom
fix/add-unit-testing-coverage
Open

Fix/add unit testing coverage#4032
pigchip wants to merge 4 commits intodevfrom
fix/add-unit-testing-coverage

Conversation

@pigchip
Copy link
Copy Markdown

@pigchip pigchip commented Apr 28, 2026

Overview

This PR significantly expands the unit test suite for Microsoft Graph Explorer, increasing coverage to ~95% with ~1,900 tests across all major modules.

Screenshot 2026-04-28 171001

What it does:

  • Adds src/test-utils.tsx with renderWithProviders and createMockStore helpers to simplify Redux-connected component testing
  • Adds 166 new spec files covering utilities, Redux slices, action creators, React components, authentication, suggestions, cache, and UI views
  • Updates jest.config.js with coverage collection configuration and exclusions
  • Adds @testing-library/jest-dom and @testing-library/react as dev dependencies

Why it's needed: The codebase lacked sufficient unit test coverage, making it risky to refactor or add features confidently. This PR establishes a strong testing
baseline that catches regressions early and improves long-term maintainability.

Notes

Implemented with: https://vigilant-adventure-v9qpqwn.pages.github.io/playground/#plugins/test-sentinel?q=test-sentinel

Testing Instructions

  • Check out the branch: git checkout fix/add-unit-testing-coverage
  • Install dependencies: npm install
  • Run the unit test suite: npm test

Expected: All ~1,900 tests pass with no failures

  • Run with coverage report: npm test -- --coverage

Expected: Coverage summary shows ~95% across statements, branches, functions, and lines. A coverage/ folder is generated with a detailed HTML report

aguzmancruz and others added 2 commits April 21, 2026 13:38
- Update jest.config.js with coverage collection exclusions
- Add test-utils.tsx with renderWithProviders and createMockStore helpers
- Add @testing-library/jest-dom and @testing-library/react dev dependencies

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- 197 test suites covering utilities, Redux slices, async thunks,
  middleware, React components, hooks, caches, and service modules
- Line coverage: 95.07% (5816/6117)
- Statement coverage: 95.03% (6063/6380)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pigchip pigchip requested a review from a team as a code owner April 28, 2026 23:16
@pigchip
Copy link
Copy Markdown
Author

pigchip commented Apr 28, 2026

@microsoft-github-policy-service agree company="Microsoft"

- Fix TS2344 in permissions-action-creator.util.spec.ts: cast
  InstanceType<typeof RevokePermissionsUtil> to unknown as RevokePermissionsUtil
- Fix TS2345/TS2739/TS2571/TS2322/TS2352/TS2556/TS2769 across spec files:
  cast sampleBody/payload as unknown as IQuery, add missing IPermissionGrant
  fields (clientId/resourceId), fix status literal types, cast result.payload
  as any, add missing PopupsComponent props, fix Provider overload
- Fix Auth test infinite useEffect loop: moved state object outside
  mockImplementation so authToken reference is stable across re-renders
- Fix 13 ESLint errors introduced by fixes: wrap long lines in
  permission-grants.slice.spec.ts and fix double-quotes + max-len in
  ShareQuery.spec.tsx
- Add @babel/plugin-proposal-private-property-in-object to devDependencies
  (suppress babel-preset-react-app warning)
- Centralize ResizeObserver mock in setupTests.ts
- Fix all 204 ESLint max-len/no-empty/quotes violations across ~60 spec files

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://calm-wave-0c4fb390f-4032.eastus2.4.azurestaticapps.net

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Azure Static Web Apps: Your stage site is ready! Visit it here: https://calm-wave-0c4fb390f-4032.eastus2.4.azurestaticapps.net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant