Skip to content

chore: add integration test for workspace/textDocumentContent - #2981

Open
rwols wants to merge 6 commits into
mainfrom
chore/integration-test-textdocumentcontent
Open

chore: add integration test for workspace/textDocumentContent#2981
rwols wants to merge 6 commits into
mainfrom
chore/integration-test-textdocumentcontent

Conversation

@rwols

@rwols rwols commented Jul 6, 2026

Copy link
Copy Markdown
Member

This teaches our fake server in tests/server.py to execute a server->client request when receiving a command. With this, we can set up an integration test that makes the fake server do a window/showDocument request when receiving a workspace/executeCommand request. In turn, that will then cause the client to make a workspace/textDocumentContent request.

So the request flow is:

  1. Client->Server: workspace/executeCommand
  2. Server->Client: window/showDocument
  3. Client->Server: workspace/textDocumentContent
  4. server resolves workspace/textDocumentContent
  5. client resolves window/showDocument
  6. server resolves workspace/executeCommand

I also ported along the $test/getAndClearUnusedMockResponses method, but that remains unused for now.

Comment thread tests/setup.py Outdated
self.session.send_request(Request("$test/setResponses", payload), handler, error_handler)
yield from self.await_promise(promise)

def mock_command_action(self, command_name: str, action: LSPObject) -> Generator:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can probably use ServerRequest type for action.
If not then create a more generic type that takes method and params keys.

Comment thread tests/server.py
Comment thread tests/server.py
@rwols
rwols requested a review from rchl July 15, 2026 16:48
Comment thread tests/setup.py Outdated
self.session.send_request(Request("$test/setResponses", payload), handler, error_handler)
yield from self.await_promise(promise)

def mock_command_action(self, command_name: str, action: ServerRequest) -> Generator:

@rchl rchl Jul 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wouldn't call it "mocking". That would be more when we would force some response without going through the server. Maybe set_command_response_action would be more consistent with other server methods. Or just set_command_response.

@rwols
rwols requested a review from rchl August 1, 2026 19:35
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.

2 participants