Repository navigation
refactor(webapp): bring all webapp JS functions under CRAP 10 - #14
Open
adamsrnmsu wants to merge 1 commit into
Open
adamsrnmsu wants to merge 1 commit into
adamsrnmsu wants to merge 1 commit into
Conversation
Problem: crapper reported 52 webapp JS functions at CRAP >= 10. That number
was an artifact: the npm dependencies were not installed, so JS coverage
failed ("Cannot find module 'jsdom'") and everything scored 0% coverage.
With deps installed (npm install in src/parseus/webapp; node_modules is
already ignored) coverage works and the real list is 25 functions in
alerts/script.js, registers.js, main.js and network_analytics.js.
Cause: five of them had real complexity (draw CC 22, renderAlertList 24,
getAxiosErrorMessage 13, renderHealthStatus 12, openAlertStream 11,
getAlertListSignature 10, reconcilePendingAlertActions 10); the rest were
simply untested (main.js, network_analytics.js, registers.js had no JS
tests at all).
Fix: add jsdom tests (a small loader, js_tests/load_script.js, runs a page
script in jsdom with real jQuery/d3 where the page uses them; npm test now
also runs js_tests/*.test.js), plus behaviour-preserving extractions:
- alerts: captureAlertSelection/restoreAlertSelection/buildAlertRow/
getAlertTotalCount out of renderAlertList; getAlertSignatureEntry;
collectSnapshotUuids; getAxiosResponseData; renderDiskUsage;
handleAlertSnapshotEvent/handleAlertHeartbeatEvent out of openAlertStream.
- registers: resolveMargin, resolvePointStyle, createXScale, paddedDomain
out of draw (resolveMargin also replaces the repeated margin block in the
two heatmaps; options.margin is no longer written back, nothing read it).
Verified:
- crapper (webapp, JS): functions with CRAP >= 10: 25 real (52 reported
before, with coverage broken) -> 0; highest remaining is 9.8.
- npm test: 30 tests before -> 71 pass, 0 fail.
- Python: no Python files changed; tests/test_analytics_capability_declarations.py
21 passed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #5 (which covered Python). crapper reported 52 webapp JS functions at CRAP >= 10, but that was an artifact: without the npm dependencies, JS coverage failed (
Cannot find module 'jsdom') and every function scored 0%. With them installed the real list is 25 functions inalerts/static/js/script.js,registers.js,main.jsandnetwork_analytics.js. All are now under 10 (highest 9.8).js_tests/load_script.jsruns a page script in jsdom with real jQuery/d3; new tests formain.js,network_analytics.js,registers.jsand the alerts helpers.npm testalso runsjs_tests/*.test.js.renderAlertList(CC 24),openAlertStream,getAxiosErrorMessage,renderHealthStatusin alerts;draw(CC 22) in registers (resolveMarginalso replaces the repeated margin block in the two heatmaps;options.marginis no longer written back to the caller, nothing read it).Related Issues/PRs
registers.js; trivial rebase at most.Type of Change
fix)feat)docs)refactor)chore)Checklist
Testing
npm testinsrc/parseus/webapp: 30 tests before, 71 pass and 0 fail after.Additional Notes
Found while writing the tests, not fixed here:
updateGraphpasses${graph_id}-legendwithout a#, andaddToLegend/clearLegendcall$(legend_id), which selects a tag name, so the register and state graph legends are never filled. The new tests deliberately do not assert legend contents.🤖 Generated with Claude Code