Skip to content

Commit fd2df21

Browse files
committed
fix(codecov): cover telemetry guard branch, exempt CT-only fixtures
1 parent ff9abb6 commit fd2df21

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

codecov.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ flag_management:
4242
- packages/core/src/
4343
carryforward: true
4444

45+
ignore:
46+
# Playwright CT-only fixtures/helpers: exercised by the webview-ui-ct flag's browser run, not
47+
# Vitest, and excluded from that flag's own lcov by playwright-ct.config.ts's sourceFilter (same
48+
# ".visual." match). Without this, patch coverage sees 0% for these paths on any PR that adds or
49+
# touches one, since no flag's lcov contains them.
50+
- "webview-ui/src/**/*.visual.fixture.tsx"
51+
- "webview-ui/src/**/*.visual.i18n.ts"
52+
4553
component_management:
4654
individual_components:
4755
- component_id: webview_components

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,4 +1929,34 @@ describe("webviewMessageHandler - telemetrySetting", () => {
19291929
const calls = vi.mocked(TelemetryService.instance.updateTelemetryState).mock.calls
19301930
expect(calls.at(-1)).toEqual([false])
19311931
})
1932+
1933+
// CodeRabbit finding: webviewDidLaunch's queued telemetry update called
1934+
// TelemetryService.instance directly, unlike the "telemetrySetting" case a few lines
1935+
// below which checks hasInstance() first. If webviewDidLaunch fires before the service
1936+
// is created (e.g. during activation), TelemetryService.instance throws -- and since
1937+
// this whole chain isn't awaited by the "webviewDidLaunch" case, that throw becomes an
1938+
// unhandled promise rejection instead of a no-op.
1939+
it("does not throw or update telemetry state when webviewDidLaunch fires before TelemetryService exists", async () => {
1940+
const { TelemetryService } = await import("@roo-code/telemetry")
1941+
vi.mocked(TelemetryService.hasInstance).mockReturnValue(false)
1942+
1943+
vi.mocked(mockClineProvider.contextProxy.getValue).mockReturnValue("unset")
1944+
vi.mocked(mockClineProvider.customModesManager.getCustomModes).mockResolvedValue([])
1945+
const providerForLaunch = mockClineProvider as unknown as {
1946+
getMcpHub: ReturnType<typeof vi.fn>
1947+
providerSettingsManager: { listConfig: ReturnType<typeof vi.fn> }
1948+
getStateToPostToWebview: ReturnType<typeof vi.fn>
1949+
}
1950+
providerForLaunch.getMcpHub = vi.fn().mockReturnValue(undefined)
1951+
providerForLaunch.providerSettingsManager = { listConfig: vi.fn().mockResolvedValue(undefined) }
1952+
providerForLaunch.getStateToPostToWebview = vi.fn().mockResolvedValue({ telemetrySetting: "unset" })
1953+
1954+
await expect(webviewMessageHandler(mockClineProvider, { type: "webviewDidLaunch" })).resolves.not.toThrow()
1955+
1956+
// The queued telemetry update is fire-and-forget from the handler's own point of
1957+
// view -- flush a microtask turn so its .then() callback runs before asserting.
1958+
await Promise.resolve()
1959+
1960+
expect(TelemetryService.instance.updateTelemetryState).not.toHaveBeenCalled()
1961+
})
19321962
})

0 commit comments

Comments
 (0)