Matt Rubens пре 11 месеци
родитељ
комит
70ad037016

+ 27 - 0
src/__mocks__/vscode.js

@@ -5,9 +5,25 @@ const vscode = {
 		createTextEditorDecorationType: jest.fn().mockReturnValue({
 			dispose: jest.fn(),
 		}),
+		tabGroups: {
+			onDidChangeTabs: jest.fn(() => {
+				return {
+					dispose: jest.fn(),
+				}
+			}),
+			all: [],
+		},
 	},
 	workspace: {
 		onDidSaveTextDocument: jest.fn(),
+		createFileSystemWatcher: jest.fn().mockReturnValue({
+			onDidCreate: jest.fn().mockReturnValue({ dispose: jest.fn() }),
+			onDidDelete: jest.fn().mockReturnValue({ dispose: jest.fn() }),
+			dispose: jest.fn(),
+		}),
+		fs: {
+			stat: jest.fn(),
+		},
 	},
 	Disposable: class {
 		dispose() {}
@@ -57,6 +73,17 @@ const vscode = {
 		Development: 2,
 		Test: 3,
 	},
+	FileType: {
+		Unknown: 0,
+		File: 1,
+		Directory: 2,
+		SymbolicLink: 64,
+	},
+	TabInputText: class {
+		constructor(uri) {
+			this.uri = uri
+		}
+	},
 }
 
 module.exports = vscode

+ 1 - 0
src/core/__tests__/Cline.test.ts

@@ -128,6 +128,7 @@ jest.mock("vscode", () => {
 			visibleTextEditors: [mockTextEditor],
 			tabGroups: {
 				all: [mockTabGroup],
+				onDidChangeTabs: jest.fn(() => ({ dispose: jest.fn() })),
 			},
 		},
 		workspace: {

+ 11 - 0
src/integrations/workspace/__tests__/WorkspaceTracker.test.ts

@@ -16,6 +16,12 @@ const mockWatcher = {
 }
 
 jest.mock("vscode", () => ({
+	window: {
+		tabGroups: {
+			onDidChangeTabs: jest.fn(() => ({ dispose: jest.fn() })),
+			all: [],
+		},
+	},
 	workspace: {
 		workspaceFolders: [
 			{
@@ -61,6 +67,7 @@ describe("WorkspaceTracker", () => {
 		expect(mockProvider.postMessageToWebview).toHaveBeenCalledWith({
 			type: "workspaceUpdated",
 			filePaths: expect.arrayContaining(["file1.ts", "file2.ts"]),
+			openedTabs: [],
 		})
 		expect((mockProvider.postMessageToWebview as jest.Mock).mock.calls[0][0].filePaths).toHaveLength(2)
 	})
@@ -74,6 +81,7 @@ describe("WorkspaceTracker", () => {
 		expect(mockProvider.postMessageToWebview).toHaveBeenCalledWith({
 			type: "workspaceUpdated",
 			filePaths: ["newfile.ts"],
+			openedTabs: [],
 		})
 	})
 
@@ -92,6 +100,7 @@ describe("WorkspaceTracker", () => {
 		expect(mockProvider.postMessageToWebview).toHaveBeenLastCalledWith({
 			type: "workspaceUpdated",
 			filePaths: [],
+			openedTabs: [],
 		})
 	})
 
@@ -106,6 +115,7 @@ describe("WorkspaceTracker", () => {
 		expect(mockProvider.postMessageToWebview).toHaveBeenCalledWith({
 			type: "workspaceUpdated",
 			filePaths: expect.arrayContaining(["newdir"]),
+			openedTabs: [],
 		})
 		const lastCall = (mockProvider.postMessageToWebview as jest.Mock).mock.calls.slice(-1)[0]
 		expect(lastCall[0].filePaths).toHaveLength(1)
@@ -126,6 +136,7 @@ describe("WorkspaceTracker", () => {
 		expect(mockProvider.postMessageToWebview).toHaveBeenCalledWith({
 			type: "workspaceUpdated",
 			filePaths: expect.arrayContaining(expectedFiles),
+			openedTabs: [],
 		})
 		expect(calls[0][0].filePaths).toHaveLength(1000)
 

+ 6 - 0
webview-ui/src/components/chat/__tests__/ChatTextArea.test.tsx

@@ -41,6 +41,7 @@ describe("ChatTextArea", () => {
 		// Default mock implementation for useExtensionState
 		;(useExtensionState as jest.Mock).mockReturnValue({
 			filePaths: [],
+			openedTabs: [],
 			apiConfiguration: {
 				apiProvider: "anthropic",
 			},
@@ -51,6 +52,7 @@ describe("ChatTextArea", () => {
 		it("should be disabled when textAreaDisabled is true", () => {
 			;(useExtensionState as jest.Mock).mockReturnValue({
 				filePaths: [],
+				openedTabs: [],
 			})
 
 			render(<ChatTextArea {...defaultProps} textAreaDisabled={true} />)
@@ -68,6 +70,7 @@ describe("ChatTextArea", () => {
 
 			;(useExtensionState as jest.Mock).mockReturnValue({
 				filePaths: [],
+				openedTabs: [],
 				apiConfiguration,
 			})
 
@@ -85,6 +88,7 @@ describe("ChatTextArea", () => {
 		it("should not send message when input is empty", () => {
 			;(useExtensionState as jest.Mock).mockReturnValue({
 				filePaths: [],
+				openedTabs: [],
 				apiConfiguration: {
 					apiProvider: "openrouter",
 				},
@@ -101,6 +105,7 @@ describe("ChatTextArea", () => {
 		it("should show loading state while enhancing", () => {
 			;(useExtensionState as jest.Mock).mockReturnValue({
 				filePaths: [],
+				openedTabs: [],
 				apiConfiguration: {
 					apiProvider: "openrouter",
 				},
@@ -123,6 +128,7 @@ describe("ChatTextArea", () => {
 			// Update apiConfiguration
 			;(useExtensionState as jest.Mock).mockReturnValue({
 				filePaths: [],
+				openedTabs: [],
 				apiConfiguration: {
 					apiProvider: "openrouter",
 					newSetting: "test",