Skip to content

Commit 66ba38c

Browse files
committed
Fix tests
1 parent 73b8bf5 commit 66ba38c

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/core/webview/__tests__/ClineProvider.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ import { safeWriteJson } from "../../../utils/safeWriteJson"
1818

1919
import { ClineProvider } from "../ClineProvider"
2020

21-
// Mock setup must come before imports
21+
// Mock setup must come before imports.
2222
vi.mock("../../prompts/sections/custom-instructions")
2323

24-
vi.mock("vscode")
25-
2624
vi.mock("p-wait-for", () => ({
2725
__esModule: true,
2826
default: vi.fn().mockResolvedValue(undefined),
@@ -96,7 +94,7 @@ vi.mock("../../../services/browser/browserDiscovery", () => ({
9694
testBrowserConnection: vi.fn(),
9795
}))
9896

99-
// Remove duplicate mock - it's already defined below
97+
// Remove duplicate mock - it's already defined below.
10098

10199
const mockAddCustomInstructions = vi.fn().mockResolvedValue("Combined instructions")
102100

@@ -229,7 +227,6 @@ vi.mock("../../../integrations/misc/extract-text", () => ({
229227
}),
230228
}))
231229

232-
// Mock getModels for router model tests
233230
vi.mock("../../../api/providers/fetchers/modelCache", () => ({
234231
getModels: vi.fn().mockResolvedValue({}),
235232
flushModels: vi.fn(),
@@ -325,6 +322,10 @@ vi.mock("@roo-code/cloud", () => ({
325322
},
326323
},
327324
getRooCodeApiUrl: vi.fn().mockReturnValue("https://app.roocode.com"),
325+
ORGANIZATION_ALLOW_ALL: {
326+
allowAll: true,
327+
providers: {},
328+
},
328329
}))
329330

330331
afterAll(() => {

src/core/webview/__tests__/ClineProvider.sticky-mode.spec.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { ContextProxy } from "../../config/ContextProxy"
77
import { Task } from "../../task/Task"
88
import type { HistoryItem, ProviderName } from "@roo-code/types"
99

10-
// Mock setup
1110
vi.mock("vscode", () => ({
1211
ExtensionContext: vi.fn(),
1312
OutputChannel: vi.fn(),
@@ -54,7 +53,8 @@ vi.mock("vscode", () => ({
5453
},
5554
version: "1.85.0",
5655
}))
57-
// Create a counter for unique task IDs
56+
57+
// Create a counter for unique task IDs.
5858
let taskIdCounter = 0
5959

6060
vi.mock("../../task/Task", () => ({
@@ -75,8 +75,11 @@ vi.mock("../../task/Task", () => ({
7575
parentTask: options.parentTask,
7676
})),
7777
}))
78+
7879
vi.mock("../../prompts/sections/custom-instructions")
80+
7981
vi.mock("../../../utils/safeWriteJson")
82+
8083
vi.mock("../../../api", () => ({
8184
buildApiHandler: vi.fn().mockReturnValue({
8285
getModel: vi.fn().mockReturnValue({
@@ -85,19 +88,22 @@ vi.mock("../../../api", () => ({
8588
}),
8689
}),
8790
}))
91+
8892
vi.mock("../../../integrations/workspace/WorkspaceTracker", () => ({
8993
default: vi.fn().mockImplementation(() => ({
9094
initializeFilePaths: vi.fn(),
9195
dispose: vi.fn(),
9296
})),
9397
}))
98+
9499
vi.mock("../../diff/strategies/multi-search-replace", () => ({
95100
MultiSearchReplaceDiffStrategy: vi.fn().mockImplementation(() => ({
96101
getToolDescription: () => "test",
97102
getName: () => "test-strategy",
98103
applyDiff: vi.fn(),
99104
})),
100105
}))
106+
101107
vi.mock("@roo-code/cloud", () => ({
102108
CloudService: {
103109
hasInstance: vi.fn().mockReturnValue(true),
@@ -108,7 +114,12 @@ vi.mock("@roo-code/cloud", () => ({
108114
},
109115
},
110116
getRooCodeApiUrl: vi.fn().mockReturnValue("https://app.roocode.com"),
117+
ORGANIZATION_ALLOW_ALL: {
118+
allowAll: true,
119+
providers: {},
120+
},
111121
}))
122+
112123
vi.mock("../../../shared/modes", () => ({
113124
modes: [
114125
{
@@ -132,27 +143,33 @@ vi.mock("../../../shared/modes", () => ({
132143
}),
133144
defaultModeSlug: "code",
134145
}))
146+
135147
vi.mock("../../prompts/system", () => ({
136148
SYSTEM_PROMPT: vi.fn().mockResolvedValue("mocked system prompt"),
137149
codeMode: "code",
138150
}))
151+
139152
vi.mock("../../../api/providers/fetchers/modelCache", () => ({
140153
getModels: vi.fn().mockResolvedValue({}),
141154
flushModels: vi.fn(),
142155
}))
156+
143157
vi.mock("../../../integrations/misc/extract-text", () => ({
144158
extractTextFromFile: vi.fn().mockResolvedValue("Mock file content"),
145159
}))
160+
146161
vi.mock("p-wait-for", () => ({
147162
default: vi.fn().mockImplementation(async () => Promise.resolve()),
148163
}))
164+
149165
vi.mock("fs/promises", () => ({
150166
mkdir: vi.fn().mockResolvedValue(undefined),
151167
writeFile: vi.fn().mockResolvedValue(undefined),
152168
readFile: vi.fn().mockResolvedValue(""),
153169
unlink: vi.fn().mockResolvedValue(undefined),
154170
rmdir: vi.fn().mockResolvedValue(undefined),
155171
}))
172+
156173
vi.mock("@roo-code/telemetry", () => ({
157174
TelemetryService: {
158175
hasInstance: vi.fn().mockReturnValue(true),

0 commit comments

Comments
 (0)