test(telemetry): improve mock isolation for runner and index tests
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { afterEach, describe, expect, it, mock } from "bun:test"
|
import { afterEach, describe, expect, it, mock } from "bun:test"
|
||||||
|
|
||||||
|
async function* createEmptyEventStream(): AsyncIterable<unknown> {}
|
||||||
|
|
||||||
describe("run telemetry isolation", () => {
|
describe("run telemetry isolation", () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
mock.restore()
|
mock.restore()
|
||||||
@@ -13,20 +15,11 @@ describe("run telemetry isolation", () => {
|
|||||||
mock.module("./agent-resolver", () => ({
|
mock.module("./agent-resolver", () => ({
|
||||||
resolveRunAgent: mock(() => "Sisyphus - Ultraworker"),
|
resolveRunAgent: mock(() => "Sisyphus - Ultraworker"),
|
||||||
}))
|
}))
|
||||||
mock.module("./events", () => ({
|
|
||||||
createEventState: mock(() => ({
|
|
||||||
messageCount: 0,
|
|
||||||
lastPartText: "Run completed",
|
|
||||||
agentColorsByName: {},
|
|
||||||
})),
|
|
||||||
processEvents: mock(async () => {}),
|
|
||||||
serializeError: (error: unknown) => (error instanceof Error ? error.message : String(error)),
|
|
||||||
}))
|
|
||||||
mock.module("./server-connection", () => ({
|
mock.module("./server-connection", () => ({
|
||||||
createServerConnection: mock(async () => ({
|
createServerConnection: mock(async () => ({
|
||||||
client: {
|
client: {
|
||||||
event: {
|
event: {
|
||||||
subscribe: mock(async () => ({ stream: {} })),
|
subscribe: mock(async () => ({ stream: createEmptyEventStream() })),
|
||||||
},
|
},
|
||||||
session: {
|
session: {
|
||||||
promptAsync: mock(async () => undefined),
|
promptAsync: mock(async () => undefined),
|
||||||
|
|||||||
@@ -95,7 +95,14 @@ function installModuleMocks(): void {
|
|||||||
startBackgroundCheck: mock(() => {}),
|
startBackgroundCheck: mock(() => {}),
|
||||||
}))
|
}))
|
||||||
mock.module("./tools/lsp/client", () => ({
|
mock.module("./tools/lsp/client", () => ({
|
||||||
lspManager: {},
|
lspManager: {
|
||||||
|
getClient: mock(async () => ({
|
||||||
|
diagnostics: mock(async () => ({ items: [] })),
|
||||||
|
})),
|
||||||
|
stopAll: mock(async () => {}),
|
||||||
|
releaseClient: mock(() => {}),
|
||||||
|
cleanupTempDirectoryClients: mock(async () => {}),
|
||||||
|
},
|
||||||
}))
|
}))
|
||||||
mock.module("./shared/posthog", () => ({
|
mock.module("./shared/posthog", () => ({
|
||||||
createPluginPostHog: mockCreatePluginPostHog,
|
createPluginPostHog: mockCreatePluginPostHog,
|
||||||
|
|||||||
Reference in New Issue
Block a user