mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:24:33 +00:00
test: dedupe validate-turns identity cases
This commit is contained in:
@@ -10,23 +10,31 @@ function asMessages(messages: unknown[]): AgentMessage[] {
|
|||||||
return messages as AgentMessage[];
|
return messages as AgentMessage[];
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("validateGeminiTurns", () => {
|
describe("validate turn edge cases", () => {
|
||||||
it("should return empty array unchanged", () => {
|
it("returns empty array unchanged", () => {
|
||||||
const result = validateGeminiTurns([]);
|
expect(validateGeminiTurns([])).toEqual([]);
|
||||||
expect(result).toEqual([]);
|
expect(validateAnthropicTurns([])).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return single message unchanged", () => {
|
it("returns single message unchanged", () => {
|
||||||
const msgs = asMessages([
|
const geminiMsgs = asMessages([
|
||||||
{
|
{
|
||||||
role: "user",
|
role: "user",
|
||||||
content: "Hello",
|
content: "Hello",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const result = validateGeminiTurns(msgs);
|
const anthropicMsgs = asMessages([
|
||||||
expect(result).toEqual(msgs);
|
{
|
||||||
|
role: "user",
|
||||||
|
content: [{ type: "text", text: "Hello" }],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
expect(validateGeminiTurns(geminiMsgs)).toEqual(geminiMsgs);
|
||||||
|
expect(validateAnthropicTurns(anthropicMsgs)).toEqual(anthropicMsgs);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("validateGeminiTurns", () => {
|
||||||
it("should leave alternating user/assistant unchanged", () => {
|
it("should leave alternating user/assistant unchanged", () => {
|
||||||
const msgs = asMessages([
|
const msgs = asMessages([
|
||||||
{ role: "user", content: "Hello" },
|
{ role: "user", content: "Hello" },
|
||||||
@@ -123,22 +131,6 @@ describe("validateGeminiTurns", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("validateAnthropicTurns", () => {
|
describe("validateAnthropicTurns", () => {
|
||||||
it("should return empty array unchanged", () => {
|
|
||||||
const result = validateAnthropicTurns([]);
|
|
||||||
expect(result).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should return single message unchanged", () => {
|
|
||||||
const msgs = asMessages([
|
|
||||||
{
|
|
||||||
role: "user",
|
|
||||||
content: [{ type: "text", text: "Hello" }],
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
const result = validateAnthropicTurns(msgs);
|
|
||||||
expect(result).toEqual(msgs);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should return alternating user/assistant unchanged", () => {
|
it("should return alternating user/assistant unchanged", () => {
|
||||||
const msgs = asMessages([
|
const msgs = asMessages([
|
||||||
{ role: "user", content: [{ type: "text", text: "Question" }] },
|
{ role: "user", content: [{ type: "text", text: "Question" }] },
|
||||||
|
|||||||
Reference in New Issue
Block a user