Skip to content

test: cover safeNum and loadHistory in fetch-hive-history.js - #1255

Merged
castrojo merged 1 commit into
projectbluefin:mainfrom
kylerankin:quality/fetch-hive-history-tests
Sep 13, 2026
Merged

test: cover safeNum and loadHistory in fetch-hive-history.js#1255
castrojo merged 1 commit into
projectbluefin:mainfrom
kylerankin:quality/fetch-hive-history-tests

Conversation

@kylerankin

Copy link
Copy Markdown
Contributor

Closes #947.

The merged #947 suite already pins extractMetrics (the sole reader of the live hive payload) plus the weekly-stats accumulator. This closes the remaining gaps the issue named:

  • safeNum — finite numbers pass; everything else (NaN, +/-Infinity, numeric strings, null/undefined, objects) coerces to undefined so a chart plots a gap, not a garbage value.
  • loadHistory — fresh start returns the seeded default, a valid file parses, and a corrupt file degrades to the default instead of throwing.

Implementation notes:

  • loadHistory now takes an optional file argument (default OUTPUT_FILE) so it can be driven against a temp file without touching the tracked static/data/hive-history.json seed.
  • safeNum and loadHistory are added to module.exports so the pure functions are importable by the test suite.

(extractRenderData from the issue no longer exists — the raw-HTML snapshot path was removed when the hosted Knuckle /api/status endpoint replaced it, so there is nothing to test there.)

All 28 suites pass under node --test; eslint is clean.


— hive: backend=pi model=lemonade/Ornith-1.5-35B-A3B-GGUF-Q6_K

🐝 Hive Agent: contributor | SHA: 54caa541

The merged projectbluefin#947 suite already pins extractMetrics, the sole reader of the
live hive payload. This closes the remaining gaps the issue named:

- safeNum: finite numbers pass, everything else (NaN, +/-Infinity, strings,
  null/undefined, objects) coerces to undefined.
- loadHistory: fresh start returns the seeded default, a valid file parses,
  and a corrupt file degrades to the default instead of throwing.

loadHistory now takes an optional path (default OUTPUT_FILE) so it can be
driven at a temp file without touching the tracked seed, and safeNum +
loadHistory are added to module.exports.

Closes projectbluefin#947.

Signed-off-by: kylerankin <kylerankin@users.noreply.github.com>
@castrojo
castrojo added this pull request to the merge queue Sep 13, 2026
Merged via the queue into projectbluefin:main with commit 4c69c7e Sep 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] Add unit tests for fetch-hive-history.js (15KB, no test coverage)

2 participants