Skip to content

Add javascript tests for the template control logic - #24

Open
tepickering wants to merge 2 commits into
masterfrom
js-tests
Open

Add javascript tests for the template control logic#24
tepickering wants to merge 2 commits into
masterfrom
js-tests

Conversation

@tepickering

@tepickering tepickering commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the continuous mode fix in aed2c63. That was a browser-side bug in code with no test coverage at all, so nothing caught it before it reached the telescope in the middle of an MMIRS night.

What this adds

A small jsdom suite covering the control logic in wfs.html and cwfs.html, run by node's built-in test runner.

  • wfssrv/tests/js/harness.js — mounts a template's control script in jsdom with a stubbed fetch and a virtual clock
  • wfssrv/tests/js/controls.test.js — 12 tests
  • package.json / package-lock.json — one devDependency, jsdom
  • .github/workflows/js-tests.yml — runs npm ci && npm test on node 22 and 24
  • CLAUDE.md — documents how to run the JS suite, plus a Deployment section recording that the summit installs from GitHub master (pip install git+... --upgrade into its mmtwfs conda env), so a fix is not deployed until it is pushed to master

Design notes

The javascript is read out of the templates, not copied. The harness pulls the inline <script> block that defines controlButtons out of the .html file and evals it. A copy in the test tree would drift and quietly stop catching regressions.

The DOM fixtures are hand-maintained, and guarded. A test scrapes every getElementById('...') id out of each template's script block and asserts the fixture provides it, so a renamed or newly added control fails loudly instead of silently going untested.

Timers run on a virtual clock. The 1s poll loop and the 5s running-flag reset fire in the correct relative order without the tests waiting on them. The whole suite takes about half a second.

Coverage

  • continuous mode analyzes a new frame while the controls are disabled — this is the regression
  • continuous mode applies focus/coma/M1 corrections when connected, and none when not
  • continuous mode keeps polling but does not re-analyze the same frame
  • continuous mode picks up each new frame as it arrives
  • the MMIRS layout (no #mode selector) omits mode= from the analyze URL; a layout with one passes it through
  • starting continuous backs the gains off to 0.2/0.5, and Turbo leaves them alone
  • stopping continuous restores the gains, re-enables the controls, and halts the loop
  • the cwfs Latest button loads the two newest frames and analyzes them

Validation

Run against the pre-fix templates (7bb3450), 7 of the 12 fail, including every continuous mode test. The 5 that pass are the ones that don't depend on the bug — gains, stop, cwfs Latest, and the two fixture guards. All 12 pass on current master, on node 22 and node 26.

Scope

Node is only needed to run these tests. The served page still has no build step, tox.ini and the pixi config are untouched, and nothing here ships in the wheel. Browser-level behavior — bootstrap, mpl.js, websockets — remains uncovered; that would need Playwright and a much heavier CI job.

🤖 Generated with Claude Code

the continuous mode regression was a browser-side bug in code that had
no test coverage at all, so nothing caught it before it reached the
telescope. add a small jsdom suite covering the control logic.

the javascript is read out of the .html templates rather than copied
into the tests, so the suite always exercises what the server actually
serves. the dom fixtures are maintained by hand and guarded by a test
that checks every element the template script reaches for is present,
so a renamed or added control fails loudly instead of going untested.

timers are driven by a virtual clock, so the 1s poll loop and the 5s
running-flag reset happen in the right order without the tests waiting
on them. the whole suite runs in about half a second.

verified against the pre-fix templates: 7 of the 12 tests fail there,
including every continuous mode test, and all 12 pass on current
master.

node is only needed to run these tests. the served page still has no
build step, and tox and pixi are untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.71%. Comparing base (aed2c63) to head (cf5c340).

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #24   +/-   ##
=======================================
  Coverage   32.71%   32.71%           
=======================================
  Files           2        2           
  Lines         590      590           
=======================================
  Hits          193      193           
  Misses        397      397           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

the js tests are invisible to anyone reading CLAUDE.md for the dev
commands, and how a change actually reaches the summit was written down
nowhere. worth recording that it installs from master with pip, so a fix
sitting on a branch or in a working checkout is not deployed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

2 participants