Skip to content

updating the publicqueue page and src/pages/admin test coverage to get full coverage

Suma Pullaiahgari requested to merge tests/coverage_enhancements into develop

Overview

This MR improves test coverage for all components under src/pages/admin& public queue page , achieving 100% statement and line coverage with near-complete branch coverage.

What does this MR do and why?

This MR ensures comprehensive test coverage for:

  • Admin pages (src/pages/admin)
  • Public-facing queue functionality (PublicQueuePage)

Motivation:

  • Eliminate untested logic paths
  • Improve reliability of critical admin and queue workflows
  • Strengthen confidence in UI behavior under edge cases

Approach:

  • Added targeted unit tests for uncovered branches
  • Covered UI states, API errors, and edge cases
  • Included real-time queue scenarios (connection, reconnection, empty states)

Trade-offs:

  • Some branch coverage limitations remain due to React Query internal states and optional chaining behavior

Changes Made

Test Files Updated

  • tests/admin/AssignRolesPage.test.tsx (+18 tests)
  • tests/admin/ManageMedicalCampsPage.test.tsx (+9 tests)
  • tests/admin/ManageMedicinesPage.test.tsx (+10 tests)
  • tests/pages/PublicQueuePage.test.tsx (+36 tests)

Coverage Improvements

  • Achieved 100% coverage for all admin pages
  • Significantly enhanced coverage for PublicQueuePage, including real-time and UI state scenarios

Technical Details

Technical Details

Admin Pages:

  • Covered edge cases like null/undefined values
  • Tested optimistic updates and mutation states
  • Improved branch coverage for filters and conditional rendering

PublicQueuePage:

  • Tested connection status indicators and reconnect logic
  • Covered empty queue and patient count states
  • Verified emergency priority badges
  • Handled navigation and error states

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • 🎨 UI/UX improvement
  • ️ Refactor (no functional changes)
  • Performance improvement
  • 🧪 Test update
  • 🔧 Configuration change
  • 🚨 Security fix

Related Issues / References

Link to related issues using GitLab syntax:

Screenshots or Screen Recordings

Before After
image image

How to Set Up and Validate Locally

  1. Pull this branch / checkout MR
  2. Install dependencies (if any changed):
    bun install
  3. Update environment variables (if needed):
    # .env
    VITE_SERVER_URL=http://localhost:8000
  4. Run development server:
    bun dev
  5. Navigate to specific pages or perform actions:
    • Visit http://localhost:5173/some-route
    • Click on X button
    • Fill form with Y data
  6. Expected behavior: ...

For backend-dependent features, mention if backend changes are needed. -->

Testing Done

Test Cases Covered:

Test Cases Covered

| Scenario | Expected Result | Status |

|----------|---------------|--------|

| Queue connection states | Correct indicator shown | |

| Reconnect flow | Successfully retries connection | |

| Empty queue | UI fallback displayed | |

| Patient count pluralization | Correct text shown | |

| Emergency priority | Badge displayed correctly | |

Code Quality Checklist

Code Standards

  • Code follows project conventions (naming, structure, formatting)
  • No console.log() or debugger statements left in code
  • No unused imports, variables, or functions
  • No duplicate code and use of existing components for reusability
  • i18n check passed with no hardcoded strings in codebase for i18n support
  • TypeScript types are properly defined (no any unless justified)
  • ESLint and Prettier checks pass
    bun run lint

React Best Practices

  • Components are properly split and single-responsibility
  • Hooks follow rules (no conditional hooks, proper dependencies)
  • State management is appropriate (local vs global state)
  • No unnecessary re-renders (memoization used where needed)
  • Event handlers are properly cleaned up

Component Patterns

  • shadcn/ui components used correctly
  • Tailwind classes follow utility-first approach
  • Responsive design considered (mobile-first if applicable)
  • Accessibility attributes included (aria-*, role, etc.)
  • Icons from lucide-react used consistently

API & Data Fetching

  • TanStack Query used for server state (if applicable)
  • Loading and error states handled
  • API types defined in src/types/api.ts
  • Axios interceptors handle auth tokens correctly
  • Use of Zod for data validations

Error Handling

  • Errors are caught and handled gracefully
  • User-friendly error messages displayed
  • Errors are being toasted properly
  • Network failures handled appropriately

Documentation

  • README.md updated (if setup steps changed)
  • .env.example updated (if new env vars added)
  • CHANGELOG.md updated (if applicable)

Known Limitations / Technical Debt

Known Limitations / Technical Debt

  • AssignRolesPage branch coverage is ~88.46% due to:
    • React Query internal state timing (isPending)
    • Optional chaining (oldUsers?.map()) not being triggerable in tests
  • This is a coverage tooling limitation, not a functional gap

Additional Notes

  • This is a test-only MR — no production code has been modified.
  • Focus is on improving coverage, reliability, and edge-case handling across admin pages and PublicQueuePage.
  • PublicQueuePage received significant test additions, especially for real-time UI states (connection, reconnection, empty states).
  • Some branch coverage (AssignRolesPage ~88%) is limited by:
    • React Query internal state timing (isPending)
    • Optional chaining paths that are not realistically triggerable
  • No impact on performance, runtime behavior, or API contracts.

##Notes:

  • Suggested review approach:
    1. Validate edge-case coverage (null, error states, UI states)
    2. Verify test readability and maintainability
    3. Spot-check critical flows (mutations, filters, queue behavior)
Edited by Suma Pullaiahgari

Merge request reports

Loading