mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:50:43 +00:00
test: keep voice-call runtime tests on public seams
This commit is contained in:
@@ -20,8 +20,7 @@ const mocks = vi.hoisted(() => ({
|
||||
realtimeHandlerRegisterToolHandler: vi.fn(),
|
||||
realtimeHandlerSetPublicUrl: vi.fn(),
|
||||
resolveConfiguredRealtimeVoiceProvider: vi.fn(),
|
||||
getActiveMemorySearchManager: vi.fn(),
|
||||
memorySearch: vi.fn(),
|
||||
resolveRealtimeFastContextConsult: vi.fn(),
|
||||
startTunnel: vi.fn(),
|
||||
setupTailscaleExposure: vi.fn(),
|
||||
cleanupTailscaleExposure: vi.fn(),
|
||||
@@ -74,6 +73,10 @@ vi.mock("./realtime-voice.runtime.js", () => ({
|
||||
resolveConfiguredRealtimeVoiceProvider: mocks.resolveConfiguredRealtimeVoiceProvider,
|
||||
}));
|
||||
|
||||
vi.mock("./realtime-fast-context.js", () => ({
|
||||
resolveRealtimeFastContextConsult: mocks.resolveRealtimeFastContextConsult,
|
||||
}));
|
||||
|
||||
vi.mock("./webhook/realtime-handler.js", () => ({
|
||||
RealtimeCallHandler: class {
|
||||
constructor(...args: unknown[]) {
|
||||
@@ -84,10 +87,6 @@ vi.mock("./webhook/realtime-handler.js", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/memory-host-search", () => ({
|
||||
getActiveMemorySearchManager: mocks.getActiveMemorySearchManager,
|
||||
}));
|
||||
|
||||
vi.mock("./tunnel.js", () => ({
|
||||
startTunnel: mocks.startTunnel,
|
||||
}));
|
||||
@@ -155,14 +154,8 @@ describe("createVoiceCallRuntime lifecycle", () => {
|
||||
provider: { id: "openai" },
|
||||
providerConfig: { model: "gpt-realtime" },
|
||||
});
|
||||
mocks.getActiveMemorySearchManager.mockReset();
|
||||
mocks.memorySearch.mockReset();
|
||||
mocks.getActiveMemorySearchManager.mockResolvedValue({
|
||||
manager: {
|
||||
search: mocks.memorySearch,
|
||||
},
|
||||
});
|
||||
mocks.memorySearch.mockResolvedValue([]);
|
||||
mocks.resolveRealtimeFastContextConsult.mockReset();
|
||||
mocks.resolveRealtimeFastContextConsult.mockResolvedValue({ handled: false });
|
||||
mocks.startTunnel.mockResolvedValue(null);
|
||||
mocks.setupTailscaleExposure.mockResolvedValue(null);
|
||||
mocks.cleanupTailscaleExposure.mockResolvedValue(undefined);
|
||||
@@ -499,16 +492,12 @@ describe("createVoiceCallRuntime lifecycle", () => {
|
||||
to: "+15550009999",
|
||||
transcript: [],
|
||||
});
|
||||
mocks.memorySearch.mockResolvedValue([
|
||||
{
|
||||
source: "memory",
|
||||
path: "MEMORY.md",
|
||||
startLine: 12,
|
||||
endLine: 14,
|
||||
score: 0.91,
|
||||
snippet: "The caller's basement lights are on.",
|
||||
mocks.resolveRealtimeFastContextConsult.mockResolvedValue({
|
||||
handled: true,
|
||||
result: {
|
||||
text: "Fast OpenClaw memory or session context found.\nThe caller's basement lights are on.",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
await createVoiceCallRuntime({
|
||||
config,
|
||||
@@ -528,10 +517,19 @@ describe("createVoiceCallRuntime lifecycle", () => {
|
||||
text: expect.stringContaining("The caller's basement lights are on."),
|
||||
},
|
||||
);
|
||||
expect(mocks.memorySearch).toHaveBeenCalledWith("Are the basement lights on?", {
|
||||
maxResults: 2,
|
||||
expect(mocks.resolveRealtimeFastContextConsult).toHaveBeenCalledWith({
|
||||
cfg: {},
|
||||
agentId: "main",
|
||||
args: { question: "Are the basement lights on?" },
|
||||
config: {
|
||||
enabled: true,
|
||||
fallbackToConsult: false,
|
||||
maxResults: 2,
|
||||
sources: ["memory"],
|
||||
timeoutMs: 800,
|
||||
},
|
||||
logger: expect.any(Object),
|
||||
sessionKey: "voice:15550001234",
|
||||
sources: ["memory"],
|
||||
});
|
||||
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user