mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:58:26 +00:00
test(gateway): dedupe openai context assertions
This commit is contained in:
@@ -120,6 +120,19 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {
|
|||||||
);
|
);
|
||||||
await res.text();
|
await res.text();
|
||||||
};
|
};
|
||||||
|
const expectMessageContext = (
|
||||||
|
message: string,
|
||||||
|
expected: { history: string[]; current: string[] },
|
||||||
|
) => {
|
||||||
|
expect(message).toContain(HISTORY_CONTEXT_MARKER);
|
||||||
|
for (const line of expected.history) {
|
||||||
|
expect(message).toContain(line);
|
||||||
|
}
|
||||||
|
expect(message).toContain(CURRENT_MESSAGE_MARKER);
|
||||||
|
for (const line of expected.current) {
|
||||||
|
expect(message).toContain(line);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
{
|
{
|
||||||
@@ -241,11 +254,10 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {
|
|||||||
|
|
||||||
const opts = (agentCommand.mock.calls[0] as unknown[] | undefined)?.[0];
|
const opts = (agentCommand.mock.calls[0] as unknown[] | undefined)?.[0];
|
||||||
const message = (opts as { message?: string } | undefined)?.message ?? "";
|
const message = (opts as { message?: string } | undefined)?.message ?? "";
|
||||||
expect(message).toContain(HISTORY_CONTEXT_MARKER);
|
expectMessageContext(message, {
|
||||||
expect(message).toContain("User: Hello, who are you?");
|
history: ["User: Hello, who are you?", "Assistant: I am Claude."],
|
||||||
expect(message).toContain("Assistant: I am Claude.");
|
current: ["User: What did I just ask you?"],
|
||||||
expect(message).toContain(CURRENT_MESSAGE_MARKER);
|
});
|
||||||
expect(message).toContain("User: What did I just ask you?");
|
|
||||||
await res.text();
|
await res.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,11 +313,10 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {
|
|||||||
|
|
||||||
const opts = (agentCommand.mock.calls[0] as unknown[] | undefined)?.[0];
|
const opts = (agentCommand.mock.calls[0] as unknown[] | undefined)?.[0];
|
||||||
const message = (opts as { message?: string } | undefined)?.message ?? "";
|
const message = (opts as { message?: string } | undefined)?.message ?? "";
|
||||||
expect(message).toContain(HISTORY_CONTEXT_MARKER);
|
expectMessageContext(message, {
|
||||||
expect(message).toContain("User: What's the weather?");
|
history: ["User: What's the weather?", "Assistant: Checking the weather."],
|
||||||
expect(message).toContain("Assistant: Checking the weather.");
|
current: ["Tool: Sunny, 70F."],
|
||||||
expect(message).toContain(CURRENT_MESSAGE_MARKER);
|
});
|
||||||
expect(message).toContain("Tool: Sunny, 70F.");
|
|
||||||
await res.text();
|
await res.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user