Skip to content

[Small Rock] Build reusable health UI states and components (#158) - #234

Open
Moon-dg wants to merge 5 commits into
oss-slu:mainfrom
Moon-dg:feature-158-ui-components
Open

Moon-dg wants to merge 5 commits into
oss-slu:mainfrom
Moon-dg:feature-158-ui-components

Conversation

@Moon-dg

@Moon-dg Moon-dg commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Built reusable, accessible health UI components (HealthBadge, HealthMetricCard, and HealthStateView) incorporating semantic health status tokens.
  • Added comprehensive unit tests in Vitest ensuring keyboard accessibility, ARIA role compliance, and reliable state handling.

Changes Made

  • Added frontend/src/components/HealthBadge.jsx:
    • Reusable status badge with semantic health status color tokens (good, warning, critical, neutral).
  • Added frontend/src/components/HealthMetricCard.jsx:
    • Metric display card supporting titles, values, units, status badges, and accessible keyboard activation (Enter/Space).
  • Added frontend/src/components/HealthStateView.jsx:
    • Unified view component handling loading indicators, empty states, and error alerts with retry callbacks.
  • Added frontend/src/components/HealthUIComponents.test.jsx:
    • Dedicated unit tests validating rendering, styling classes, keyboard interactions, and action triggers.

Testing Details

  • Ran automated test suite via Vitest (npm run test:run), successfully passing all 9 test suites and 113 tests with zero regressions.
  • Ran linter (npm run lint), passing with zero warnings or errors.

Checklist

  • Components have consistent spacing and semantics.
  • Components support keyboard and screen-reader use.
  • Components have focused tests or usage coverage.
  • Components work across supported languages.

Closes #158

@mudabs mudabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, Moon, for building these reusable health UI components and adding focused tests.

Please address the following before approval:

  1. Reuse the existing semantic status helper at frontend/src/utils/healthStatusClasses.js instead of duplicating raw Tailwind color mappings in HealthBadge.jsx.

  2. Fix HealthMetricCard.jsx accessibility. The current aria-label={title} hides the metric value, unit, status, and description from screen readers. Remove it or provide proper aria-labelledby and aria-describedby relationships so the complete metric is announced.

  3. Improve HealthStateView.jsx semantics:

    • Give the region an accessible name linked to its title.
    • Use an assertive alert treatment for error states.
    • Make the loading indicator label configurable instead of hard-coding Loading content.
  4. Add tests for:

    • Space key activation in addition to Enter.
    • Accessible metric value, unit, status, and description.
    • Loading, empty, and error announcements.
    • Unknown status fallback.
    • Localized loading text in at least English and Arabic.
  5. Confirm whether these components are intended to remain unused until a later PR. If they are part of the current UI work, integrate at least one into an existing health route.

Please run and pass:

  • npm run lint
  • npm run test:run
  • npm run build

Then push the updates and confirm that GitHub Actions checks pass.

@Moon-dg

Moon-dg commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

I have resolved all requested feedback and resolved the branch conflict with upstream main:

  1. Semantic Status Helper: Reused the shared semantic status helper and exports in frontend/src/utils/healthStatusClasses.js instead of duplicating raw Tailwind color mappings.
  2. Accessible Metric Cards: Removed the masking aria-label from HealthMetricCard.jsx and connected explicit aria-labelledby and aria-describedby IDs to ensure metric value, unit, status badge, and description are fully announced.
  3. Accessible State Views: Added aria-labelledby linking the region to the title, configured assertive alert handling (role="alert" and aria-live="assertive") for error states, and made the loading label configurable via loadingLabel.
  4. Comprehensive Unit Tests: Enhanced HealthUIComponents.test.jsx covering Space key activation, full metric detail exposure in accessibility tree, assertive alert/live announcements, unknown status fallback, and localized loading text in English and Arabic.
  5. Quality Verification: Verified that npm run lint, npm run test:run, and npm run build all pass cleanly with zero warnings/errors locally.

@mudabs mudabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you Moon for addressing the semantic status helper, accessibility relationships, configurable loading labels, assertive error states, and expanded tests.

Please address these items before merge:

  • Fix the failing critical-status test in frontend/src/components/HealthUIComponents.test.jsx. It expects a rose class, but the shared helper correctly returns border-health-critical bg-health-critical/10 text-red-950. Update the assertion to validate the shared semantic classes.
  • Integrate at least one reusable component into an existing health route, or clearly document that this is a foundation-only PR and link the follow-up integration work. The new components are currently used only by their tests.
  • Re-run npm run lint, npm run test:run, and npm run build, then confirm Node 20, Node 22, and Build all pass.

@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

@Moon-dg

Moon-dg commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

I have updated the PR to address your latest review feedback:

  1. Updated Critical-Status Test Assertion:

    • Fixed the failing assertion in HealthUIComponents.test.jsx to validate the shared semantic tokens (border-health-critical, bg-health-critical/10, text-red-950) from healthStatusClasses.js instead of the raw rose classes.
  2. Scope & Integration:

    • As scoped under #158, this PR establishes the core reusable UI foundation and test suite (HealthBadge, HealthMetricCard, and HealthStateView).
    • The integration of these components into the actual health route views will follow immediately in a dedicated subsequent PR.
  3. Local Quality Verification:

    • Ran npm run lint, npm run test:run, and npm run build locally—all passed cleanly with zero errors/warnings.

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.

[Small Rock] Build reusable health UI states and components

2 participants