Menu
popagent
publicLatest change 7f0ff66d6d9fb6468416c58bee46bd3d08169501 - Checkpoint browser channels and memory work by AkurAI Build
import { beforeAll, describe, expect, test } from "bun:test";
import { BrowserProfileStore } from "./browser-profiles";
const store = new BrowserProfileStore();
beforeAll(() => store.init());
describe("BrowserProfileStore", () => {
test("encrypts profile state and returns metadata without plaintext", async () => {
const marker = `profile-${crypto.randomUUID()}`;
const state = { cookies: [], origins: [{ origin: "https://example.com", localStorage: [{ name: "marker", value: marker }] }] };
const profile = await store.create({ name: marker, enabled: true, state });
try {
expect(profile).toMatchObject({ name: marker, enabled: true });
expect(JSON.stringify(await store.list())).not.toContain("localStorage");
expect(await store.recallState(profile.id)).toEqual(state);
const ciphertext = await store.storage.db.one<{ text: string }>(
"SELECT encode(ciphertext, 'escape') AS text FROM popagent_secrets WHERE resource_id='popagent-browser' AND name=$1",
[`profile:${profile.id}`],
);
expect(ciphertext.text).not.toContain(marker);
} finally {
await store.delete(profile.id);
}
});
test("rejects malformed Playwright storage state", async () => {
await expect(store.create({ name: "invalid", enabled: false, state: { cookies: "not-an-array" } })).rejects.toThrow("storage state");
});
});