chore(tests): delete 14 source-text tests that no defect can fail - #433
Merged
Conversation
PathGao
force-pushed
the
chore/drop-tests-that-only-detect-renames
branch
from
August 3, 2026 09:11
2b5e7fe to
495336d
Compare
Measured against injected defects, these 14 files detect that a specific line was edited and nothing else. Each one stayed green while a real defect in its own stated subject was live; four of them are the only file that greps the line they pin, so the catch they do provide is the rename detector #418 rules out, not coverage. Four assertions inside them were the exception — they pin something no compiler can see (a Tauri command name, a locale's own dictionary entry, a CSS duration, an `async fn` whose absence only deadlocks on Windows). Those move into surviving files rather than being lost: findCollapsedMatches FOLD_TRANSITION_MS vs the styles.css transition -> foldLayout.test.ts toolbarCustomization two per-locale translation tests (they import and run the dictionary) -> i18nCoverage.test.ts windowsPdfExport invoke() name <-> generate_handler! registration -> macosPdfExport.test.ts tabContextMenuIsolation create_transfer_window must stay `async` -> windowOrganization.test.ts Five files from the same list are kept: each was measured to catch a real defect that nothing else catches. See the pull request for the per-file table. 562 -> 524 tests; 199 assertions removed, 5 tests added back by the salvage. Every mutation the suite caught before it still catches, including the three controls (sanitizer `<style>`, lossy-decode save guard, checkbox toggle line). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
PathGao
force-pushed
the
chore/drop-tests-that-only-detect-renames
branch
from
August 3, 2026 09:30
495336d to
47b9bd6
Compare
This was referenced Aug 3, 2026
PathGao
added a commit
that referenced
this pull request
Aug 3, 2026
Scroll sync had 23 assertions and no coverage. The defect that set the sync threshold to a value which disabled sync outright left every one of them green, because they read Editor.svelte as text; both files were deleted in #433, so the behaviour is currently untested. The cause is structural: `node --test` cannot import a `.svelte` file, so the only thing a test can do to logic living inside one is grep it. The two functions that decide where the other pane scrolls to are pure arithmetic — `getScrollSyncPositionFromPixels` and `getScrollTopForSyncPosition` read nothing but their arguments — so they can simply leave the component, the same move that produced `documentSession` and `windowSession`. They were also duplicated. Both functions plus their `clampScrollRatio` helper existed byte for byte in Editor.svelte and MarkdownViewer.svelte: two private copies of one formula, invisible to each other and to the compiler. Both call sites now import `src/lib/utils/scrollSync.ts`, whose body is the moved code verbatim apart from `export` (md5 of all three blocks, de-indented: 31ab3110). scripts/scrollSync.test.ts imports and runs it. The cases are stated as a mapping between two panes with different proportions — the editor spends 20% of its scroll range on front matter, the preview 10% — because that asymmetry is the reason the position carries a section instead of a single ratio. 13 injected defects, 13 caught, including both spellings of "sync does nothing". 540 -> 552 tests. Co-authored-by: PathGao <gaoyanbo@gaoyanbodeMacBook-Air.local> 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.
What this measures
node --testcannot import a.sveltefile, so anything asserted about a component can only be a regex over its source text. 19 files were nominated for deletion on the theory that such a test detects a rename and nothing else. I did not take the list on faith: every file was measured by injecting a real defect into its own stated subject and running the whole suite.14 are deleted. 5 are kept — each was measured to catch a real defect that nothing else catches. Four assertions from inside the deleted files were salvaged.
Deleted: the file stayed green with a real defect live
Each row is a defect injected into production code, with the whole suite run against it. "Also caught by" is the file that went red instead — where that column is empty, nothing in the suite noticed at all.
previewScrollSync5→100000(sync dead)previewScrollSync0findCollapsedMatchesrevealFoldsAroundmade a no-opfindCollapsedMatchesfoldToggleForalways returnsnulltoolbarCustomizationWiringreorderEditorToolbarToolmade a no-optoolbarCustomizationWiringreorderTitlebarToolbarActionmade a no-opinterruptedSessionRestoresessionRestoreResilienceinterruptedSessionRestorewindowStateRestoretaskToggleMemory===→>=)truncatedBufferGuardtaskToggleMemorydisabledrenderProtocolreloadOpenToolbarcanCloseTaband ignores the answerreloadOpenToolbarfmt-boldtoolbar action does nothingwindowsPdfExportawaitdropped frominvoke('export_pdf_windows')batchCloseConfirmationfrontMatterDisclosureviewerDisposalisDisposedguards removedpreviewRenderRevision||becomes&&tocEditorJumpopenMultipleFilestabContextMenuIsolationeditorOptionWiring*minimapandwordWrapsettings ignoredThe rows marked red need the qualifier that decides this PR. In each of them my edit landed on the exact line the file greps, so the file failed because a string moved, not because behaviour changed. That is the same mechanism that turns 2 tests red for renaming
revealFoldsAroundwhile 553 stay green for making it a no-op. It is detection of an edit, not of a defect — andsvelte-checkalready refuses an inconsistent rename, which is the only edit of that shape that is ever a bug.Where the injected defect avoided the greped line (
viewerDisposal,previewRenderRevision,batchCloseConfirmation,frontMatterDisclosure,tocEditorJump,reloadOpenToolbar,findCollapsedMatches), the file was green. That is every file in this list.*
editorOptionWiringappears here for context but is kept — see below.Kept: 5 of the 19, each with a defect only it catches
These were on the list. They should not have been. In each case the file caught something that is not a spelling pin, and nothing else in the suite caught it.
editorOptionWiringrenderWhitespacesites regresses to"trailing"count(...) === 2, so it catches creation andupdateOptionsdisagreeing — a class of bug, not a stringprintFindHighlightbackground-color: transparentbecomesdisplay: nonestyles.cssand a:global()rule inFindBar.svelte; no compiler does thisfoldLayoutstyles.cssfold wrapper reverts togrid-template-rows: 1frfoldLayout.ts(writes--fold-content-height) tostyles.css(consumes it) across filesscrollSyncInputwindowTagswindowTagdropped from the v2 window snapshot;pinnedforced trueThe table's premise for
windowTags— "Rust pinned-tag write made a no-op" — reproduces: makingsave_pinned_tag_atreturnOk(())leaves all 562 JS tests green. Butcargo testcatches it in three tests (window_runtime::tests), and the JS file's remaining value is the frontend half, which nothing else covers. Deleting it would open a real hole in a data-persistence path.Salvaged
Four assertions pinned something no compiler can see. They moved rather than died, and each was re-verified by mutation after the move.
windowsPdfExportinvoke('…pdf…')name inexport.tsis registered ingenerate_handler!and defined as a#[tauri::command]macosPdfExportexport_pdf_windowson the Rust side only → redtoolbarCustomizationWiringi18nCoveragemenu.mergeAllWindowsentry → redfindCollapsedMatchesFOLD_TRANSITION_MSoutlasts thestyles.cssheight transitionfoldLayout0.6s→ redtabContextMenuIsolationcreate_transfer_windowisasync fnwindowOrganizationasync→ redThe two i18n tests were the only behavioural code in
toolbarCustomizationWiring— they import the dictionary and look keys up in it.i18nCoveragedeliberately does not enforce per-locale completeness (19 locales are >100 keys short and failing on that would block every English string), so these keys needed to survive as the named exception: they label icon-only controls where the word carries the whole meaning.The PDF salvage reads the command names out of
export.tsinstead of restating them, so a renamed command is checked at its new name rather than quietly passing.Coverage holes this PR does not close
Deleting these files removes no detection, but it does remove the appearance of it. Four subjects now have no test at all, and each needs an executable one:
getScrollSyncPositionFromPixelsandgetScrollTopForSyncPositionare pure functions of three numbers, currently declared insideMarkdownViewer.svelteandEditor.sveltewhere nothing can import them. Moving the pair tosrc/lib/utils/scrollSync.tswould make the whole subject unit-testable, including both defects above.revealFoldsAround/foldToggleForinFindBar.svelte. These are DOM walks;foldMeasurementBatching.test.tsalready drivesobserveFoldLayoutthrough a recording stand-in for the DOM, and the same technique applies here.exportAsPdf.export.tsis importable and already covered behaviourally for HTML export (exportFoldParity,exportRichContent). The droppedawaitabove would be caught by an equivalent test with a stubbedinvoke/save.reloadFromDisk's dirty-buffer guard.documentSession.canCloseTabis covered behaviourally bytruncatedBufferGuard; the reload path that calls it is not, because it lives in the component.Verification
npm test524 pass / 0 fail (was 562);npm run check0 errors;npm run buildclean;cargo test144 pass.sessionRestoreResilience; snapshot discard →windowStateRestore; task marker →renderProtocol; fold heights →foldMeasurementBatching; fold styles →foldLayout; window tag →windowTags; whitespace →editorOptionWiring; cursor listener →scrollSyncInput; print highlight →printFindHighlight.<style>→exportSanitize+previewSanitize; lossy-decode save guard inverted →checkedReadMigration+externalChangeReload+pathIdentityCaseFolding+truncatedBufferGuard; checkbox toggle writes the wrong line →truncatedBufferGuard.scripts/sourceTree.tsis untouched — none of the deleted files imported it (its only consumers arepreviewSanitize,renderPipelineConventionandsingleImplementationConvention).package.json:test:settings-scrollis removed (both its files are gone);test:workflowsandtest:frontmatterdrop the deleted entries.🤖 Generated with Claude Code