Skip to content

Comments

test(lsp): add tests for diagnostics on didOpen|didChange|didSave#16466

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-03-test_lsp_add_tests_for_diagnostics_on_didopen_didchange_didsave_
Dec 3, 2025
Merged

test(lsp): add tests for diagnostics on didOpen|didChange|didSave#16466
graphite-app[bot] merged 1 commit intomainfrom
12-03-test_lsp_add_tests_for_diagnostics_on_didopen_didchange_didsave_

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Dec 3, 2025

This PR adds comprehensive test coverage for diagnostic functionality in the Language Server Protocol (LSP) implementation, specifically testing diagnostics on didOpen, didChange, and didSave events. The changes include both unit tests for the worker module and integration tests for the backend

along with a bug fix in the did_save handler.

This is not really a bug fix, just a little refactoring to pass the tests.
In general, I do not expect that params.text (didSave) has changed from didChange content

@github-actions github-actions bot added A-editor Area - Editor and Language Server C-test Category - Testing. Code is missing test cases, or a PR is adding them labels Dec 3, 2025
Copy link
Member Author

Sysix commented Dec 3, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive test coverage for diagnostic functionality in the Language Server Protocol (LSP) implementation, specifically testing diagnostics on didOpen, didChange, and didSave events. The changes include both unit tests for the worker module and integration tests for the backend, along with a bug fix in the did_save handler.

Key Changes

  • Added unit tests for run_diagnostic, run_diagnostic_on_change, and run_diagnostic_on_save methods in the worker module
  • Added integration tests verifying diagnostic publishing on didOpen, didChange, and didSave LSP events
  • Fixed bug in did_save handler to pass actual text content instead of None when available

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/oxc_language_server/src/worker.rs Added three unit tests (test_run_diagnostic, test_run_diagnostic_on_change, test_run_diagnostic_on_save) that verify the diagnostic collection methods work correctly with and without content
crates/oxc_language_server/src/tests.rs Added three FakeTool methods for diagnostic testing and three integration tests (test_diagnostic_on_open, test_diagnostic_on_change, test_no_diagnostic_on_save) that verify end-to-end diagnostic publishing behavior
crates/oxc_language_server/src/backend.rs Fixed did_save handler to pass params.text.as_deref() instead of None, ensuring saved file content is available for diagnostics

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Sysix Sysix force-pushed the 12-03-test_lsp_add_tests_for_diagnostics_on_didopen_didchange_didsave_ branch from ee2e7c4 to b920607 Compare December 3, 2025 19:10
@Sysix Sysix marked this pull request as ready for review December 3, 2025 19:16
@Sysix Sysix requested a review from camc314 as a code owner December 3, 2025 19:16
@Sysix Sysix force-pushed the 12-03-test_lsp_add_tests_for_diagnostics_on_didopen_didchange_didsave_ branch from b920607 to 7fd08de Compare December 3, 2025 19:27
@Sysix Sysix force-pushed the 12-03-test_lsp_add_tests_for_diagnostics_on_didopen_didchange_didsave_ branch from 7fd08de to f6a8a66 Compare December 3, 2025 21:49
@camc314 camc314 self-assigned this Dec 3, 2025
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 3, 2025
Copy link
Contributor

camc314 commented Dec 3, 2025

Merge activity

…16466)

> This PR adds comprehensive test coverage for diagnostic functionality in the Language Server Protocol (LSP) implementation, specifically testing diagnostics on didOpen, didChange, and didSave events. The changes include both unit tests for the worker module and integration tests for the backend

>  along with a bug fix in the did_save handler.

This is not really a bug fix, just a little refactoring to pass the tests.
In general, I do not expect that `params.text (didSave)` has changed from `didChange` content
@graphite-app graphite-app bot force-pushed the 12-03-test_lsp_add_tests_for_diagnostics_on_didopen_didchange_didsave_ branch from f6a8a66 to 5dfde85 Compare December 3, 2025 22:27
@graphite-app graphite-app bot merged commit 5dfde85 into main Dec 3, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 12-03-test_lsp_add_tests_for_diagnostics_on_didopen_didchange_didsave_ branch December 3, 2025 22:32
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 3, 2025
taearls pushed a commit to taearls/oxc that referenced this pull request Dec 11, 2025
…xc-project#16466)

> This PR adds comprehensive test coverage for diagnostic functionality in the Language Server Protocol (LSP) implementation, specifically testing diagnostics on didOpen, didChange, and didSave events. The changes include both unit tests for the worker module and integration tests for the backend

>  along with a bug fix in the did_save handler.

This is not really a bug fix, just a little refactoring to pass the tests.
In general, I do not expect that `params.text (didSave)` has changed from `didChange` content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-editor Area - Editor and Language Server C-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants