Skip to content

Commit e48a66e

Browse files
test(activate): restore the diagnostics wiring case 375e255 dropped
The 375e255 merge of upstream/main took this branch copy of src/activate/__tests__/registerCommands.spec.ts over mains and dropped ten upstream titles. The one that came back with nothing behind it was creates diagnostics from all provider instances without requiring a visible provider: the head tree tested createDiagnosticsReport itself in src/services/diagnostics/__tests__/command.spec.ts, always with providers: [], and never asserted what the command handler passes to it. This commit restores that case. The handler hands every live instance to the report builder and never consults the visible provider (registerCommands.ts:249-254), so the case pins the wiring: two instances, no visible instance, and a payload of context, outputChannel and exactly those providers. Control run: changing the handler to read providers: ClineProvider.getVisibleInstance() ? ClineProvider.getAllInstances() : [] makes the case fail on the payload (providers [] against the two instances); with the handler as written it passes. Baseline whole registerCommands.spec.ts on d19bb3f was 60 passed, after the change 61 passed, target 1 passed. tsc -p tsconfig.json clean, eslint --max-warnings=0 --no-warn-ignored clean on the file with src/eslint-suppressions.json untouched, prettier --check clean. The other title 375e255 dropped from this file group, postMessageToWebview does not throw when webview is disposed, is deliberately not rewritten here: src/core/webview/__tests__/ClineProvider.spec.ts:3317 already contains that exact body - the same disposal mock, the same message, the same await expect(provider.postMessageToWebview(message)).resolves.toBeUndefined() at line 3327 - plus a stronger assertion on the dropped-message log, and spec:8608 covers the disposed-view early return. Duplicating it would have added a copy without adding a pin. Hook note: this commit ran the husky pre-commit hook for real - no --no-verify. The hook execs lint-staged through npx and lint-staged runs pnpm --dir src exec eslint, so the PATH used for the commit was extended with the npm global bin directory that carries pnpm (pnpm --version resolves to the pinned 10.8.1 there); without it this lane has no pnpm and the hook would have been skipped rather than run.
1 parent d19bb3f commit e48a66e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎src/activate/__tests__/registerCommands.spec.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ vi.mock("../../i18n", () => ({
9494
t: (key: string) => key,
9595
}))
9696

97+
vi.mock("../../services/diagnostics", () => ({
98+
createDiagnosticsReport: vi.fn(),
99+
}))
100+
97101
vi.mock("../../services/ripgrep/diagnostic", () => ({
98102
registerRipgrepDiagnosticCommand: vi.fn().mockReturnValue({ dispose: vi.fn() }),
99103
}))
@@ -198,6 +202,25 @@ describe("registerCommands handlers", () => {
198202
})
199203
})
200204

205+
it("creates diagnostics from all provider instances without requiring a visible provider", async () => {
206+
// Restores the case 375e25546 dropped when it took this branch copy of the spec over
207+
// main's. The command handler hands every live instance to the report builder and never
208+
// consults the visible provider (registerCommands.ts:249-254), so a report still forms when
209+
// no view is visible; the payload assertion is what pins that wiring.
210+
const { createDiagnosticsReport } = await import("../../services/diagnostics")
211+
const providers = [{}, {}]
212+
;(ClineProvider.getAllInstances as Mock).mockReturnValue(providers)
213+
;(ClineProvider.getVisibleInstance as Mock).mockReturnValue(undefined)
214+
215+
await handlers["zoo-code.createDiagnosticsReport"]()
216+
217+
expect(createDiagnosticsReport).toHaveBeenCalledWith({
218+
context: mockContext,
219+
outputChannel: mockOutputChannel,
220+
providers,
221+
})
222+
})
223+
201224
it.each([false, true])("retries the appropriate provider when a visible provider exists: %s", async (visible) => {
202225
vi.mocked(ClineProvider.getVisibleInstance).mockReturnValue(visible ? mockVisibleProviderInstance : undefined)
203226
await handlers["zoo-code.retryWebviewRecovery"]()

0 commit comments

Comments
 (0)