@@ -329,8 +329,7 @@ describe("getBookingResponsesSchema", () => {
329329 ) ;
330330 } ) ;
331331
332- // TODO: Fix this behaviour later
333- test . skip ( "`firstAndLastName` variant to `fullName` when passed as JSON string from URL prefill" , async ( ) => {
332+ test ( "`firstAndLastName` variant to `fullName` when passed as JSON string from URL prefill" , async ( ) => {
334333 const schema = getBookingResponsesSchema ( {
335334 bookingFields : [
336335 {
@@ -366,6 +365,126 @@ describe("getBookingResponsesSchema", () => {
366365 ) ;
367366 } ) ;
368367
368+ test ( "JSON string with only firstName (no lastName) from URL prefill" , async ( ) => {
369+ const schema = getBookingResponsesSchema ( {
370+ bookingFields : [
371+ {
372+ name : "name" ,
373+ type : "name" ,
374+ required : true ,
375+ } ,
376+ {
377+ name : "email" ,
378+ type : "email" ,
379+ required : true ,
380+ } ,
381+ ] as z . infer < typeof eventTypeBookingFields > & z . BRAND < "HAS_SYSTEM_FIELDS" > ,
382+ view : "ALL_VIEWS" ,
383+ } ) ;
384+ const parsedResponses = await schema . safeParseAsync ( {
385+ name : '{"firstName":"John"}' ,
386+ email : "john@example.com" ,
387+ } ) ;
388+
389+ expectResponsesToBe (
390+ parsedResponses ,
391+ expect . objectContaining ( {
392+ name : "John" ,
393+ email : "john@example.com" ,
394+ } )
395+ ) ;
396+ } ) ;
397+
398+ test ( "Invalid JSON string falls back to regular string handling" , async ( ) => {
399+ const schema = getBookingResponsesSchema ( {
400+ bookingFields : [
401+ {
402+ name : "name" ,
403+ type : "name" ,
404+ required : true ,
405+ } ,
406+ {
407+ name : "email" ,
408+ type : "email" ,
409+ required : true ,
410+ } ,
411+ ] as z . infer < typeof eventTypeBookingFields > & z . BRAND < "HAS_SYSTEM_FIELDS" > ,
412+ view : "ALL_VIEWS" ,
413+ } ) ;
414+ const parsedResponses = await schema . safeParseAsync ( {
415+ name : "{not valid json}" ,
416+ email : "john@example.com" ,
417+ } ) ;
418+
419+ expectResponsesToBe (
420+ parsedResponses ,
421+ expect . objectContaining ( {
422+ name : "{not valid json}" ,
423+ email : "john@example.com" ,
424+ } )
425+ ) ;
426+ } ) ;
427+
428+ test ( "JSON array falls back to regular string handling" , async ( ) => {
429+ const schema = getBookingResponsesSchema ( {
430+ bookingFields : [
431+ {
432+ name : "name" ,
433+ type : "name" ,
434+ required : true ,
435+ } ,
436+ {
437+ name : "email" ,
438+ type : "email" ,
439+ required : true ,
440+ } ,
441+ ] as z . infer < typeof eventTypeBookingFields > & z . BRAND < "HAS_SYSTEM_FIELDS" > ,
442+ view : "ALL_VIEWS" ,
443+ } ) ;
444+ const parsedResponses = await schema . safeParseAsync ( {
445+ name : '["John", "Doe"]' ,
446+ email : "john@example.com" ,
447+ } ) ;
448+
449+ expectResponsesToBe (
450+ parsedResponses ,
451+ expect . objectContaining ( {
452+ name : '["John", "Doe"]' ,
453+ email : "john@example.com" ,
454+ } )
455+ ) ;
456+ } ) ;
457+
458+ test ( "JSON object without firstName falls back to regular string handling" , async ( ) => {
459+ const schema = getBookingResponsesSchema ( {
460+ bookingFields : [
461+ {
462+ name : "name" ,
463+ type : "name" ,
464+ required : true ,
465+ } ,
466+ {
467+ name : "email" ,
468+ type : "email" ,
469+ required : true ,
470+ } ,
471+ ] as z . infer < typeof eventTypeBookingFields > & z . BRAND < "HAS_SYSTEM_FIELDS" > ,
472+ view : "ALL_VIEWS" ,
473+ } ) ;
474+ const parsedResponses = await schema . safeParseAsync ( {
475+ name : '{"name":"John Doe"}' ,
476+ email : "john@example.com" ,
477+ } ) ;
478+
479+ expectResponsesToBe (
480+ parsedResponses ,
481+ expect . objectContaining ( {
482+ name : '{"name":"John Doe"}' ,
483+ email : "john@example.com" ,
484+ } )
485+ ) ;
486+ } ) ;
487+
369488 test ( "`fullName` to `firstAndLastName` when there is a lastName(separated by space)" , async ( ) => {
370489 const schema = getBookingResponsesSchema ( {
371490 bookingFields : [
0 commit comments