mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 06:31:24 +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();
|
||||
};
|
||||
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 {
|
||||
{
|
||||
@@ -241,11 +254,10 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {
|
||||
|
||||
const opts = (agentCommand.mock.calls[0] as unknown[] | undefined)?.[0];
|
||||
const message = (opts as { message?: string } | undefined)?.message ?? "";
|
||||
expect(message).toContain(HISTORY_CONTEXT_MARKER);
|
||||
expect(message).toContain("User: Hello, who are you?");
|
||||
expect(message).toContain("Assistant: I am Claude.");
|
||||
expect(message).toContain(CURRENT_MESSAGE_MARKER);
|
||||
expect(message).toContain("User: What did I just ask you?");
|
||||
expectMessageContext(message, {
|
||||
history: ["User: Hello, who are you?", "Assistant: I am Claude."],
|
||||
current: ["User: What did I just ask you?"],
|
||||
});
|
||||
await res.text();
|
||||
}
|
||||
|
||||
@@ -301,11 +313,10 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {
|
||||
|
||||
const opts = (agentCommand.mock.calls[0] as unknown[] | undefined)?.[0];
|
||||
const message = (opts as { message?: string } | undefined)?.message ?? "";
|
||||
expect(message).toContain(HISTORY_CONTEXT_MARKER);
|
||||
expect(message).toContain("User: What's the weather?");
|
||||
expect(message).toContain("Assistant: Checking the weather.");
|
||||
expect(message).toContain(CURRENT_MESSAGE_MARKER);
|
||||
expect(message).toContain("Tool: Sunny, 70F.");
|
||||
expectMessageContext(message, {
|
||||
history: ["User: What's the weather?", "Assistant: Checking the weather."],
|
||||
current: ["Tool: Sunny, 70F."],
|
||||
});
|
||||
await res.text();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user