mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-10 22:41:14 +00:00
refactor: improve test resilience and code readability
- Use expect.objectContaining in tests for better resilience to future option additions - Extract showTextDocument options to named constant for improved readability - Addresses Copilot review feedback on PR #5282
This commit is contained in:
parent
99e7febd5f
commit
18dcd17bc9
2 changed files with 10 additions and 3 deletions
|
|
@ -503,8 +503,9 @@ export class DiffViewProvider {
|
|||
|
||||
// Pre-open the file as a text document to ensure it doesn't open in preview mode
|
||||
// This fixes issues with files that have custom editor associations (like markdown preview)
|
||||
const showOptions = { preview: false, viewColumn: vscode.ViewColumn.Active, preserveFocus: true }
|
||||
vscode.window
|
||||
.showTextDocument(uri, { preview: false, viewColumn: vscode.ViewColumn.Active, preserveFocus: true })
|
||||
.showTextDocument(uri, showOptions)
|
||||
.then(() => {
|
||||
// Execute the diff command after ensuring the file is open as text
|
||||
return vscode.commands.executeCommand(
|
||||
|
|
|
|||
|
|
@ -176,7 +176,13 @@ describe("DiffViewProvider", () => {
|
|||
// Mock showTextDocument to track when it's called
|
||||
vi.mocked(vscode.window.showTextDocument).mockImplementation(async (uri, options) => {
|
||||
callOrder.push("showTextDocument")
|
||||
expect(options).toEqual({ preview: false, viewColumn: vscode.ViewColumn.Active, preserveFocus: true })
|
||||
expect(options).toEqual(
|
||||
expect.objectContaining({
|
||||
preview: false,
|
||||
viewColumn: vscode.ViewColumn.Active,
|
||||
preserveFocus: true,
|
||||
}),
|
||||
)
|
||||
return mockEditor as any
|
||||
})
|
||||
|
||||
|
|
@ -211,7 +217,7 @@ describe("DiffViewProvider", () => {
|
|||
// Verify that showTextDocument was called with preview: false
|
||||
expect(vscode.window.showTextDocument).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ fsPath: `${mockCwd}/test.md` }),
|
||||
{ preview: false, viewColumn: vscode.ViewColumn.Active, preserveFocus: true },
|
||||
expect.objectContaining({ preview: false, viewColumn: vscode.ViewColumn.Active, preserveFocus: true }),
|
||||
)
|
||||
|
||||
// Verify that the diff command was executed
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue