-
Notifications
You must be signed in to change notification settings - Fork 509
Ghost Provider Tests #1336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ghost Provider Tests #1336
Conversation
b8aad83
to
d9a7766
Compare
|
8222db0
to
339529d
Compare
00fb7eb
to
d244e8f
Compare
Introduce a comprehensive mock testing framework to simulate the VS Code editor and workspace environments. This allows for isolated and deterministic unit testing of services that rely on VS Code APIs. The new framework includes: - `MockTextDocument`: Simulates document content, line/range operations. - `MockTextEditor`: Encapsulates a document with cursor position. - `MockWorkspace`: Manages a collection of mock documents. - `MockWorkspaceEdit`: Simulates applying edits to the workspace. This infrastructure will be used to build out robust tests for Ghost, autocomplete, and other editor-aware services.
d244e8f
to
469ab35
Compare
This commit introduces a robust testing framework for the Ghost feature, centered around a new `MockWorkspace` that simulates the VS Code environment. This allows for isolated unit testing of the suggestion parsing and application logic. The new test suite, `GhostProvider.spec.ts`, validates various scenarios: - Simple line additions and deletions - Mixed addition/deletion operations - Complex diffs with multiple change hunks - Sequential application of individual suggestions A minor fix is also included in `GhostStrategy.ts` to handle file path URI parsing more robustly, ensuring that paths are correctly converted to URIs whether or not they already have a `file://` prefix.
469ab35
to
a6735bd
Compare
* feat: enable Ghost Writer and add i18n for Ghost features This commit enables the Ghost Writer feature by uncommenting its registration in `extension.ts`. It also introduces internationalization (i18n) support for all Ghost Writer related strings across multiple languages, including progress messages, input prompts, commands, and chat participant details. The `package.json` is updated to include new commands, keybindings, code actions, and chat participant declarations for the Ghost Writer. The `GhostCodeActionProvider`, `GhostModel`, and `GhostProvider` classes are updated to use the new i18n strings and to properly initialize the `GhostProvider` with the extension context. The `GhostStrategy` is also updated to incorporate custom instructions into the system prompt. * Ghost Suggestion Navigation (#1304) * refactor: remove chat api definition * feat: ghost navigation * Update src/services/ghost/GhostProvider.ts Co-authored-by: Copilot <[email protected]> * feat: CodeLens indicator * refactor: fix commands names * refactor(ghost): rename haveSuggestions to hasSuggestions Renames the `haveSuggestions` method and related context key to `hasSuggestions` for improved clarity and consistency. This change affects the GhostProvider, GhostSuggestions, and the `package.json` and `extension.json` files where the context key is used. --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Chris Hasson <[email protected]> * Ghost fuzzy matching diff filenames (#1315) * refactor: implement fuzzy matching * refactor: implement fuzzy matching with relative path * fix(ghost): update file names in patch to use matched URI string * Ghost prevent race conditions (#1329) * refactor: fix codelens ranges, lock workspaces edits, update commands * refactor: add translations of the new cmds * refactor: move the cursor to follow the suggestions * refactor: update the pending suggestion when we applied a single op group * refactor: update the pending suggestion when we applied a single op group * refactor: ghost render when active editor change * refactor: correct typo in compute operations offset method * refactor: simplify GhostProvider method calls Removed unnecessary explicit object destructuring in method calls for `provideCodeSuggestions` and `enhanceContext` to improve readability and conciseness. Also removed redundant progress report messages. --------- Co-authored-by: Chris Hasson <[email protected]> * refactor: fix delete lines recalculation * Ghost Provider Tests (#1336) * test(testing): add mock editor and workspace framework for services Introduce a comprehensive mock testing framework to simulate the VS Code editor and workspace environments. This allows for isolated and deterministic unit testing of services that rely on VS Code APIs. The new framework includes: - `MockTextDocument`: Simulates document content, line/range operations. - `MockTextEditor`: Encapsulates a document with cursor position. - `MockWorkspace`: Manages a collection of mock documents. - `MockWorkspaceEdit`: Simulates applying edits to the workspace. This infrastructure will be used to build out robust tests for Ghost, autocomplete, and other editor-aware services. * test(ghost): add comprehensive test suite for ghost provider This commit introduces a robust testing framework for the Ghost feature, centered around a new `MockWorkspace` that simulates the VS Code environment. This allows for isolated unit testing of the suggestion parsing and application logic. The new test suite, `GhostProvider.spec.ts`, validates various scenarios: - Simple line additions and deletions - Mixed addition/deletion operations - Complex diffs with multiple change hunks - Sequential application of individual suggestions A minor fix is also included in `GhostStrategy.ts` to handle file path URI parsing more robustly, ensuring that paths are correctly converted to URIs whether or not they already have a `file://` prefix. * refactor: wip tests * refactor: fix all existing tests * refactor: fix random suggestion apply * refactor(ghost): update default model to stable gemini-2.5-flash * refactor: simplify the logic of apply changes * refactor: fix triple slash * fix: fix workspace edit lock * Switch GhostProvider tests to be file based --------- Co-authored-by: Chris Hasson <[email protected]> Co-authored-by: Catriel Müller <[email protected]> * refactor: fix tests * refactor: fix tests tabs * refactor: fix merge json format * refactor: try to fix windows test errors * Add changeset --------- Co-authored-by: Chris Hasson <[email protected]> Co-authored-by: Catriel Müller <[email protected]> Co-authored-by: Copilot <[email protected]>
Add tests- some don't pass but I think they have the right expectations!
cd $WORKSPACE_ROOT/src && npx vitest run services/ghost/__tests__/GhostProvider.spec.ts