@omersx/bemms 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +203 -2
- package/drizzle.config.ts +11 -0
- package/next.config.ts +51 -0
- package/package.json +99 -3
- package/postcss.config.mjs +7 -0
- package/public/hospital_demo_devices.csv +32 -0
- package/public/icons/icon-192.png +0 -0
- package/public/icons/icon-512.png +0 -0
- package/public/icons/icon-maskable-512.png +0 -0
- package/public/manifest.webmanifest +31 -0
- package/public/sw.js +177 -0
- package/src/app/(auth)/layout.tsx +20 -0
- package/src/app/(auth)/login/page.tsx +135 -0
- package/src/app/(dashboard)/admin/audit-logs/page.tsx +178 -0
- package/src/app/(dashboard)/admin/data/page.tsx +37 -0
- package/src/app/(dashboard)/admin/departments/[deptId]/edit/page.tsx +206 -0
- package/src/app/(dashboard)/admin/departments/[deptId]/page.tsx +71 -0
- package/src/app/(dashboard)/admin/departments/new/page.tsx +6 -0
- package/src/app/(dashboard)/admin/departments/page.tsx +6 -0
- package/src/app/(dashboard)/admin/general/page.tsx +374 -0
- package/src/app/(dashboard)/admin/hospitals/[hospitalId]/edit/page.tsx +304 -0
- package/src/app/(dashboard)/admin/hospitals/[hospitalId]/page.tsx +94 -0
- package/src/app/(dashboard)/admin/hospitals/new/page.tsx +302 -0
- package/src/app/(dashboard)/admin/hospitals/page.tsx +6 -0
- package/src/app/(dashboard)/admin/layout.tsx +49 -0
- package/src/app/(dashboard)/admin/organizations/[orgId]/edit/page.tsx +172 -0
- package/src/app/(dashboard)/admin/organizations/[orgId]/page.tsx +82 -0
- package/src/app/(dashboard)/admin/organizations/new/page.tsx +150 -0
- package/src/app/(dashboard)/admin/organizations/page.tsx +6 -0
- package/src/app/(dashboard)/admin/page.tsx +258 -0
- package/src/app/(dashboard)/admin/roles/page.tsx +153 -0
- package/src/app/(dashboard)/admin/settings/page.tsx +69 -0
- package/src/app/(dashboard)/admin/users/[userId]/edit/page.tsx +153 -0
- package/src/app/(dashboard)/admin/users/[userId]/page.tsx +317 -0
- package/src/app/(dashboard)/admin/users/invite/page.tsx +3 -0
- package/src/app/(dashboard)/admin/users/new/page.tsx +5 -0
- package/src/app/(dashboard)/admin/users/page.tsx +23 -0
- package/src/app/(dashboard)/dashboard/page.tsx +462 -0
- package/src/app/(dashboard)/departments/[deptId]/page.tsx +39 -0
- package/src/app/(dashboard)/departments/new/page.tsx +330 -0
- package/src/app/(dashboard)/departments/page.tsx +52 -0
- package/src/app/(dashboard)/devices/[id]/edit/page.tsx +131 -0
- package/src/app/(dashboard)/devices/[id]/page.tsx +408 -0
- package/src/app/(dashboard)/devices/[id]/qr/page.tsx +54 -0
- package/src/app/(dashboard)/devices/new/page.tsx +382 -0
- package/src/app/(dashboard)/devices/page.tsx +80 -0
- package/src/app/(dashboard)/engineering-team/page.tsx +41 -0
- package/src/app/(dashboard)/layout.tsx +43 -0
- package/src/app/(dashboard)/maintenance/checklists/page.tsx +57 -0
- package/src/app/(dashboard)/maintenance/page.tsx +231 -0
- package/src/app/(dashboard)/maintenance/plans/page.tsx +142 -0
- package/src/app/(dashboard)/maintenance/tasks/[id]/page.tsx +997 -0
- package/src/app/(dashboard)/maintenance/tasks/page.tsx +119 -0
- package/src/app/(dashboard)/more/page.tsx +310 -0
- package/src/app/(dashboard)/my-department/page.tsx +151 -0
- package/src/app/(dashboard)/notifications/notification-list.tsx +103 -0
- package/src/app/(dashboard)/notifications/page.tsx +59 -0
- package/src/app/(dashboard)/profile/page.tsx +27 -0
- package/src/app/(dashboard)/reports/costs/page.tsx +127 -0
- package/src/app/(dashboard)/reports/history/page.tsx +105 -0
- package/src/app/(dashboard)/reports/inventory/page.tsx +116 -0
- package/src/app/(dashboard)/reports/maintenance/page.tsx +136 -0
- package/src/app/(dashboard)/reports/page.tsx +120 -0
- package/src/app/(dashboard)/reports/tickets/page.tsx +139 -0
- package/src/app/(dashboard)/reports/workload/page.tsx +135 -0
- package/src/app/(dashboard)/rounds/[id]/page.tsx +197 -0
- package/src/app/(dashboard)/rounds/history/page.tsx +82 -0
- package/src/app/(dashboard)/rounds/page.tsx +107 -0
- package/src/app/(dashboard)/scan/[code]/page.tsx +154 -0
- package/src/app/(dashboard)/scan/page.tsx +73 -0
- package/src/app/(dashboard)/team/page.tsx +42 -0
- package/src/app/(dashboard)/tickets/[id]/page.tsx +465 -0
- package/src/app/(dashboard)/tickets/create/page.tsx +722 -0
- package/src/app/(dashboard)/tickets/page.tsx +55 -0
- package/src/app/(dashboard)/tickets/triage/page.tsx +161 -0
- package/src/app/api/admin/data/export/route.ts +316 -0
- package/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/src/app/api/health/route.ts +46 -0
- package/src/app/api/notifications/sse/route.ts +91 -0
- package/src/app/api/notifications/subscribe/route.ts +54 -0
- package/src/app/api/notifications/vapid-key/route.ts +7 -0
- package/src/app/api/reports/export/route.ts +102 -0
- package/src/app/api/tickets/[id]/attachments/route.ts +129 -0
- package/src/app/api/tickets/[id]/live-sync/route.ts +52 -0
- package/src/app/error.tsx +54 -0
- package/src/app/globals.css +89 -0
- package/src/app/layout.tsx +59 -0
- package/src/app/not-found.tsx +32 -0
- package/src/app/page.tsx +5 -0
- package/src/components/admin/add-department-user-dialog.tsx +759 -0
- package/src/components/admin/add-engineer-dialog.tsx +773 -0
- package/src/components/admin/add-user-type-dialog.tsx +89 -0
- package/src/components/admin/audit-log-export.tsx +113 -0
- package/src/components/admin/audit-log-filters.tsx +255 -0
- package/src/components/admin/audit-log-table.tsx +383 -0
- package/src/components/admin/data-management/danger-zone.tsx +301 -0
- package/src/components/admin/data-management/data-management-tabs.tsx +61 -0
- package/src/components/admin/data-management/export-center.tsx +301 -0
- package/src/components/admin/data-management/import-wizard.tsx +558 -0
- package/src/components/admin/settings-forms/features-form.tsx +115 -0
- package/src/components/admin/settings-forms/health-panel.tsx +182 -0
- package/src/components/admin/settings-forms/localization-form.tsx +203 -0
- package/src/components/admin/settings-forms/retention-form.tsx +164 -0
- package/src/components/admin/settings-forms/security-form.tsx +186 -0
- package/src/components/admin/system-settings-tabs.tsx +88 -0
- package/src/components/admin/user-role-dialog.tsx +293 -0
- package/src/components/admin/user-status-dialog.tsx +166 -0
- package/src/components/admin/users-page-client.tsx +514 -0
- package/src/components/dashboard/action-buttons.tsx +93 -0
- package/src/components/dashboard/admin-alerts.tsx +86 -0
- package/src/components/dashboard/availability-alerts.tsx +65 -0
- package/src/components/dashboard/maintenance-due-list.tsx +87 -0
- package/src/components/dashboard/round-widget.tsx +110 -0
- package/src/components/dashboard/stat-card.tsx +38 -0
- package/src/components/dashboard/ticket-list-compact.tsx +86 -0
- package/src/components/departments/department-cards-view.tsx +244 -0
- package/src/components/departments/department-detail-view.tsx +467 -0
- package/src/components/departments/department-visuals.tsx +190 -0
- package/src/components/departments/my-department-view.tsx +333 -0
- package/src/components/devices/change-status-dialog.tsx +146 -0
- package/src/components/devices/device-action-buttons.tsx +125 -0
- package/src/components/devices/device-availability-banner.tsx +59 -0
- package/src/components/devices/device-badges.tsx +55 -0
- package/src/components/devices/device-documents-tab.tsx +93 -0
- package/src/components/devices/device-maintenance-tab.tsx +113 -0
- package/src/components/devices/device-mini-qr.tsx +109 -0
- package/src/components/devices/device-qr-card.tsx +187 -0
- package/src/components/devices/device-signatures-tab.tsx +607 -0
- package/src/components/devices/device-tickets-tab.tsx +139 -0
- package/src/components/devices/device-timelines.tsx +124 -0
- package/src/components/devices/qr-camera-scanner.tsx +167 -0
- package/src/components/devices/qr-code-display.tsx +139 -0
- package/src/components/devices/quick-add-category-dialog.tsx +135 -0
- package/src/components/devices/quick-add-manufacturer-dialog.tsx +212 -0
- package/src/components/devices/transfer-device-dialog.tsx +190 -0
- package/src/components/layout/header.tsx +80 -0
- package/src/components/layout/mobile-nav.tsx +91 -0
- package/src/components/layout/more-item-badge.tsx +15 -0
- package/src/components/layout/nav-badge.tsx +72 -0
- package/src/components/layout/sidebar.tsx +297 -0
- package/src/components/maintenance/maintenance-badges.tsx +579 -0
- package/src/components/maintenance/maintenance-nav.tsx +107 -0
- package/src/components/maintenance/parts-costs-manager.tsx +909 -0
- package/src/components/maintenance/signature-card.tsx +413 -0
- package/src/components/maintenance/task-action-bar.tsx +955 -0
- package/src/components/notifications/notification-bell.tsx +367 -0
- package/src/components/notifications/notification-item.tsx +93 -0
- package/src/components/notifications/notification-preferences.tsx +182 -0
- package/src/components/profile/user-profile-view.tsx +626 -0
- package/src/components/providers/nav-counts-provider.tsx +235 -0
- package/src/components/providers/session-provider.tsx +7 -0
- package/src/components/providers/theme-provider.tsx +124 -0
- package/src/components/pwa/install-prompt.tsx +82 -0
- package/src/components/pwa/sw-register.tsx +43 -0
- package/src/components/reports/export-button.tsx +62 -0
- package/src/components/reports/filter-chips.tsx +47 -0
- package/src/components/reports/summary-cards.tsx +40 -0
- package/src/components/reports/transparency-header.tsx +54 -0
- package/src/components/rounds/department-visit-sheet.tsx +199 -0
- package/src/components/rounds/mention-textarea.tsx +187 -0
- package/src/components/rounds/round-calendar.tsx +233 -0
- package/src/components/rounds/round-department-list.tsx +281 -0
- package/src/components/rounds/round-history-client.tsx +218 -0
- package/src/components/rounds/start-round-card.tsx +184 -0
- package/src/components/shared/confirm-dialog.tsx +67 -0
- package/src/components/shared/data-table.tsx +104 -0
- package/src/components/shared/page-header.tsx +20 -0
- package/src/components/shared/sign-out-button.tsx +52 -0
- package/src/components/shared/status-badge.tsx +42 -0
- package/src/components/shared/table-search.tsx +55 -0
- package/src/components/signatures/sign-action-dialog.tsx +253 -0
- package/src/components/signatures/signature-history.tsx +121 -0
- package/src/components/signatures/signature-status-panel.tsx +164 -0
- package/src/components/team/department-coverage.tsx +141 -0
- package/src/components/team/edit-engineer-dialog.tsx +242 -0
- package/src/components/team/engineer-card.tsx +180 -0
- package/src/components/team/engineer-details-dialog.tsx +432 -0
- package/src/components/team/schedule-calendar.tsx +204 -0
- package/src/components/team/staff-engineer-team-view.tsx +368 -0
- package/src/components/team/team-header-stats.tsx +88 -0
- package/src/components/team/team-page-client.tsx +216 -0
- package/src/components/theme/theme-selector-card.tsx +63 -0
- package/src/components/theme/theme-toggle.tsx +65 -0
- package/src/components/tickets/staff-status-label.tsx +58 -0
- package/src/components/tickets/staff-ticket-card.tsx +109 -0
- package/src/components/tickets/staff-ticket-progress-tracker.tsx +405 -0
- package/src/components/tickets/staff-tickets-view.tsx +182 -0
- package/src/components/tickets/ticket-action-buttons.tsx +873 -0
- package/src/components/tickets/ticket-auto-refresh.tsx +197 -0
- package/src/components/tickets/ticket-badges.tsx +43 -0
- package/src/components/tickets/ticket-card.tsx +197 -0
- package/src/components/tickets/ticket-cards-view.tsx +395 -0
- package/src/components/tickets/ticket-comment-section.tsx +684 -0
- package/src/components/tickets/ticket-dispatch-status.tsx +184 -0
- package/src/components/tickets/ticket-list-auto-refresh.tsx +55 -0
- package/src/components/tickets/ticket-reporter-profile.tsx +235 -0
- package/src/components/tickets/ticket-signatures-panel.tsx +32 -0
- package/src/components/tickets/ticket-timeline.tsx +131 -0
- package/src/components/tickets/ticket-triage-panel.tsx +124 -0
- package/src/components/tickets/tickets-nav.tsx +107 -0
- package/src/components/ui/avatar.tsx +43 -0
- package/src/components/ui/badge.tsx +34 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/card.tsx +77 -0
- package/src/components/ui/checkbox.tsx +31 -0
- package/src/components/ui/dialog.tsx +123 -0
- package/src/components/ui/dropdown-menu.tsx +126 -0
- package/src/components/ui/form.tsx +179 -0
- package/src/components/ui/input.tsx +24 -0
- package/src/components/ui/label.tsx +27 -0
- package/src/components/ui/popover.tsx +34 -0
- package/src/components/ui/progress.tsx +36 -0
- package/src/components/ui/scroll-area.tsx +47 -0
- package/src/components/ui/select.tsx +160 -0
- package/src/components/ui/separator.tsx +25 -0
- package/src/components/ui/sheet.tsx +131 -0
- package/src/components/ui/switch.tsx +30 -0
- package/src/components/ui/table.tsx +121 -0
- package/src/components/ui/tabs.tsx +62 -0
- package/src/components/ui/textarea.tsx +23 -0
- package/src/components/ui/tooltip.tsx +27 -0
- package/src/lib/actions/__tests__/devices.test.ts +176 -0
- package/src/lib/actions/__tests__/signatures.test.ts +303 -0
- package/src/lib/actions/__tests__/tickets.test.ts +243 -0
- package/src/lib/actions/audit-logs.ts +298 -0
- package/src/lib/actions/checklists.ts +429 -0
- package/src/lib/actions/dashboard.ts +358 -0
- package/src/lib/actions/data-management.ts +723 -0
- package/src/lib/actions/departments.ts +369 -0
- package/src/lib/actions/device-categories.ts +117 -0
- package/src/lib/actions/devices.ts +748 -0
- package/src/lib/actions/engineer-rounds.ts +973 -0
- package/src/lib/actions/engineers.ts +285 -0
- package/src/lib/actions/hospitals.ts +148 -0
- package/src/lib/actions/locations.ts +115 -0
- package/src/lib/actions/maintenance-plans.ts +316 -0
- package/src/lib/actions/maintenance-tasks.ts +415 -0
- package/src/lib/actions/manufacturers.ts +132 -0
- package/src/lib/actions/nav-counts.ts +144 -0
- package/src/lib/actions/notifications.ts +136 -0
- package/src/lib/actions/organizations.ts +99 -0
- package/src/lib/actions/qr.ts +147 -0
- package/src/lib/actions/report-history.ts +77 -0
- package/src/lib/actions/reports.ts +192 -0
- package/src/lib/actions/roles.ts +32 -0
- package/src/lib/actions/signature-auth.ts +377 -0
- package/src/lib/actions/signatures.ts +532 -0
- package/src/lib/actions/system-settings.ts +274 -0
- package/src/lib/actions/tickets.ts +1445 -0
- package/src/lib/actions/users.ts +740 -0
- package/src/lib/audit/index.ts +103 -0
- package/src/lib/auth/__tests__/rbac.test.ts +33 -0
- package/src/lib/auth/index.ts +338 -0
- package/src/lib/auth/password.ts +10 -0
- package/src/lib/auth/rbac.ts +103 -0
- package/src/lib/auth/types.ts +57 -0
- package/src/lib/constants/departments.ts +16 -0
- package/src/lib/constants/manufacturers.ts +32 -0
- package/src/lib/db/index.ts +23 -0
- package/src/lib/db/schema/audit-logs.ts +42 -0
- package/src/lib/db/schema/departments.ts +39 -0
- package/src/lib/db/schema/device-categories.ts +38 -0
- package/src/lib/db/schema/devices.ts +195 -0
- package/src/lib/db/schema/engineer-profiles.ts +63 -0
- package/src/lib/db/schema/engineer-rounds.ts +115 -0
- package/src/lib/db/schema/enums.ts +148 -0
- package/src/lib/db/schema/hospitals.ts +34 -0
- package/src/lib/db/schema/index.ts +24 -0
- package/src/lib/db/schema/locations.ts +46 -0
- package/src/lib/db/schema/maintenance-plans.ts +99 -0
- package/src/lib/db/schema/maintenance-records.ts +161 -0
- package/src/lib/db/schema/maintenance-tasks.ts +196 -0
- package/src/lib/db/schema/manufacturers.ts +60 -0
- package/src/lib/db/schema/notifications.ts +48 -0
- package/src/lib/db/schema/organizations.ts +24 -0
- package/src/lib/db/schema/report-history.ts +28 -0
- package/src/lib/db/schema/roles.ts +59 -0
- package/src/lib/db/schema/sessions.ts +46 -0
- package/src/lib/db/schema/signature-events.ts +48 -0
- package/src/lib/db/schema/signature-policies.ts +60 -0
- package/src/lib/db/schema/signatures.ts +87 -0
- package/src/lib/db/schema/tickets.ts +169 -0
- package/src/lib/db/schema/user-assignments.ts +85 -0
- package/src/lib/db/schema/users.ts +39 -0
- package/src/lib/db/seed.ts +131 -0
- package/src/lib/logger/__tests__/logger.test.ts +154 -0
- package/src/lib/logger/formatters.ts +159 -0
- package/src/lib/logger/index.ts +184 -0
- package/src/lib/logger/types.ts +48 -0
- package/src/lib/notifications/create.ts +71 -0
- package/src/lib/notifications/dispatcher.ts +490 -0
- package/src/lib/notifications/index.ts +7 -0
- package/src/lib/notifications/push-sender.ts +128 -0
- package/src/lib/notifications/push.ts +64 -0
- package/src/lib/notifications/triggers.ts +166 -0
- package/src/lib/utils/__tests__/crypto.test.ts +30 -0
- package/src/lib/utils/__tests__/export.test.ts +55 -0
- package/src/lib/utils/__tests__/nav-badge.test.ts +147 -0
- package/src/lib/utils/__tests__/staff-status.test.ts +50 -0
- package/src/lib/utils/attestations.ts +19 -0
- package/src/lib/utils/crypto.ts +18 -0
- package/src/lib/utils/csv-parser.ts +181 -0
- package/src/lib/utils/export.ts +45 -0
- package/src/lib/utils/nav-badge.ts +225 -0
- package/src/lib/utils/sound.ts +152 -0
- package/src/lib/utils/staff-status.ts +115 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/validators/__tests__/auth.test.ts +127 -0
- package/src/lib/validators/__tests__/data-management.test.ts +182 -0
- package/src/lib/validators/__tests__/devices-profile.test.ts +129 -0
- package/src/lib/validators/__tests__/devices.test.ts +98 -0
- package/src/lib/validators/__tests__/engineer-rounds.test.ts +170 -0
- package/src/lib/validators/__tests__/maintenance.test.ts +178 -0
- package/src/lib/validators/__tests__/signatures.test.ts +154 -0
- package/src/lib/validators/__tests__/system-settings.test.ts +119 -0
- package/src/lib/validators/__tests__/tickets.test.ts +176 -0
- package/src/lib/validators/__tests__/users.test.ts +92 -0
- package/src/lib/validators/auth.ts +32 -0
- package/src/lib/validators/data-management.ts +67 -0
- package/src/lib/validators/departments.ts +14 -0
- package/src/lib/validators/devices.ts +94 -0
- package/src/lib/validators/engineer-rounds.ts +70 -0
- package/src/lib/validators/hospitals.ts +17 -0
- package/src/lib/validators/locations.ts +15 -0
- package/src/lib/validators/maintenance.ts +211 -0
- package/src/lib/validators/organizations.ts +11 -0
- package/src/lib/validators/reports.ts +31 -0
- package/src/lib/validators/signatures.ts +49 -0
- package/src/lib/validators/system-settings.ts +55 -0
- package/src/lib/validators/tickets.ts +125 -0
- package/src/lib/validators/users.ts +43 -0
- package/src/middleware.ts +45 -0
- package/tailwind.config.ts +76 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { parseCSV, getDeviceImportTemplateCSV, getDepartmentImportTemplateCSV } from '@/lib/utils/csv-parser';
|
|
3
|
+
import { deviceImportRowSchema, departmentImportRowSchema, purgeDataSchema, exportRequestSchema } from '../data-management';
|
|
4
|
+
|
|
5
|
+
describe('CSV Parser Utility', () => {
|
|
6
|
+
it('parses simple CSV text into structured records', () => {
|
|
7
|
+
const csv = `asset_number,name,model\nDEV-001,Ventilator,V-500\nDEV-002,ECG Monitor,E-200`;
|
|
8
|
+
const records = parseCSV(csv);
|
|
9
|
+
expect(records).toHaveLength(2);
|
|
10
|
+
expect(records[0]).toEqual({
|
|
11
|
+
asset_number: 'DEV-001',
|
|
12
|
+
name: 'Ventilator',
|
|
13
|
+
model: 'V-500',
|
|
14
|
+
});
|
|
15
|
+
expect(records[1].asset_number).toEqual('DEV-002');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('handles quoted fields with commas correctly', () => {
|
|
19
|
+
const csv = `asset_number,name,location\nDEV-001,"Defibrillator, Biphasic","Room 102, Bay A"`;
|
|
20
|
+
const records = parseCSV(csv);
|
|
21
|
+
expect(records).toHaveLength(1);
|
|
22
|
+
expect(records[0].name).toBe('Defibrillator, Biphasic');
|
|
23
|
+
expect(records[0].location).toBe('Room 102, Bay A');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('normalizes various header formats', () => {
|
|
27
|
+
const csv = `Asset-Number,Device Name,SERIAL_NUMBER\nDEV-01,Pump,SN-100`;
|
|
28
|
+
const records = parseCSV(csv);
|
|
29
|
+
expect(records[0]).toHaveProperty('asset_number');
|
|
30
|
+
expect(records[0]).toHaveProperty('device_name');
|
|
31
|
+
expect(records[0]).toHaveProperty('serial_number');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('returns empty array when text has only headers', () => {
|
|
35
|
+
const csv = `asset_number,name,model`;
|
|
36
|
+
expect(parseCSV(csv)).toHaveLength(0);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('getDeviceImportTemplateCSV', () => {
|
|
41
|
+
it('generates a valid CSV with BOM and required BEMMS headers', () => {
|
|
42
|
+
const template = getDeviceImportTemplateCSV();
|
|
43
|
+
expect(template.startsWith('\uFEFF')).toBe(true);
|
|
44
|
+
expect(template).toContain('asset_number');
|
|
45
|
+
expect(template).toContain('category');
|
|
46
|
+
expect(template).toContain('department');
|
|
47
|
+
expect(template).toContain('manufacturer');
|
|
48
|
+
|
|
49
|
+
const parsed = parseCSV(template);
|
|
50
|
+
expect(parsed.length).toBeGreaterThanOrEqual(2);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('getDepartmentImportTemplateCSV', () => {
|
|
55
|
+
it('generates a valid CSV with BOM and department headers', () => {
|
|
56
|
+
const template = getDepartmentImportTemplateCSV();
|
|
57
|
+
expect(template.startsWith('\uFEFF')).toBe(true);
|
|
58
|
+
expect(template).toContain('name');
|
|
59
|
+
expect(template).toContain('code');
|
|
60
|
+
expect(template).toContain('hospital_name');
|
|
61
|
+
|
|
62
|
+
const parsed = parseCSV(template);
|
|
63
|
+
expect(parsed.length).toBeGreaterThanOrEqual(2);
|
|
64
|
+
expect(parsed[0]).toHaveProperty('name');
|
|
65
|
+
expect(parsed[0]).toHaveProperty('code');
|
|
66
|
+
expect(parsed[0]).toHaveProperty('hospital_name');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('departmentImportRowSchema', () => {
|
|
71
|
+
it('validates a correct department row', () => {
|
|
72
|
+
const result = departmentImportRowSchema.safeParse({
|
|
73
|
+
name: 'Intensive Care Unit',
|
|
74
|
+
code: 'ICU',
|
|
75
|
+
departmentType: 'critical_care',
|
|
76
|
+
hospitalName: 'Central Teaching Hospital',
|
|
77
|
+
});
|
|
78
|
+
expect(result.success).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('rejects rows missing required fields', () => {
|
|
82
|
+
const result = departmentImportRowSchema.safeParse({
|
|
83
|
+
name: '',
|
|
84
|
+
code: '',
|
|
85
|
+
hospitalName: '',
|
|
86
|
+
});
|
|
87
|
+
expect(result.success).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('deviceImportRowSchema', () => {
|
|
92
|
+
it('validates a complete medical device row', () => {
|
|
93
|
+
const result = deviceImportRowSchema.safeParse({
|
|
94
|
+
assetNumber: 'DEV-100',
|
|
95
|
+
name: 'Syringe Pump',
|
|
96
|
+
model: 'SP-1000',
|
|
97
|
+
serialNumber: 'SN-789',
|
|
98
|
+
categoryName: 'Infusion Pump',
|
|
99
|
+
manufacturerName: 'B. Braun',
|
|
100
|
+
departmentName: 'Emergency',
|
|
101
|
+
locationDescription: 'Storage Room B',
|
|
102
|
+
riskClassification: 'class_iib',
|
|
103
|
+
criticalityLevel: 'high',
|
|
104
|
+
});
|
|
105
|
+
expect(result.success).toBe(true);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('rejects rows missing required assetNumber or name', () => {
|
|
109
|
+
const result = deviceImportRowSchema.safeParse({
|
|
110
|
+
assetNumber: '',
|
|
111
|
+
name: 'Syringe Pump',
|
|
112
|
+
categoryName: 'Pump',
|
|
113
|
+
manufacturerName: 'Vendor',
|
|
114
|
+
departmentName: 'ICU',
|
|
115
|
+
});
|
|
116
|
+
expect(result.success).toBe(false);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('applies standard defaults for optional fields', () => {
|
|
120
|
+
const result = deviceImportRowSchema.safeParse({
|
|
121
|
+
assetNumber: 'DEV-200',
|
|
122
|
+
name: 'Patient Monitor',
|
|
123
|
+
categoryName: 'Monitor',
|
|
124
|
+
manufacturerName: 'GE Healthcare',
|
|
125
|
+
departmentName: 'ICU',
|
|
126
|
+
});
|
|
127
|
+
expect(result.success).toBe(true);
|
|
128
|
+
if (result.success) {
|
|
129
|
+
expect(result.data.riskClassification).toBe('class_i');
|
|
130
|
+
expect(result.data.criticalityLevel).toBe('medium');
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('purgeDataSchema', () => {
|
|
136
|
+
it('validates a valid test data purge request', () => {
|
|
137
|
+
const result = purgeDataSchema.safeParse({
|
|
138
|
+
scope: 'test_transactions',
|
|
139
|
+
confirmText: 'PURGE TEST DATA',
|
|
140
|
+
password: 'adminPassword123',
|
|
141
|
+
reason: 'Pre-launch test cleanup',
|
|
142
|
+
});
|
|
143
|
+
expect(result.success).toBe(true);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('rejects missing password', () => {
|
|
147
|
+
const result = purgeDataSchema.safeParse({
|
|
148
|
+
scope: 'test_transactions',
|
|
149
|
+
confirmText: 'PURGE TEST DATA',
|
|
150
|
+
password: '',
|
|
151
|
+
});
|
|
152
|
+
expect(result.success).toBe(false);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe('exportRequestSchema', () => {
|
|
157
|
+
it('accepts rounds as a valid export entity', () => {
|
|
158
|
+
const result = exportRequestSchema.safeParse({
|
|
159
|
+
entities: ['rounds'],
|
|
160
|
+
format: 'xlsx',
|
|
161
|
+
});
|
|
162
|
+
expect(result.success).toBe(true);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('accepts full multi-entity export including rounds', () => {
|
|
166
|
+
const result = exportRequestSchema.safeParse({
|
|
167
|
+
entities: ['devices', 'departments', 'tickets', 'rounds'],
|
|
168
|
+
format: 'json',
|
|
169
|
+
});
|
|
170
|
+
expect(result.success).toBe(true);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('rejects empty entities array', () => {
|
|
174
|
+
const result = exportRequestSchema.safeParse({
|
|
175
|
+
entities: [],
|
|
176
|
+
format: 'csv',
|
|
177
|
+
});
|
|
178
|
+
expect(result.success).toBe(false);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
transferDeviceSchema,
|
|
4
|
+
changeDeviceStatusSchema,
|
|
5
|
+
decommissionDeviceSchema,
|
|
6
|
+
} from '../devices';
|
|
7
|
+
|
|
8
|
+
describe('Device Transfer & Status Change Validators', () => {
|
|
9
|
+
const validUuid1 = '123e4567-e89b-12d3-a456-426614174000';
|
|
10
|
+
const validUuid2 = '223e4567-e89b-12d3-a456-426614174000';
|
|
11
|
+
|
|
12
|
+
describe('transferDeviceSchema', () => {
|
|
13
|
+
it('validates a complete transfer payload', () => {
|
|
14
|
+
const valid = {
|
|
15
|
+
destinationHospitalId: validUuid1,
|
|
16
|
+
destinationDepartmentId: validUuid2,
|
|
17
|
+
destinationLocationId: validUuid1,
|
|
18
|
+
transferReason: 'relocation',
|
|
19
|
+
notes: 'Moved to new ICU wing room 4',
|
|
20
|
+
};
|
|
21
|
+
const result = transferDeviceSchema.safeParse(valid);
|
|
22
|
+
expect(result.success).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('accepts all valid transfer reasons', () => {
|
|
26
|
+
const reasons = [
|
|
27
|
+
'relocation',
|
|
28
|
+
'temporary_loan',
|
|
29
|
+
'department_change',
|
|
30
|
+
'correction',
|
|
31
|
+
'replacement',
|
|
32
|
+
'workshop',
|
|
33
|
+
'storage',
|
|
34
|
+
'other',
|
|
35
|
+
];
|
|
36
|
+
for (const reason of reasons) {
|
|
37
|
+
const result = transferDeviceSchema.safeParse({
|
|
38
|
+
destinationHospitalId: validUuid1,
|
|
39
|
+
destinationDepartmentId: validUuid2,
|
|
40
|
+
transferReason: reason,
|
|
41
|
+
});
|
|
42
|
+
expect(result.success).toBe(true);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('rejects an invalid transfer reason', () => {
|
|
47
|
+
const result = transferDeviceSchema.safeParse({
|
|
48
|
+
destinationHospitalId: validUuid1,
|
|
49
|
+
destinationDepartmentId: validUuid2,
|
|
50
|
+
transferReason: 'invalid_reason',
|
|
51
|
+
});
|
|
52
|
+
expect(result.success).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('rejects missing destination hospital or department', () => {
|
|
56
|
+
const result = transferDeviceSchema.safeParse({
|
|
57
|
+
transferReason: 'relocation',
|
|
58
|
+
});
|
|
59
|
+
expect(result.success).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('changeDeviceStatusSchema', () => {
|
|
64
|
+
it('validates a valid status change', () => {
|
|
65
|
+
const valid = {
|
|
66
|
+
newStatusCode: 'under_maintenance',
|
|
67
|
+
reason: 'Scheduled quarterly preventive inspection',
|
|
68
|
+
notes: 'Engineer assigned and work order created',
|
|
69
|
+
};
|
|
70
|
+
const result = changeDeviceStatusSchema.safeParse(valid);
|
|
71
|
+
expect(result.success).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('accepts all 9 medical device operational statuses', () => {
|
|
75
|
+
const statuses = [
|
|
76
|
+
'operational',
|
|
77
|
+
'operational_with_limitations',
|
|
78
|
+
'under_maintenance',
|
|
79
|
+
'under_repair',
|
|
80
|
+
'waiting_for_parts',
|
|
81
|
+
'awaiting_release',
|
|
82
|
+
'out_of_service',
|
|
83
|
+
'standby',
|
|
84
|
+
'decommissioned',
|
|
85
|
+
];
|
|
86
|
+
for (const status of statuses) {
|
|
87
|
+
const result = changeDeviceStatusSchema.safeParse({
|
|
88
|
+
newStatusCode: status,
|
|
89
|
+
reason: `Transitioning to ${status}`,
|
|
90
|
+
});
|
|
91
|
+
expect(result.success).toBe(true);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('rejects an invalid status code', () => {
|
|
96
|
+
const result = changeDeviceStatusSchema.safeParse({
|
|
97
|
+
newStatusCode: 'broken_beyond_repair',
|
|
98
|
+
reason: 'Hardware failure',
|
|
99
|
+
});
|
|
100
|
+
expect(result.success).toBe(false);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('rejects empty or missing reason', () => {
|
|
104
|
+
const result = changeDeviceStatusSchema.safeParse({
|
|
105
|
+
newStatusCode: 'out_of_service',
|
|
106
|
+
reason: '',
|
|
107
|
+
});
|
|
108
|
+
expect(result.success).toBe(false);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('decommissionDeviceSchema', () => {
|
|
113
|
+
it('validates a valid decommission reason', () => {
|
|
114
|
+
const valid = {
|
|
115
|
+
reason: 'Equipment reached end-of-life per manufacturer policy and safety notice.',
|
|
116
|
+
};
|
|
117
|
+
const result = decommissionDeviceSchema.safeParse(valid);
|
|
118
|
+
expect(result.success).toBe(true);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('rejects too short decommission reason', () => {
|
|
122
|
+
const result = decommissionDeviceSchema.safeParse({
|
|
123
|
+
reason: 'old',
|
|
124
|
+
});
|
|
125
|
+
expect(result.success).toBe(false);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
createDeviceSchema,
|
|
4
|
+
createDeviceCategorySchema,
|
|
5
|
+
createManufacturerSchema,
|
|
6
|
+
} from '../devices';
|
|
7
|
+
|
|
8
|
+
describe('createDeviceCategorySchema', () => {
|
|
9
|
+
const validUuid = '123e4567-e89b-12d3-a456-426614174000';
|
|
10
|
+
|
|
11
|
+
it('validates a correct device category', () => {
|
|
12
|
+
const result = createDeviceCategorySchema.safeParse({
|
|
13
|
+
organizationId: validUuid,
|
|
14
|
+
name: 'Infusion Pump',
|
|
15
|
+
code: 'INF-PUMP',
|
|
16
|
+
description: 'Standard volumetric infusion pump',
|
|
17
|
+
riskClassification: 'class_iib',
|
|
18
|
+
criticalityLevel: 'high',
|
|
19
|
+
defaultPmIntervalDays: 180,
|
|
20
|
+
});
|
|
21
|
+
expect(result.success).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('rejects invalid UUID for organizationId', () => {
|
|
25
|
+
const result = createDeviceCategorySchema.safeParse({
|
|
26
|
+
organizationId: 'not-a-uuid',
|
|
27
|
+
name: 'Infusion Pump',
|
|
28
|
+
code: 'INF',
|
|
29
|
+
});
|
|
30
|
+
expect(result.success).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('rejects invalid risk classification enum value', () => {
|
|
34
|
+
const result = createDeviceCategorySchema.safeParse({
|
|
35
|
+
organizationId: validUuid,
|
|
36
|
+
name: 'Infusion Pump',
|
|
37
|
+
code: 'INF',
|
|
38
|
+
riskClassification: 'invalid_class',
|
|
39
|
+
});
|
|
40
|
+
expect(result.success).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('createManufacturerSchema', () => {
|
|
45
|
+
const validUuid = '123e4567-e89b-12d3-a456-426614174000';
|
|
46
|
+
|
|
47
|
+
it('validates a valid manufacturer', () => {
|
|
48
|
+
const result = createManufacturerSchema.safeParse({
|
|
49
|
+
organizationId: validUuid,
|
|
50
|
+
name: 'GE Healthcare',
|
|
51
|
+
code: 'GE',
|
|
52
|
+
country: 'USA',
|
|
53
|
+
supportEmail: 'support@ge.com',
|
|
54
|
+
website: 'https://gehealthcare.com',
|
|
55
|
+
});
|
|
56
|
+
expect(result.success).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('allows empty string for optional email and website', () => {
|
|
60
|
+
const result = createManufacturerSchema.safeParse({
|
|
61
|
+
organizationId: validUuid,
|
|
62
|
+
name: 'Local Medtech',
|
|
63
|
+
supportEmail: '',
|
|
64
|
+
website: '',
|
|
65
|
+
});
|
|
66
|
+
expect(result.success).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('createDeviceSchema', () => {
|
|
71
|
+
const validUuid = '123e4567-e89b-12d3-a456-426614174000';
|
|
72
|
+
|
|
73
|
+
it('validates a complete valid device', () => {
|
|
74
|
+
const result = createDeviceSchema.safeParse({
|
|
75
|
+
organizationId: validUuid,
|
|
76
|
+
hospitalId: validUuid,
|
|
77
|
+
departmentId: validUuid,
|
|
78
|
+
name: 'Defibrillator X',
|
|
79
|
+
assetNumber: 'BME-DEF-001',
|
|
80
|
+
serialNumber: 'SN-987654321',
|
|
81
|
+
deviceCategoryId: validUuid,
|
|
82
|
+
criticalityLevel: 'critical',
|
|
83
|
+
riskClassification: 'class_iii',
|
|
84
|
+
});
|
|
85
|
+
expect(result.success).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('rejects device without assetNumber or name', () => {
|
|
89
|
+
const result = createDeviceSchema.safeParse({
|
|
90
|
+
organizationId: validUuid,
|
|
91
|
+
hospitalId: validUuid,
|
|
92
|
+
departmentId: validUuid,
|
|
93
|
+
deviceCategoryId: validUuid,
|
|
94
|
+
});
|
|
95
|
+
expect(result.success).toBe(false);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
startRoundSchema,
|
|
4
|
+
completeDepartmentVisitSchema,
|
|
5
|
+
addVisitNoteSchema,
|
|
6
|
+
completeRoundSchema,
|
|
7
|
+
roundHistoryFilterSchema,
|
|
8
|
+
roundCalendarQuerySchema,
|
|
9
|
+
} from '../engineer-rounds';
|
|
10
|
+
import { featuresSettingsSchema, systemSettingsSchema } from '../system-settings';
|
|
11
|
+
|
|
12
|
+
describe('featuresSettingsSchema', () => {
|
|
13
|
+
it('defaults engineerRoundEnabled to false', () => {
|
|
14
|
+
const result = featuresSettingsSchema.safeParse({});
|
|
15
|
+
expect(result.success).toBe(true);
|
|
16
|
+
if (result.success) {
|
|
17
|
+
expect(result.data.engineerRoundEnabled).toBe(false);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('accepts explicitly enabled engineerRoundEnabled', () => {
|
|
22
|
+
const result = featuresSettingsSchema.safeParse({ engineerRoundEnabled: true });
|
|
23
|
+
expect(result.success).toBe(true);
|
|
24
|
+
if (result.success) {
|
|
25
|
+
expect(result.data.engineerRoundEnabled).toBe(true);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('integrates cleanly into systemSettingsSchema', () => {
|
|
30
|
+
const result = systemSettingsSchema.safeParse({
|
|
31
|
+
features: { engineerRoundEnabled: true },
|
|
32
|
+
});
|
|
33
|
+
expect(result.success).toBe(true);
|
|
34
|
+
if (result.success) {
|
|
35
|
+
expect(result.data.features.engineerRoundEnabled).toBe(true);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('startRoundSchema', () => {
|
|
41
|
+
it('accepts valid start round payload with password signature', () => {
|
|
42
|
+
const result = startRoundSchema.safeParse({
|
|
43
|
+
hospitalId: '123e4567-e89b-12d3-a456-426614174000',
|
|
44
|
+
shiftType: 'morning',
|
|
45
|
+
password: 'MySecretPassword123!',
|
|
46
|
+
});
|
|
47
|
+
expect(result.success).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('rejects missing password for e-signature', () => {
|
|
51
|
+
const result = startRoundSchema.safeParse({
|
|
52
|
+
hospitalId: '123e4567-e89b-12d3-a456-426614174000',
|
|
53
|
+
shiftType: 'morning',
|
|
54
|
+
password: '',
|
|
55
|
+
});
|
|
56
|
+
expect(result.success).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('rejects invalid hospital UUID', () => {
|
|
60
|
+
const result = startRoundSchema.safeParse({
|
|
61
|
+
hospitalId: 'invalid-uuid',
|
|
62
|
+
shiftType: 'evening',
|
|
63
|
+
password: 'valid-password',
|
|
64
|
+
});
|
|
65
|
+
expect(result.success).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('defaults shiftType to morning if omitted', () => {
|
|
69
|
+
const result = startRoundSchema.safeParse({
|
|
70
|
+
hospitalId: '123e4567-e89b-12d3-a456-426614174000',
|
|
71
|
+
password: 'valid-password',
|
|
72
|
+
});
|
|
73
|
+
expect(result.success).toBe(true);
|
|
74
|
+
if (result.success) {
|
|
75
|
+
expect(result.data.shiftType).toBe('morning');
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('completeDepartmentVisitSchema', () => {
|
|
81
|
+
it('accepts completion with optional note and @device mentions', () => {
|
|
82
|
+
const result = completeDepartmentVisitSchema.safeParse({
|
|
83
|
+
visitId: '123e4567-e89b-12d3-a456-426614174001',
|
|
84
|
+
noteText: 'Checked ventilator, all operating within specifications.',
|
|
85
|
+
deviceMentions: [
|
|
86
|
+
{
|
|
87
|
+
deviceId: '123e4567-e89b-12d3-a456-426614174002',
|
|
88
|
+
deviceName: 'Ventilator 01',
|
|
89
|
+
internalCode: 'ICU-VENT-01',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
});
|
|
93
|
+
expect(result.success).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('accepts completion without note (quick completion)', () => {
|
|
97
|
+
const result = completeDepartmentVisitSchema.safeParse({
|
|
98
|
+
visitId: '123e4567-e89b-12d3-a456-426614174001',
|
|
99
|
+
});
|
|
100
|
+
expect(result.success).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('rejects invalid visitId UUID', () => {
|
|
104
|
+
const result = completeDepartmentVisitSchema.safeParse({
|
|
105
|
+
visitId: 'not-a-uuid',
|
|
106
|
+
});
|
|
107
|
+
expect(result.success).toBe(false);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('addVisitNoteSchema', () => {
|
|
112
|
+
it('accepts non-empty note with device mentions', () => {
|
|
113
|
+
const result = addVisitNoteSchema.safeParse({
|
|
114
|
+
visitId: '123e4567-e89b-12d3-a456-426614174001',
|
|
115
|
+
noteText: 'Replaced backup battery on @Monitor-02',
|
|
116
|
+
deviceMentions: [
|
|
117
|
+
{
|
|
118
|
+
deviceId: '123e4567-e89b-12d3-a456-426614174003',
|
|
119
|
+
deviceName: 'Monitor-02',
|
|
120
|
+
internalCode: 'EMERG-MON-02',
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
expect(result.success).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('rejects empty note', () => {
|
|
128
|
+
const result = addVisitNoteSchema.safeParse({
|
|
129
|
+
visitId: '123e4567-e89b-12d3-a456-426614174001',
|
|
130
|
+
noteText: '',
|
|
131
|
+
});
|
|
132
|
+
expect(result.success).toBe(false);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('roundCalendarQuerySchema', () => {
|
|
137
|
+
it('accepts valid month and year', () => {
|
|
138
|
+
const result = roundCalendarQuerySchema.safeParse({
|
|
139
|
+
engineerId: '123e4567-e89b-12d3-a456-426614174000',
|
|
140
|
+
month: 10,
|
|
141
|
+
year: 2026,
|
|
142
|
+
});
|
|
143
|
+
expect(result.success).toBe(true);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('rejects invalid month numbers', () => {
|
|
147
|
+
const result = roundCalendarQuerySchema.safeParse({
|
|
148
|
+
engineerId: '123e4567-e89b-12d3-a456-426614174000',
|
|
149
|
+
month: 13,
|
|
150
|
+
year: 2026,
|
|
151
|
+
});
|
|
152
|
+
expect(result.success).toBe(false);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe('completeRoundSchema', () => {
|
|
157
|
+
it('accepts valid round UUID', () => {
|
|
158
|
+
const result = completeRoundSchema.safeParse({
|
|
159
|
+
roundId: '123e4567-e89b-12d3-a456-426614174000',
|
|
160
|
+
});
|
|
161
|
+
expect(result.success).toBe(true);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('rejects invalid round UUID', () => {
|
|
165
|
+
const result = completeRoundSchema.safeParse({
|
|
166
|
+
roundId: 'not-valid',
|
|
167
|
+
});
|
|
168
|
+
expect(result.success).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
});
|