@@ -276,8 +276,11 @@ describe('Function Execute API Route', () => {
276276 it . concurrent ( 'should resolve tag variables with <tag_name> syntax' , async ( ) => {
277277 const req = createMockRequest ( 'POST' , {
278278 code : 'return <email>' ,
279- params : {
280- email : { id : '123' , subject : 'Test Email' } ,
279+ blockData : {
280+ 'block-123' : { id : '123' , subject : 'Test Email' } ,
281+ } ,
282+ blockNameMapping : {
283+ email : 'block-123' ,
281284 } ,
282285 } )
283286
@@ -305,9 +308,13 @@ describe('Function Execute API Route', () => {
305308 it . concurrent ( 'should only match valid variable names in angle brackets' , async ( ) => {
306309 const req = createMockRequest ( 'POST' , {
307310 code : 'return <validVar> + "<invalid@email.com>" + <another_valid>' ,
308- params : {
309- validVar : 'hello' ,
310- another_valid : 'world' ,
311+ blockData : {
312+ 'block-1' : 'hello' ,
313+ 'block-2' : 'world' ,
314+ } ,
315+ blockNameMapping : {
316+ validVar : 'block-1' ,
317+ another_valid : 'block-2' ,
311318 } ,
312319 } )
313320
@@ -321,28 +328,22 @@ describe('Function Execute API Route', () => {
321328 it . concurrent (
322329 'should handle Gmail webhook data with email addresses containing angle brackets' ,
323330 async ( ) => {
324- const gmailData = {
325- email : {
326- id : '123' ,
327- from : 'Waleed Latif <waleed@sim.ai>' ,
328- to : 'User <user@example.com>' ,
329- subject : 'Test Email' ,
330- bodyText : 'Hello world' ,
331- } ,
332- rawEmail : {
333- id : '123' ,
334- payload : {
335- headers : [
336- { name : 'From' , value : 'Waleed Latif <waleed@sim.ai>' } ,
337- { name : 'To' , value : 'User <user@example.com>' } ,
338- ] ,
339- } ,
340- } ,
331+ const emailData = {
332+ id : '123' ,
333+ from : 'Waleed Latif <waleed@sim.ai>' ,
334+ to : 'User <user@example.com>' ,
335+ subject : 'Test Email' ,
336+ bodyText : 'Hello world' ,
341337 }
342338
343339 const req = createMockRequest ( 'POST' , {
344340 code : 'return <email>' ,
345- params : gmailData ,
341+ blockData : {
342+ 'block-email' : emailData ,
343+ } ,
344+ blockNameMapping : {
345+ email : 'block-email' ,
346+ } ,
346347 } )
347348
348349 const response = await POST ( req )
@@ -356,17 +357,20 @@ describe('Function Execute API Route', () => {
356357 it . concurrent (
357358 'should properly serialize complex email objects with special characters' ,
358359 async ( ) => {
359- const complexEmailData = {
360- email : {
361- from : 'Test User <test@example.com>' ,
362- bodyHtml : '<div>HTML content with "quotes" and \'apostrophes\'</div>' ,
363- bodyText : 'Text with\nnewlines\tand\ttabs' ,
364- } ,
360+ const emailData = {
361+ from : 'Test User <test@example.com>' ,
362+ bodyHtml : '<div>HTML content with "quotes" and \'apostrophes\'</div>' ,
363+ bodyText : 'Text with\nnewlines\tand\ttabs' ,
365364 }
366365
367366 const req = createMockRequest ( 'POST' , {
368367 code : 'return <email>' ,
369- params : complexEmailData ,
368+ blockData : {
369+ 'block-email' : emailData ,
370+ } ,
371+ blockNameMapping : {
372+ email : 'block-email' ,
373+ } ,
370374 } )
371375
372376 const response = await POST ( req )
@@ -519,18 +523,23 @@ describe('Function Execute API Route', () => {
519523 } )
520524
521525 it . concurrent ( 'should handle JSON serialization edge cases' , async ( ) => {
526+ const complexData = {
527+ special : 'chars"with\'quotes' ,
528+ unicode : '🎉 Unicode content' ,
529+ nested : {
530+ deep : {
531+ value : 'test' ,
532+ } ,
533+ } ,
534+ }
535+
522536 const req = createMockRequest ( 'POST' , {
523537 code : 'return <complexData>' ,
524- params : {
525- complexData : {
526- special : 'chars"with\'quotes' ,
527- unicode : '🎉 Unicode content' ,
528- nested : {
529- deep : {
530- value : 'test' ,
531- } ,
532- } ,
533- } ,
538+ blockData : {
539+ 'block-complex' : complexData ,
540+ } ,
541+ blockNameMapping : {
542+ complexData : 'block-complex' ,
534543 } ,
535544 } )
536545
0 commit comments