Files
open-design/apps/daemon/tests
SidandGitHub 95637b2ae2 test(daemon): cover kindFor and mimeFor file classifiers (#269)
Both helpers in `apps/daemon/src/projects.ts` are dispatch points
multiple modules depend on, but had zero test coverage:

- `kindFor` returns the coarse 'image' / 'sketch' / 'code' / 'video' /
  'audio' / 'text' / 'html' / 'pdf' / 'document' / 'presentation' /
  'spreadsheet' / 'binary' bucket the frontend uses to pick a viewer in
  `apps/web/src/components/FileViewer.tsx`. Called from
  `projects.ts:66/88/130`, `media.ts:448`, and `document-preview.ts:18`.
- `mimeFor` is the Content-Type the daemon sends when serving the file
  directly. Called from the file-serving routes in `server.ts`.

Adding `tests/project-classifiers.test.ts` (15 cases) pins both
contracts so the next bucket addition (e.g. issue #61's recently-merged
`.py` extension, or upcoming `.yaml` / `.toml` / `.sh` requests) can
be made with a clear regression net.

`kindFor` coverage:
- compound `.sketch.json` extension wins over `.json`
- `.html` / `.htm` → `'html'`
- `.svg` → `'sketch'`
- raster image extensions → `'image'`, with `sketch-` prefix → `'sketch'`
- video / audio / markdown / text / code (incl. `.py`) buckets
- office docs → respective `'pdf' / 'document' / 'presentation' /
  'spreadsheet'` buckets
- unknown extensions and extensionless names → `'binary'`
- case-insensitive on extension

`mimeFor` coverage:
- every `EXT_MIME` mapping (charset where applicable)
- unmapped extensions → `'application/octet-stream'`
- case-insensitive on extension

No production change — pure test addition.

Verification:
- `pnpm --filter @open-design/daemon test` — 16 files / 240 tests pass
  (was 15 files / 225 tests on main; +1 file, +15 tests).
2026-05-02 16:25:47 +08:00
..