Summary
The project currently has 14 test files covering 96 tests, but only 14.4% of testable files have any test coverage. Major gaps exist across server routes (0%), components (9%), and services (25%). This issue tracks the work needed to bring test coverage up to a reasonable baseline across all layers.
Current State
| Category |
Tested |
Untested |
Coverage |
| Server Routes |
0 |
9 |
0% |
| Frontend Services |
4 |
12 |
25% |
| Components |
5 |
50 |
9% |
| Utilities |
1 |
2 |
33% |
| Contexts |
2 |
1 |
67% |
| Types |
2 |
9 |
18% |
Existing Tests (14 files, 96 tests)
src/types/Item.test.ts (6), src/types/User.test.ts (5)
src/services/itemService.test.ts (14), src/services/userService.test.ts (6), src/services/authService.test.ts (3), src/services/storage.test.ts (6)
src/utils/export.test.ts (11)
src/contexts/AlertContext.test.tsx (9), src/contexts/ThemeContext.test.tsx (6)
src/components/common/Pagination.test.tsx (13), src/components/common/ConfirmModal.test.tsx (7), src/components/common/AlertDisplay.test.tsx (4), src/components/auth/ProtectedRoute.test.tsx (4), src/components/layout/Footer.test.tsx (2)
Missing Tests
Priority 1: Server Route Tests (0/9 covered)
These are the most critical gap — no API endpoint testing exists.
server/routes/items.ts — CRUD, children endpoint, bulk delete, reorder/low-stock queries
server/routes/auth.ts — Login, register, verify email, profile update, token generation
server/routes/inventoryTypes.ts — CRUD with schema validation, item dependency check before delete
server/routes/categories.ts — CRUD with type filtering, reorder by sortOrder
server/routes/stockHistory.ts — Filtered history queries, pagination
server/routes/costHistory.ts — Cost stats with trend analysis (up/down/stable)
server/routes/boms.ts — BOM CRUD with item arrays and cost calculations
server/routes/templates.ts — Template CRUD with defaultFields JSON
server/routes/users.ts — User management, role changes, password stripping
Priority 2: Untested Frontend Services (12 files)
src/services/api.ts — Core fetch wrapper, ApiError class, error handling
src/services/inventoryTypeService.ts — Type CRUD, schema validation, PRESET_TYPES
src/services/categoryService.ts — Category CRUD, filtering by type
src/services/bomService.ts — BOM CRUD, cost breakdown calculation
src/services/costHistoryService.ts — Cost history retrieval, stats
src/services/stockHistoryService.ts — Stock history with date/type filters
src/services/itemTemplateService.ts — Template CRUD, apply template
src/services/vendorService.ts — Mock vendor price lookup with 15-min cache
Priority 3: Untested Utilities & Contexts
src/utils/formatters.ts — formatCurrency, formatDate, formatDateTime, formatBytes, percentageChange
src/utils/imageOptimizer.ts — Image compression with configurable quality/dimensions
src/contexts/AuthContext.tsx — Auth state, login/logout/register flows, role management
Priority 4: Key Component Tests (highest-value 15 of 50 untested)
src/components/items/ItemList.tsx — Sorting, filtering, pagination, bulk actions, low stock
src/components/items/ItemDetail.tsx — Detail display, parent/child, vendor prices, delete
src/components/items/ItemForm.tsx — Create/edit form, custom fields, parent selection, validation
src/components/items/CustomFieldRenderer.tsx — Schema-driven field rendering (text/number/select/date/boolean)
src/components/items/ParentItemSelector.tsx — Parent dropdown, circular reference prevention
src/components/items/ChildItemsList.tsx — Child items table, type badges
src/components/items/ItemFilters.tsx — Search, category, type filter controls
src/components/items/BulkActions.tsx — Bulk delete/category change actions
src/components/common/LowStockAlert.tsx — Alert with type-filtered stock counts
src/components/common/EmptyState.tsx — Empty state rendering
src/components/reports/Dashboard.tsx — Stats cards, charts, recent activity
src/components/settings/InventoryTypeManager.tsx — Type CRUD, export buttons
src/components/settings/CategoryManager.tsx — Category CRUD, drag reorder
src/components/bom/BOMList.tsx — BOM table, cost breakdown
src/components/auth/Login.tsx — Login form, error handling
Acceptance Criteria
Additional Context
This should be broken into multiple PRs by priority tier to keep reviews manageable. Each PR should target one tier or a logical subset of files.
Summary
The project currently has 14 test files covering 96 tests, but only 14.4% of testable files have any test coverage. Major gaps exist across server routes (0%), components (9%), and services (25%). This issue tracks the work needed to bring test coverage up to a reasonable baseline across all layers.
Current State
Existing Tests (14 files, 96 tests)
src/types/Item.test.ts(6),src/types/User.test.ts(5)src/services/itemService.test.ts(14),src/services/userService.test.ts(6),src/services/authService.test.ts(3),src/services/storage.test.ts(6)src/utils/export.test.ts(11)src/contexts/AlertContext.test.tsx(9),src/contexts/ThemeContext.test.tsx(6)src/components/common/Pagination.test.tsx(13),src/components/common/ConfirmModal.test.tsx(7),src/components/common/AlertDisplay.test.tsx(4),src/components/auth/ProtectedRoute.test.tsx(4),src/components/layout/Footer.test.tsx(2)Missing Tests
Priority 1: Server Route Tests (0/9 covered)
These are the most critical gap — no API endpoint testing exists.
server/routes/items.ts— CRUD, children endpoint, bulk delete, reorder/low-stock queriesserver/routes/auth.ts— Login, register, verify email, profile update, token generationserver/routes/inventoryTypes.ts— CRUD with schema validation, item dependency check before deleteserver/routes/categories.ts— CRUD with type filtering, reorder by sortOrderserver/routes/stockHistory.ts— Filtered history queries, paginationserver/routes/costHistory.ts— Cost stats with trend analysis (up/down/stable)server/routes/boms.ts— BOM CRUD with item arrays and cost calculationsserver/routes/templates.ts— Template CRUD with defaultFields JSONserver/routes/users.ts— User management, role changes, password strippingPriority 2: Untested Frontend Services (12 files)
src/services/api.ts— Core fetch wrapper, ApiError class, error handlingsrc/services/inventoryTypeService.ts— Type CRUD, schema validation, PRESET_TYPESsrc/services/categoryService.ts— Category CRUD, filtering by typesrc/services/bomService.ts— BOM CRUD, cost breakdown calculationsrc/services/costHistoryService.ts— Cost history retrieval, statssrc/services/stockHistoryService.ts— Stock history with date/type filterssrc/services/itemTemplateService.ts— Template CRUD, apply templatesrc/services/vendorService.ts— Mock vendor price lookup with 15-min cachePriority 3: Untested Utilities & Contexts
src/utils/formatters.ts— formatCurrency, formatDate, formatDateTime, formatBytes, percentageChangesrc/utils/imageOptimizer.ts— Image compression with configurable quality/dimensionssrc/contexts/AuthContext.tsx— Auth state, login/logout/register flows, role managementPriority 4: Key Component Tests (highest-value 15 of 50 untested)
src/components/items/ItemList.tsx— Sorting, filtering, pagination, bulk actions, low stocksrc/components/items/ItemDetail.tsx— Detail display, parent/child, vendor prices, deletesrc/components/items/ItemForm.tsx— Create/edit form, custom fields, parent selection, validationsrc/components/items/CustomFieldRenderer.tsx— Schema-driven field rendering (text/number/select/date/boolean)src/components/items/ParentItemSelector.tsx— Parent dropdown, circular reference preventionsrc/components/items/ChildItemsList.tsx— Child items table, type badgessrc/components/items/ItemFilters.tsx— Search, category, type filter controlssrc/components/items/BulkActions.tsx— Bulk delete/category change actionssrc/components/common/LowStockAlert.tsx— Alert with type-filtered stock countssrc/components/common/EmptyState.tsx— Empty state renderingsrc/components/reports/Dashboard.tsx— Stats cards, charts, recent activitysrc/components/settings/InventoryTypeManager.tsx— Type CRUD, export buttonssrc/components/settings/CategoryManager.tsx— Category CRUD, drag reordersrc/components/bom/BOMList.tsx— BOM table, cost breakdownsrc/components/auth/Login.tsx— Login form, error handlingAcceptance Criteria
formatters.tsandimageOptimizer.tsAdditional Context
This should be broken into multiple PRs by priority tier to keep reviews manageable. Each PR should target one tier or a logical subset of files.