Skip to content

Commit e09e1bf

Browse files
author
easonLiangWorldedtech
committed
test(view-state): read the recorded update calls through vi.mocked so check-types accepts them
mockContext.globalState.update is typed by the vscode ExtensionContext signature, not as a vitest Mock, so .mock.calls failed zoo-code#check-types (TS2339 plus an implicit any on the filter parameter). Wrapping in vi.mocked keeps the assertion identical and typed. Local run: 255 tests pass in ClineProvider.spec.ts, eslint clean. Note that local tsc cannot catch this class of error: the shared node_modules junction has no real vscode typings, so those members resolve to any locally.
1 parent 224ff2d commit e09e1bf

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,7 +4538,9 @@ describe("ClineProvider", () => {
45384538
// writes the shared global mode. Reject any write to the shared "mode" key,
45394539
// whatever value it carries - a write of "ask" would satisfy a value-specific check.
45404540
expect(provider["viewLocalState"].mode).toBe("code")
4541-
expect(mockContext.globalState.update.mock.calls.filter((call) => call[0] === "mode")).toHaveLength(0)
4541+
expect(
4542+
vi.mocked(mockContext.globalState.update).mock.calls.filter((call) => call[0] === "mode"),
4543+
).toHaveLength(0)
45424544
expect(logSpy).toHaveBeenCalledWith(
45434545
"Mode 'non-existent-mode' from history no longer exists. Falling back to default mode 'code'.",
45444546
)
@@ -4612,7 +4614,9 @@ describe("ClineProvider", () => {
46124614

46134615
// Verify mode was preserved view-locally: no write to the shared "mode" key at all.
46144616
expect(provider["viewLocalState"].mode).toBe("custom-mode")
4615-
expect(mockContext.globalState.update.mock.calls.filter((call) => call[0] === "mode")).toHaveLength(0)
4617+
expect(
4618+
vi.mocked(mockContext.globalState.update).mock.calls.filter((call) => call[0] === "mode"),
4619+
).toHaveLength(0)
46164620
expect(logSpy).not.toHaveBeenCalledWith(expect.stringContaining("no longer exists"))
46174621

46184622
// Verify history item mode was not changed
@@ -4661,7 +4665,9 @@ describe("ClineProvider", () => {
46614665

46624666
// Verify mode was preserved view-locally: no write to the shared "mode" key at all.
46634667
expect(provider["viewLocalState"].mode).toBe("architect")
4664-
expect(mockContext.globalState.update.mock.calls.filter((call) => call[0] === "mode")).toHaveLength(0)
4668+
expect(
4669+
vi.mocked(mockContext.globalState.update).mock.calls.filter((call) => call[0] === "mode"),
4670+
).toHaveLength(0)
46654671

46664672
// Verify history item mode was not changed
46674673
expect(historyItem.mode).toBe("architect")

0 commit comments

Comments
 (0)