(test): run the shipped app.js code in five replica tests (#171) - #403
Conversation
indexing-banner, confirm-and-stop-session, open-session-terminal, search-perf and running-indicators asserted against a copy of the logic written in the test, so a change to public/app.js could not fail them. They now load the real functions through test/app-source.js into the jsdom window of dom-setup.js, and each goes red when the production line it guards is broken. Closes #171
|
Reviewing |
|
Adversarial review at |
The regex-literal skipper had no end-of-input guard and ignored [...] classes and keyword-led regexes. It now throws on an unterminated regex, and every extracted slice is compiled and checked to end at a line break, so a scanner mistake fails loudly naming the function instead of loading a truncated one. Unit tests cover the synthetic cases. Refs #171
|
Re-review at |
Closes #171
Five test files asserted against a copy of the logic written inside the test, so
public/app.jswas never loaded and a change to the real functions could not turn them red. They now run the shipped code.What changed
test/app-source.js(new):loadAppFunctions(context, { functions, declarations })cuts the named top-level functions and one-linelet/constdeclarations out ofpublic/app.jsand evaluates them in the jsdom window thatsetupSidebarDom()builds.app.jsitself still cannot be evaluated whole.test/dom-setup.js:setupSidebarDom()also returns the VMcontext.session-activity.js,sidebar.js,stop-session-ui.js,utils.jsin the same window:indexing-banner.test.js:updateIndexingBanner,dismissIndexingBannerconfirm-and-stop-session.test.js:confirmAndStopSessionopen-session-terminal.test.js:openSessionsearch-perf.test.js:clearSearch,resetSearchFilter,runSearchQueryrunning-indicators.test.js:updateRunningIndicatorsdialogs.jspin stays..ai/shared-guidelines.md: one line on how to test anapp.jsfunction.The replicas had already drifted:
openSessioninapp.jshasguardResume,forgetSessionExitandsyncPtySizeAfterOpenthat the mirror lacked, and the real search clear defers the rebuild to an animation frame.Tests only; no changelog entry (
no-changeloglabel).Proof
Each rewired file goes red when one line of production
public/app.jsis broken, and was green on the unmutated tree:public/app.jsindexingBannerDismissed = trueondone:trueif (false){ type: 'terminal' }for terminal sessionsclearSearchrAF callbackresort: falseif (item.dataset.subagent) return;Not verified
session-restore.test.jsanddom-sidebar-perf.test.jsstill carry partial inline mirrors ofapp.jslogic; they were not part of this change.