Add javascript tests for the template control logic - #24
Open
tepickering wants to merge 2 commits into
Open
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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>
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.
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.htmlandcwfs.html, run by node's built-in test runner.wfssrv/tests/js/harness.js— mounts a template's control script in jsdom with a stubbedfetchand a virtual clockwfssrv/tests/js/controls.test.js— 12 testspackage.json/package-lock.json— one devDependency,jsdom.github/workflows/js-tests.yml— runsnpm ci && npm teston node 22 and 24CLAUDE.md— documents how to run the JS suite, plus a Deployment section recording that the summit installs from GitHubmaster(pip install git+... --upgradeinto itsmmtwfsconda env), so a fix is not deployed until it is pushed tomasterDesign notes
The javascript is read out of the templates, not copied. The harness pulls the inline
<script>block that definescontrolButtonsout of the.htmlfile 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
#modeselector) omitsmode=from the analyze URL; a layout with one passes it throughValidation
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.iniand 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