AkurAI Build
Menu

popagent

public

Latest change 6edc7e928c57dab23c0973ed3f7ee70b3ebb72d5 - Initial popagent baseline by AkurAI Build

import { beforeAll, describe, expect, test } from "bun:test";
import { SessionStore } from "./sessions";

const store = new SessionStore();

beforeAll(() => store.init());

describe("SessionStore", () => {
  test("creates, lists, updates, and reloads sessions", async () => {
    const created = await store.create("cx/gpt-5.6-sol");

    expect(await store.list()).toContainEqual(
      expect.objectContaining({ id: created.id, title: "New chat", model: "cx/gpt-5.6-sol" }),
    );

    const messages = [
      { id: "user-1", role: "user", parts: [{ type: "text", text: "Plan a trip to Oslo" }] },
      { id: "assistant-1", role: "assistant", parts: [{ type: "text", text: "Sure." }] },
    ];
    await store.save(created.id, { model: "cx/gpt-5.6-sol", messages, expectedRevision: created.revision });

    expect(await store.get(created.id)).toEqual(
      expect.objectContaining({ id: created.id, title: "Plan a trip to Oslo", messages }),
    );
  });

  test("returns undefined for an unknown session", async () => {
    expect(await store.get("missing")).toBeUndefined();
  });
});