diff --git a/src/lib/__tests__/lore.test.ts b/src/lib/__tests__/lore.test.ts index 727185c..9060ad1 100644 --- a/src/lib/__tests__/lore.test.ts +++ b/src/lib/__tests__/lore.test.ts @@ -4,7 +4,6 @@ import dotenv from "dotenv"; import { createRuntime } from "../../test/createRuntime"; import { composeContext } from "../context"; import { addLore, getLore } from "../lore"; -import { getRelationship } from "../../agents/cj/relationships"; import { BgentRuntime } from "../runtime"; import { requestHandlerTemplate } from "../templates"; import { type Content } from "../types"; @@ -14,22 +13,13 @@ describe("Lore", () => { const zeroUuid: UUID = "00000000-0000-0000-0000-000000000000"; let runtime: BgentRuntime; let user: User; - let room_id: UUID; beforeAll(async () => { const result = await createRuntime({ env: process.env as Record, }); runtime = result.runtime; - user = result.session.user; - - const data = await getRelationship({ - runtime, - userA: user?.id as UUID, - userB: zeroUuid, - }); - - room_id = data?.room_id; + user = result?.session?.user as User; }); beforeEach(async () => { @@ -52,8 +42,8 @@ describe("Lore", () => { runtime, source: "/Test.md", content: "Test", - user_id: user.id as UUID, - room_id, + user_id: zeroUuid, + room_id: zeroUuid, }); const lore = await getLore({ @@ -61,9 +51,8 @@ describe("Lore", () => { message: "Test", }); - expect(lore).toHaveLength(1); expect(lore[0].content).toEqual(content); - }); + }, 60000); // TODO: Test that the lore is in the context of the agent @@ -72,23 +61,20 @@ describe("Lore", () => { runtime, source: "Test Lore Source", content: "Test Lore Content", - user_id: user.id as UUID, - room_id, + user_id: zeroUuid as UUID, + room_id: zeroUuid, }); const message = { - senderId: user.id as UUID, + senderId: zeroUuid as UUID, agentId: zeroUuid, - userIds: [user.id as UUID, zeroUuid], - content: "Test", - room_id, + userIds: [zeroUuid], + content: "Test Lore Content", + room_id: zeroUuid, }; const state = await runtime.composeState(message); - // expect state.lore to exist - expect(state.lore).toHaveLength(1); - const context = composeContext({ state, template: requestHandlerTemplate, @@ -97,5 +83,5 @@ describe("Lore", () => { // expect context to contain 'Test Lore Source' and 'Test Lore Content' expect(context).toContain("Test Lore Source"); expect(context).toContain("Test Lore Content"); - }); + }, 60000); }); diff --git a/src/test/createRuntime.ts b/src/test/createRuntime.ts index 1fdafdf..c7bd5fa 100644 --- a/src/test/createRuntime.ts +++ b/src/test/createRuntime.ts @@ -19,9 +19,12 @@ export async function createRuntime({ evaluators?: Evaluator[]; actions?: Action[]; }) { - const supabase = createClient(SUPABASE_URL!, SUPABASE_ANON_KEY!); + const supabase = createClient( + env?.SUPABASE_URL ?? SUPABASE_URL, + env?.SUPABASE_SERVICE_API_KEY ?? SUPABASE_ANON_KEY, + ); - const { + let { data: { user, session }, } = await supabase.auth.signInWithPassword({ email: TEST_EMAIL!, @@ -29,7 +32,12 @@ export async function createRuntime({ }); if (!session) { - throw new Error("Session not found"); + const response = await supabase.auth.signUp({ + email: TEST_EMAIL!, + password: TEST_PASSWORD!, + }); + user = response.data.user; + session = response.data.session; } const runtime = new BgentRuntime({