mirror of
https://github.com/cline/cline.git
synced 2026-09-19 02:05:44 +08:00
fix(test): stub telemetry helpers in unit-test @cline/core mock
Mirror the integration-test fix from bf147b939 in apps/vscode/src/test/requires.ts so the unit-test @cline/core mock also exposes `createClineTelemetryServiceConfig` and `createConfiguredTelemetryHandle`. Currently only marketplace-filtering.test.ts constructs a Controller, but any future unit test that does so would hit the same `TypeError: createClineTelemetryServiceConfig is not a function` and these two shims should stay in sync.
This commit is contained in:
@@ -20,6 +20,22 @@ Module.prototype.require = function (path: string) {
|
||||
// so requiring SDK adapter modules would otherwise make Mocha fall back to native
|
||||
// ESM loading and bypass tsconfig-paths aliases such as @shared/*.
|
||||
if (path === "@cline/core") {
|
||||
const createNoopTelemetry = () => ({
|
||||
setDistinctId() {},
|
||||
setMetadata() {},
|
||||
updateMetadata() {},
|
||||
setCommonProperties() {},
|
||||
updateCommonProperties() {},
|
||||
isEnabled: () => false,
|
||||
capture() {},
|
||||
captureRequired() {},
|
||||
recordCounter() {},
|
||||
recordHistogram() {},
|
||||
recordGauge() {},
|
||||
flush: async () => {},
|
||||
dispose: async () => {},
|
||||
})
|
||||
|
||||
class ProviderSettingsManager {
|
||||
private state = { providers: {}, lastUsedProvider: undefined }
|
||||
|
||||
@@ -41,6 +57,23 @@ Module.prototype.require = function (path: string) {
|
||||
}
|
||||
|
||||
return {
|
||||
createClineTelemetryServiceConfig: (config: Record<string, unknown> = {}) => ({
|
||||
enabled: false,
|
||||
metadata: {
|
||||
extension_version: "test",
|
||||
cline_type: "test",
|
||||
platform: "test",
|
||||
platform_version: "test",
|
||||
os_type: "test",
|
||||
os_version: "test",
|
||||
},
|
||||
...config,
|
||||
}),
|
||||
createConfiguredTelemetryHandle: () => ({
|
||||
telemetry: createNoopTelemetry(),
|
||||
flush: async () => {},
|
||||
dispose: async () => {},
|
||||
}),
|
||||
ClineCore: class {
|
||||
static async create() {
|
||||
return new this()
|
||||
|
||||
Reference in New Issue
Block a user