evOo-local/packages/memory/src/index.test.ts
cynarAI 6c7eed7580 Initial clean evOo-local from f00577b
Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline
(Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/*
packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
2026-09-20 17:15:16 +02:00

50 lines
1.5 KiB
TypeScript

import type { AdapterContext } from "@rakazo/adapter-kit";
import { describe, expect, it, vi } from "vitest";
import { MarkdownMemoryStore } from "./index.js";
const context: AdapterContext = {
operationId: "read-memory",
traceId: "read-memory",
spaceId: "workspace-1",
userId: "user-1",
signal: new AbortController().signal,
};
describe("memory store contract shape", () => {
it("declares markdown portability", () => {
const store = new MarkdownMemoryStore({} as never);
expect(store.describe().capabilities.markdownPortable).toBe(true);
});
it("reads the most recently updated documents first", async () => {
const updatedAt = new Date("2026-08-16T10:00:00.000Z");
const findMany = vi
.fn()
.mockResolvedValue([
{ id: "memory-1", path: "facts.md", content: "A fact", revision: 3, updatedAt },
]);
const store = new MarkdownMemoryStore({ memoryDocument: { findMany } } as never);
await expect(store.read({ scope: "bot", botId: "bot-1" }, context)).resolves.toEqual({
documents: [
{
id: "memory-1",
path: "facts.md",
content: "A fact",
revision: 3,
updatedAt: updatedAt.toISOString(),
},
],
});
expect(findMany).toHaveBeenCalledWith({
where: {
spaceId: "workspace-1",
userId: "user-1",
scope: "bot",
botId: "bot-1",
},
orderBy: [{ updatedAt: "desc" }, { path: "asc" }],
});
});
});