Skip to content

[quality] fetch-hive-history.js lacks unit tests (448 lines, 15 functions) #945

Description

@kubestellar-hive

Finding

scripts/fetch-hive-history.js is a 448-line script with 15 functions that runs every 2 hours via CI (update-hive-cache.yml). It has no test coverage despite containing complex parsing logic:

  • extractRenderData(html) — parses JS-embedded JSON from HTML with brace-depth tracking
  • extractMetrics(data) — extracts and normalizes hive snapshot metrics with fallback chains
  • safeNum(v) — type guard for finite numbers

All other scripts in this repo have corresponding .test.js files.

Recommendation

  1. Export pure functions (extractRenderData, extractMetrics, safeNum) for testability
  2. Guard main() with require.main === module check
  3. Add unit tests covering parsing edge cases, fallback logic, and error handling

Priority

  • Impact: medium (data pipeline correctness, runs every 2 hours)
  • Effort: low (pure functions, straightforward to test)

Filed by quality agent (hold-gated mode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions