Parent issue: #90
Overview
P0 priority tests for data validation, type guards, and file persistence. If these fail, data is lost.
Tests: Validators (20 tests)
| Test |
Type |
validateSerializedData accepts valid payload |
+ |
validateSerializedData accepts minimal payload |
+ |
validateSerializedData accepts legacy data (no partiallyAuditedFiles) |
+ |
validateSerializedData rejects missing treeEntries |
- |
validateSerializedData rejects missing auditedFiles |
- |
validateSerializedData rejects missing resolvedEntries |
- |
validateSerializedData rejects invalid entryType |
- |
validateSerializedData rejects entry missing label/author/details/locations |
- |
validateSerializedData rejects location missing path/startLine/endLine/label |
- |
validateSerializedData rejects auditedFile missing path/author |
- |
validateSerializedData rejects partiallyAuditedFile missing coordinates |
- |
validateSerializedData rejects entryDetails missing severity/difficulty/type |
- |
Tests: Type Guards (11 tests)
| Test |
Type |
isEntry true for FullEntry, false for LocationEntry/PathOrganizer |
+/- |
isLocationEntry true for FullLocationEntry, false for FullEntry |
+/- |
isPathOrganizerEntry true/false cases |
+/- |
isOldEntry legacy vs new format |
+/- |
isConfigurationEntry / isWorkspaceRootEntry |
+/- |
Tests: Equality & Merging (18 tests)
| Test |
Type |
entryEquals identical entries |
+ |
entryEquals different label/author/type/locations |
- |
getEntryIndexFromArray found and not found |
+/- |
mergeTwoEntryArrays deduplication and empty arrays |
+ |
mergeTwoAuditedFileArrays deduplication |
+ |
mergeTwoPartiallyAuditedFileArrays deduplication |
+ |
configEntryEquals all cases |
+/- |
Tests: Factory Functions (9 tests)
| Test |
Type |
createDefaultSerializedData structure |
+ |
createDefaultEntryDetails structure |
+ |
createPathOrganizer / createLocationEntry |
+ |
treeViewModeLabel enum conversion |
+ |
Tests: File Persistence (12 tests)
| Test |
Type |
| Load .weaudit parses valid JSON |
+ |
| Load .weaudit handles missing/corrupt/empty file |
- |
| Load .weaudit rejects invalid schema |
- |
| Save .weaudit creates .vscode if missing |
+ |
| Save .weaudit writes valid JSON |
+ |
| Save .weaudit preserves other users data |
+ |
| Day log load/save/missing/corrupt |
+/- |
Files
test/unit/validators.test.ts
test/unit/types.test.ts (extend existing)
test/unit/persistence.test.ts
Total: 70 tests