Skip to content

test: add component tests for DashboardLayout, DataTable, Combobox, MilestoneTimeline, ShipmentSummaryPrint - #1

Open
Raven062 wants to merge 1 commit into
mainfrom
feat/739-740-741-add-component-tests
Open

test: add component tests for DashboardLayout, DataTable, Combobox, MilestoneTimeline, ShipmentSummaryPrint#1
Raven062 wants to merge 1 commit into
mainfrom
feat/739-740-741-add-component-tests

Conversation

@Raven062

Copy link
Copy Markdown
Owner

Summary

Closes issues Navin-xmr#739, Navin-xmr#740, Navin-xmr#741

Adds component tests with zero previous coverage for five components:

Component Test File Issue
DashboardLayout.tsx src/components/layout/DashboardLayout.test.tsx Navin-xmr#739
DataTable.tsx (common) src/components/common/DataTable/DataTable.test.tsx Navin-xmr#740
Combobox.tsx src/components/ui/Combobox.test.tsx Navin-xmr#740
MilestoneTimeline.tsx src/components/shipment/MilestoneTimeline/MilestoneTimeline.test.tsx Navin-xmr#741
ShipmentSummaryPrint.tsx src/components/shipment/ShipmentSummaryPrint/ShipmentSummaryPrint.test.tsx Navin-xmr#741

What's covered

DashboardLayout — initial render, nav items, Outlet rendering, active route highlighting, sidebar collapse/expand, nav group accordion, favorites (add/remove/persist/restore from localStorage), mobile sidebar dialog (role=dialog, aria-modal), keyboard shortcuts modal, enterprise node status widget.

DataTable — column headers, data rows, loading skeleton, empty state with CTA, sorting (asc/desc/reset, numeric, non-sortable columns), row click callback, pagination (page buttons, aria-current, prev/next disabled states, item range summary).

Combobox — initial render, controlled value, opening dropdown, filtering (case-insensitive), option selection (onChange + onSelectOption), keyboard navigation (ArrowDown/Up/Enter/Escape), clear button, loading state, disabled state, outside click.

MilestoneTimeline — render, filter pills (All/Completed/In Progress/Upcoming), empty state after filtering, clear filter, zoom controls (in/out/disabled at limits/reset), expandable milestone details (notes, sensor readings), blockchain link for completed milestones.

ShipmentSummaryPrint — portal rendering, all metadata fields (id, status, sender, receiver, tracking, carrier, priority, dates), milestone table, cost breakdown, payment info, sensor snapshot, notes, delivery proof, Stellar TX hash, print+close lifecycle (window.print called after 200 ms delay, onClose fired once).

Testing approach

  • Vitest + React Testing Library, matching the project's established patterns
  • Behavior-focused assertions (what the user sees/can do), not implementation details
  • Heavy dependencies (realtimeService, ToastContext, WalletContext, useTheme, authApi) mocked at the module level
  • window.print and HTMLElement.prototype.scrollIntoView stubbed for jsdom compatibility

What was tested

pnpm run test run locally; all five new test files pass.

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.

1 participant