forked from bubblelabai/BubbleLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-validation-strict.ts
More file actions
136 lines (118 loc) · 4.23 KB
/
test-validation-strict.ts
File metadata and controls
136 lines (118 loc) · 4.23 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Test strict validation with properly typed code
const API_URL = 'http://localhost:3001';
async function testStrictValidation() {
console.log('Testing strict TypeScript validation...\n');
// Test 1: Extra properties on AIAgentBubble
console.log('=== Test 1: Extra properties not allowed ===');
const test1Response = await fetch(`${API_URL}/bubble-flow`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Extra Properties Test',
description: 'Testing strict type checking',
code: `
import { BubbleFlow, AIAgentBubble } from '@bubblelab/bubble-core';
import type { BubbleTriggerEventRegistry } from '@bubblelab/bubble-core';
export class TestFlow extends BubbleFlow<'webhook/http'> {
async handle(payload: BubbleTriggerEventRegistry['webhook/http']) {
const result = await new AIAgentBubble({
message: "Hello",
model: {
model: "google/gemini-2.0-flash-exp"
},
// @ts-expect-error Testing extra property
extraProperty: "should not be allowed",
randomField: 123
}).action();
return { result };
}
}
`,
eventType: 'webhook/http',
}),
});
const test1Result = await test1Response.json();
console.log('Response:', test1Result);
console.log('---\n');
// Test 2: Wrong model enum value
console.log('=== Test 2: Invalid model enum value ===');
const test2Response = await fetch(`${API_URL}/bubble-flow`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Invalid Model Enum Test',
description: 'Testing model enum validation',
code: `
import { BubbleFlow, AIAgentBubble } from '@bubblelab/bubble-core';
import type { BubbleTriggerEventRegistry } from '@bubblelab/bubble-core';
export class TestFlow extends BubbleFlow<'webhook/http'> {
async handle(payload: BubbleTriggerEventRegistry['webhook/http']) {
const result = await new AIAgentBubble({
message: "Hello",
model: {
model: "invalid-model/xyz" // Not in the allowed enum
}
}).action();
return { result };
}
}
`,
eventType: 'webhook/http',
}),
});
const test2Result = await test2Response.json();
console.log('Response:', test2Result);
console.log('---\n');
// Test 3: Check if model is actually required
console.log('=== Test 3: Is model parameter required? ===');
const test3Response = await fetch(`${API_URL}/bubble-flow`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Model Required Test',
description: 'Testing if model is required',
code: `
import { BubbleFlow, AIAgentBubble } from '@bubblelab/bubble-core';
import type { BubbleTriggerEventRegistry } from '@bubblelab/bubble-core';
export class TestFlow extends BubbleFlow<'webhook/http'> {
async handle(payload: BubbleTriggerEventRegistry['webhook/http']) {
// Only message, no model
const result = await new AIAgentBubble({
message: "Hello, is model required?"
}).action();
return { result };
}
}
`,
eventType: 'webhook/http',
}),
});
const test3Result = await test3Response.json();
console.log('Response:', test3Result);
console.log('---\n');
// Test 4: Completely wrong constructor signature
console.log('=== Test 4: Wrong constructor signature ===');
const test4Response = await fetch(`${API_URL}/bubble-flow`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Wrong Constructor Test',
description: 'Testing wrong constructor parameters',
code: `
import { BubbleFlow, AIAgentBubble } from '@bubblelab/bubble-core';
import type { BubbleTriggerEventRegistry } from '@bubblelab/bubble-core';
export class TestFlow extends BubbleFlow<'webhook/http'> {
async handle(payload: BubbleTriggerEventRegistry['webhook/http']) {
// Passing string instead of object
const result = await new AIAgentBubble("Just a string").action();
return { result };
}
}
`,
eventType: 'webhook/http',
}),
});
const test4Result = await test4Response.json();
console.log('Response:', test4Result);
}
testStrictValidation().catch(console.error);