Skip to content

Unit test for TextDocumentSyncHandler - #662

Closed
Firehed wants to merge 2 commits into
mainfrom
text-document-sync-handler-unit-test
Closed

Firehed wants to merge 2 commits into
mainfrom
text-document-sync-handler-unit-test

Conversation

@Firehed

@Firehed Firehed commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #663. Fifth and last handler to get a real unit test, following the pattern from the four query handlers.

What changed

  • Adds a new TextDocumentSyncHandlerTest under tests/Handler/ that mocks the three interface collaborators. Unlike the query handlers this one mutates, so the test asserts on the collaborator calls each notification produces rather than on a return shape.
  • Removes integration cases now redundant with the new unit test (testSupports, and the testDidCloseInvalidatesTheOnDiskCacheSoTheNextQueryReReadsDisk case that already mocked the invalidator and asserted only on invalidate()).

🤖 Generated with Claude Code

Firehed and others added 2 commits September 30, 2026 17:41
Its setUp builds the full production symbol-knowledge stack and most of
its cases assert on the real SymbolSource state after dispatch. The
filename now matches what the test is.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Mocks DocumentManagerInterface, SymbolSinkInterface, and InvalidatableInterface.
Unlike the four query handlers, this one mutates: the test asserts on the
collaborator calls each notification produces rather than on a return
shape.

- didOpen: documentManager.open(uri, lang, version, text), then
  symbols.openDocument with the document the manager returns from get().
- didChange: documentManager.update(uri, lastText, version), then
  symbols.updateDocument. Empty contentChanges short-circuits.
- didClose: symbols.closeDocument(uri), invalidator.invalidate(uri),
  documentManager.close(uri). The invalidator drop is why the next
  on-disk query re-reads disk rather than the pre-edit value.

Also drops two integration tests the unit test now covers identically:
testSupports and testDidCloseInvalidatesTheOnDiskCacheSoTheNextQueryReReadsDisk
(the latter already mocked the invalidator and asserted only on the
invalidate() call).

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

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.73%. Comparing base (1fc769f) to head (b3db5bb).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #662   +/-   ##
=========================================
  Coverage     99.73%   99.73%           
  Complexity     1903     1903           
=========================================
  Files           136      136           
  Lines          4882     4882           
=========================================
  Hits           4869     4869           
  Misses           13       13           

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

@Firehed
Firehed changed the base branch from main to text-document-sync-handler-rename October 1, 2026 00:46
@Firehed
Firehed marked this pull request as ready for review October 1, 2026 00:47
Base automatically changed from text-document-sync-handler-rename to main October 1, 2026 00:48
@Firehed

Firehed commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Rebase conflicted after #663 merged. Replaced by a fresh branch; new PR coming.

@Firehed Firehed closed this Oct 1, 2026
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