mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:01:23 +00:00
test: move embedded and tool agent suites out of e2e
This commit is contained in:
62
src/agents/pi-embedded-subscribe.code-span-awareness.test.ts
Normal file
62
src/agents/pi-embedded-subscribe.code-span-awareness.test.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
createStubSessionHarness,
|
||||
emitAssistantTextDelta,
|
||||
} from "./pi-embedded-subscribe.e2e-harness.js";
|
||||
import { subscribeEmbeddedPiSession } from "./pi-embedded-subscribe.js";
|
||||
|
||||
describe("subscribeEmbeddedPiSession thinking tag code span awareness", () => {
|
||||
function createPartialReplyHarness() {
|
||||
const { session, emit } = createStubSessionHarness();
|
||||
const onPartialReply = vi.fn();
|
||||
|
||||
subscribeEmbeddedPiSession({
|
||||
session,
|
||||
runId: "run",
|
||||
onPartialReply,
|
||||
});
|
||||
|
||||
return { emit, onPartialReply };
|
||||
}
|
||||
|
||||
it("does not strip thinking tags inside inline code backticks", () => {
|
||||
const { emit, onPartialReply } = createPartialReplyHarness();
|
||||
|
||||
emitAssistantTextDelta({
|
||||
emit,
|
||||
delta: "The fix strips leaked `<thinking>` tags from messages.",
|
||||
});
|
||||
|
||||
expect(onPartialReply).toHaveBeenCalled();
|
||||
const lastCall = onPartialReply.mock.calls[onPartialReply.mock.calls.length - 1];
|
||||
expect(lastCall[0].text).toContain("`<thinking>`");
|
||||
});
|
||||
|
||||
it("does not strip thinking tags inside fenced code blocks", () => {
|
||||
const { emit, onPartialReply } = createPartialReplyHarness();
|
||||
|
||||
emitAssistantTextDelta({
|
||||
emit,
|
||||
delta: "Example:\n ````\n<thinking>code example</thinking>\n ````\nDone.",
|
||||
});
|
||||
|
||||
expect(onPartialReply).toHaveBeenCalled();
|
||||
const lastCall = onPartialReply.mock.calls[onPartialReply.mock.calls.length - 1];
|
||||
expect(lastCall[0].text).toContain("<thinking>code example</thinking>");
|
||||
});
|
||||
|
||||
it("still strips actual thinking tags outside code spans", () => {
|
||||
const { emit, onPartialReply } = createPartialReplyHarness();
|
||||
|
||||
emitAssistantTextDelta({
|
||||
emit,
|
||||
delta: "Hello <thinking>internal thought</thinking> world",
|
||||
});
|
||||
|
||||
expect(onPartialReply).toHaveBeenCalled();
|
||||
const lastCall = onPartialReply.mock.calls[onPartialReply.mock.calls.length - 1];
|
||||
expect(lastCall[0].text).not.toContain("internal thought");
|
||||
expect(lastCall[0].text).toContain("Hello");
|
||||
expect(lastCall[0].text).toContain("world");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user