mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: specify session export content
This commit is contained in:
@@ -119,18 +119,15 @@ describe("buildSessionEntry", () => {
|
||||
fsSync.writeFileSync(filePath, jsonlLines.join("\n"));
|
||||
|
||||
const entry = requireSessionEntry(await buildSessionEntry(filePath));
|
||||
// The content should have 3 lines (3 message records)
|
||||
const contentLines = entry.content.split("\n");
|
||||
expect(contentLines).toHaveLength(3);
|
||||
expect(contentLines[0]).toContain("User: Hello world");
|
||||
expect(contentLines[1]).toContain("Assistant: Hi there");
|
||||
expect(contentLines[2]).toContain("User: Tell me a joke");
|
||||
expect(entry.content).toBe(
|
||||
"User: Hello world\nAssistant: Hi there, how can I help?\nUser: Tell me a joke",
|
||||
);
|
||||
|
||||
// lineMap should map each content line to its original JSONL line (1-indexed)
|
||||
// Content line 0 → JSONL line 4 (the first user message)
|
||||
// Content line 1 → JSONL line 6 (the assistant message)
|
||||
// Content line 2 → JSONL line 7 (the second user message)
|
||||
expect(entry.lineMap).toEqual([4, 6, 7]);
|
||||
expect(entry.lineMap).toStrictEqual([4, 6, 7]);
|
||||
});
|
||||
|
||||
it("returns empty lineMap when no messages are found", async () => {
|
||||
@@ -170,10 +167,10 @@ describe("buildSessionEntry", () => {
|
||||
|
||||
// Usage-counted archives (reset, deleted) must surface real content so
|
||||
// post-reset memory_search can recover prior session history.
|
||||
expect(resetEntry.content).toContain("User: Archived hello");
|
||||
expect(resetEntry.lineMap).toEqual([1]);
|
||||
expect(deletedEntry.content).toContain("User: Archived hello");
|
||||
expect(deletedEntry.lineMap).toEqual([1]);
|
||||
expect(resetEntry.content).toBe("User: Archived hello");
|
||||
expect(resetEntry.lineMap).toStrictEqual([1]);
|
||||
expect(deletedEntry.content).toBe("User: Archived hello");
|
||||
expect(deletedEntry.lineMap).toStrictEqual([1]);
|
||||
|
||||
// .bak and compaction checkpoints remain opaque pre-archive / snapshot
|
||||
// artifacts and stay empty so they do not get double-indexed.
|
||||
@@ -240,7 +237,7 @@ describe("buildSessionEntry", () => {
|
||||
fsSync.writeFileSync(filePath, jsonlLines.join("\n"));
|
||||
|
||||
const entry = requireSessionEntry(await buildSessionEntry(filePath));
|
||||
expect(entry.lineMap).toEqual([3, 5]);
|
||||
expect(entry.lineMap).toStrictEqual([3, 5]);
|
||||
});
|
||||
|
||||
it("strips inbound metadata when a user envelope is split across text blocks", async () => {
|
||||
@@ -296,6 +293,6 @@ describe("buildSessionEntry", () => {
|
||||
|
||||
const entry = requireSessionEntry(await buildSessionEntry(filePath));
|
||||
expect(entry.content).toBe("Assistant: User-facing summary.\nUser: Actual user follow-up.");
|
||||
expect(entry.lineMap).toEqual([2, 3]);
|
||||
expect(entry.lineMap).toStrictEqual([2, 3]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user