forked from gmpetrov/databerry
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.globalSetup.ts
71 lines (63 loc) · 1.83 KB
/
jest.globalSetup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { ChildProcess, spawn } from 'child_process';
import prisma from '@app/utils/prisma-client';
import sleep from './utils/sleep';
let p: ChildProcess | null = null;
const globalSetup = async () => {
p = spawn('pnpm run dev:all:test', {
shell: true,
stdio: 'inherit',
});
(global as any).TEST_PROCESS_PID = p.pid;
await sleep(1000);
await prisma.user.create({
data: {
id: process.env.TEST_USER_ID,
email: '[email protected]',
usage: {
create: {},
},
apiKeys: {
create: {
key: process.env.TEST_USER_API_KEY!,
id: `id_${process.env.TEST_USER_API_KEY_ID}`!,
},
},
agents: {
createMany: {
data: [
{
id: process.env.TEST_PRIVATE_AGENT_ID!,
name: 'Private Agent',
description: 'This is a private agent',
modelName: 'gpt_3_5_turbo',
promptType: 'customer_support',
prompt: 'Hello, my name is John, I am a customer support agent.',
temperature: 0,
visibility: 'private',
},
{
id: process.env.TEST_PUBLIC_AGENT_ID!,
name: 'Public Agent',
description: 'This is a private agent',
modelName: 'gpt_3_5_turbo',
promptType: 'customer_support',
prompt: 'Hello, my name is John, I am a customer support agent.',
temperature: 0,
visibility: 'public',
},
],
},
},
datastores: {
create: {
id: process.env.TEST_DATASTORE_ID,
name: 'Private Datastore',
type: 'qdrant',
description: 'This is a private datastore',
visibility: 'private',
},
},
},
});
};
export default globalSetup;