Skip to content

test(editor): move the editor's own suites into the package and close the testable seam - #2891

Merged
datlechin merged 8 commits into
mainfrom
refactor/editor-test-seam
Sep 15, 2026
Merged

datlechin merged 8 commits into
mainfrom
refactor/editor-test-seam

Conversation

@datlechin

Copy link
Copy Markdown
Member

Stacked on #2886.

Thirteen files in TableProTests reached into the editor with @testable import, which is the
seam a package boundary is supposed to remove: anything the app's tests can only say by opening
the module is either a test that belongs inside the package, or API the package should have.

Afterwards there are zero @testable imports of TableProEditorKit or TableProTextEngine
outside the package, and exactly one symbol was promoted.

Nine suites moved into the package

They test the editor and never mention an app type, so they belong with the editor. They also run
in swift test, which is seconds, instead of behind a full app build.

Moved to What it tests
TableProEditorKitTests/SyntaxHighlightingTests grammar captures, query compilation, token colours
TableProEditorKitTests/Controller/EditorPeripheralSurfaceTests gutter hit-testing, trailing insets, filter parity across languages
TableProEditorKitTests/Controller/EditorKeyMonitorCompositionTests the key monitor during IME composition
TableProEditorKitTests/Controller/LongLineScrollTests scroll position across a long-line paste and undo
TableProEditorKitTests/GutterHighlightTests the line-number highlight at the end of a document
TableProEditorKitTests/LargePasteTests a large paste and the completion trigger
TableProEditorKitTests/Highlighting/PasteHighlightCancelTests a cancelled tree-sitter edit invalidating the right range
TableProEditorKitTests/SourceEditorDismantleTests dismantleNSViewController destroying each coordinator once
TableProTextEngineTests/TypesetterWrapLengthTests wrapped fragment lengths

Two of those were carved out of app suites that do need the app: SyntaxHighlightingTests left
its ThemeEngine case behind as EditorThemeBridgeTests, and EditorLifecycleTeardownTests kept
everything about SQLEditorCoordinator and WorkspacePanes.

One promotion, and two tests rewritten instead

  • EmphasisManager.toolTip(at:) is now public. An emphasis owns its tool tip and AppKit only ever
    asks the owner, so this is the only way anything outside the manager can read what the editor
    would show under the pointer. The app-side diagnostics test was reaching textView and
    toolTips separately to hand-roll it.
  • QueryDiagnosticsRefreshTests built a TextBindingSync and a RepresentableSyncPhase to push
    text the way SourceEditor's binding does. That plumbing is the package's, and
    SourceEditorBindingSyncTests already covers it in twelve cases; what the app test is actually
    for is that a second replacement re-checks, which setText says directly.
  • RemoveInvisibleCharactersCommandTests asserted isApplyingUnfilteredEdits == false to mean
    "the filters are back on". That only says a flag was cleared. It now types a bracket and expects
    the pair, which is the filters actually running.

Two fixes the move surfaced

  • Mock.loadedTextViewController defaults to wrapLines: false. A wrapped editor cannot scroll
    horizontally, so the long-line suite measured nothing once it took the package's fixture.
  • LineFoldChunkBoundaryTests waits for an async calculation on the main actor with a deadline
    that turns a hang into a failure. Five seconds was enough for that target before; with the
    editor's own suites in it, it was not. The deadline is 60 seconds now; the loop still exits the
    moment the condition holds.

Verification

  • swift test --package-path Packages/TableProEditor --force-resolved-versions: 336 engine cases
    and 145 kit cases, 0 failures (was 333 and 102).
  • xcodebuild build-for-testing: 0 errors, so nothing in the app's test target needed the seam.
  • verify.sh test over the five app suites this touched: 24 of 24 pass.
  • swiftlint lint --strict: 0 violations.

No CHANGELOG entry: tests only.

…package

# Conflicts:
#	CLAUDE.md
#	LocalPackages/CodeEditTextView/Sources/CodeEditTextView/CodeEditTextView.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/Controller/TextViewController+TextViewDelegate.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/Controller/TextViewController+ToggleComment.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/Extensions/NSRange+/NSRange+InputEdit.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/Extensions/TextView+/TextView+Point.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/Extensions/TextView+/TextView+TextFormation.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/Extensions/TextView+/TextView+createReadBlock.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/Filters/DeleteWhitespaceFilter.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/Find/PanelView/FindPanelView.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/Find/ViewModel/FindPanelViewModel+Replace.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/Find/ViewModel/FindPanelViewModel.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/SourceEditor/SourceEditor+Coordinator.swift
#	Packages/TableProEditor/Sources/TableProEditorKit/TextViewCoordinator/CombineCoordinator.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/CaptureModifierSetTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/CodeEditSourceEditorTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/Controller/TextViewController+IndentTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/Controller/TextViewController+MoveLinesTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/Controller/TextViewControllerTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/FindPanelTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/GutterNumberOffsetTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/Highlighting/StyledRangeContainerTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/Highlighting/VisibleRangeProviderTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldAccessibilityTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldChunkBoundaryTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldCollapsePathTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldDocumentSwapTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldHoverTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldPlaceholderClickTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldRibbonLookupTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldStorageTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldingModelTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/RangeStoreTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/TreeSitterClientTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/AccessibilityTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/CmdUpAtEndOfDocumentTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/IMEInputTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/KillRingTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/LayoutManager/OverridingLayoutManagerRenderingTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/LayoutManager/TextLayoutManagerAttachmentsTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/LayoutManager/TextLayoutManagerTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/LineEndingTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/MarkedTextTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/NSBezierPathSmoothPathTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/NSTextInputRangeGuardTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/TextLayoutLineStorageTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/TextLineDisplayRangeTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/TextSelectionManagerTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/TextViewTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/TypesetterTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/VisualLineEndOfDocumentTests.swift
#	Packages/TableProEditor/Tests/TableProTextEngineTests/WordSelectionTests.swift
…seam

# Conflicts:
#	Packages/TableProEditor/Tests/TableProEditorKitTests/Controller/EditorPeripheralSurfaceTests.swift
#	Packages/TableProEditor/Tests/TableProEditorKitTests/SyntaxHighlightingTests.swift
#	TableProTests/Views/Editor/EditorControllerFixture.swift
#	TableProTests/Views/Editor/EditorLifecycleTeardownTests.swift
#	TableProTests/Views/Editor/QueryDiagnosticsRefreshTests.swift
#	TableProTests/Views/Editor/RemoveInvisibleCharactersCommandTests.swift
@datlechin
datlechin merged commit 9af73db into main Sep 15, 2026
8 of 9 checks passed
@datlechin
datlechin deleted the refactor/editor-test-seam branch September 15, 2026 08:45
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.

1 participant