test: add unit-test harness (tsx + node:test) + first suite for utils/common

Addresses the "no automated test suite" gap. Chose Node's built-in test runner
via tsx rather than vitest: the project is on Vite 8.0.14, ahead of vitest's
supported Vite range, so vitest would fight peer deps. tsx is build-independent.

- `npm test` → `node --import tsx --test $(find src -name '*.test.ts')` (works on
  Node 20 local + 24 CI without relying on --test glob support).
- src/app/utils/common.test.ts: 15 tests covering the pure helpers (bytesToSize,
  time formatters, binarySearch, parseGeoUri, slash trimmers, nameInitials,
  randomStr, suffixRename, splitWithSpace, promise-settled helpers, etc.) —
  asserts actual behavior, traced from source.
- common.ts: folds import made `import type` (it's types only) so the module is
  pure and testable without loading folds/CSS.
- tsconfig excludes *.test.ts (tsx transpiles tests; eslint isn't type-aware so
  it still lints them); added an informational CI "Unit tests" step (promote to a
  hard gate by dropping continue-on-error).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 08:45:22 -04:00
parent 36343baecc
commit e80ebd35cb
6 changed files with 177 additions and 2 deletions
+1 -1
View File
@@ -13,6 +13,6 @@
"skipLibCheck": true,
"lib": ["ES2020", "DOM"]
},
"exclude": ["node_modules", "dist"],
"exclude": ["node_modules", "dist", "src/**/*.test.ts"],
"include": ["src"]
}