File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed
Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1+ import { expect , test } from "vitest" ;
2+ import { components } from "./_generated/api.js" ;
3+ import { createThread } from "@convex-dev/agent" ;
4+ import { initConvexTest } from "./setup.test.js" ;
5+
6+ test ( "Agent createThread" , async ( ) => {
7+ const t = initConvexTest ( ) ;
8+
9+ const threadId = await t . run ( async ( ctx ) => {
10+ return await createThread ( ctx , components . agent , {
11+ title : "Hello, world!" ,
12+ } ) ;
13+ } ) ;
14+ const thread = await t . query ( components . agent . threads . getThread , {
15+ threadId,
16+ } ) ;
17+ expect ( thread ) . toMatchObject ( {
18+ title : "Hello, world!" ,
19+ } ) ;
20+ } ) ;
Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ import { api } from "./_generated/api.js";
66import type { Id } from "./_generated/dataModel.js" ;
77import { getMaxMessage } from "./messages.js" ;
88import schema from "./schema.js" ;
9- import { modules } from "./setup.test.js" ;
9+ import { initConvexTest , modules } from "./setup.test.js" ;
1010
1111describe ( "agent" , ( ) => {
1212 test ( "getMaxMessage works for threads" , async ( ) => {
13- const t = convexTest ( schema , modules ) ;
13+ const t = initConvexTest ( ) ;
1414 const thread = await t . mutation ( api . threads . createThread , {
1515 userId : "test" ,
1616 } ) ;
Original file line number Diff line number Diff line change 11/// <reference types="vite/client" />
2+ import { convexTest } from "convex-test" ;
23import { test } from "vitest" ;
4+ import schema from "./schema.js" ;
35export const modules = import . meta. glob ( "./**/*.*s" ) ;
46
7+ export function initConvexTest ( ) {
8+ const t = convexTest ( schema , modules ) ;
9+ return t ;
10+ }
11+
512test ( "setup" , ( ) => { } ) ;
You can’t perform that action at this time.
0 commit comments