@@ -470,6 +470,177 @@ Array [
470470 } ) ;
471471 } ) ;
472472
473+ describe ( "getCreator" , ( ) => {
474+ it ( "should return app creator with initials and logo" , ( ) => {
475+ // Arrange
476+ const appCreator = {
477+ __typename : "App" as const ,
478+ id : "app-1" ,
479+ name : "Payment App" ,
480+ brand : {
481+ __typename : "AppBrand" as const ,
482+ logo : {
483+ __typename : "AppBrandLogo" as const ,
484+ default : "https://example.com/app-logo.webp" ,
485+ } ,
486+ } ,
487+ } ;
488+
489+ // Act
490+ const result = OrderRefundsViewModel [ "getCreator" ] ( appCreator ) ;
491+
492+ // Assert
493+ expect ( result ) . toStrictEqual ( {
494+ initials : "PA" ,
495+ logoUrl : "https://example.com/app-logo.webp" ,
496+ } ) ;
497+ } ) ;
498+
499+ it ( "should return app creator with initials when logo is missing" , ( ) => {
500+ // Arrange
501+ const appCreator = {
502+ __typename : "App" as const ,
503+ id : "app-2" ,
504+ name : "Another App" ,
505+ brand : null ,
506+ } ;
507+
508+ // Act
509+ const result = OrderRefundsViewModel [ "getCreator" ] ( appCreator ) ;
510+
511+ // Assert
512+ expect ( result ) . toStrictEqual ( {
513+ initials : "AN" ,
514+ logoUrl : null ,
515+ } ) ;
516+ } ) ;
517+
518+ it ( "should return app creator with empty initials when name is null" , ( ) => {
519+ // Arrange
520+ const appCreator = {
521+ __typename : "App" as const ,
522+ id : "app-3" ,
523+ name : null ,
524+ brand : null ,
525+ } ;
526+
527+ // Act
528+ const result = OrderRefundsViewModel [ "getCreator" ] ( appCreator ) ;
529+
530+ // Assert
531+ expect ( result ) . toStrictEqual ( {
532+ initials : "" ,
533+ logoUrl : null ,
534+ } ) ;
535+ } ) ;
536+
537+ it ( "should return app creator with initials and handle nested null logo" , ( ) => {
538+ // Arrange
539+ const appCreator = {
540+ __typename : "App" as const ,
541+ id : "app-4" ,
542+ name : "Test App" ,
543+ brand : {
544+ __typename : "AppBrand" as const ,
545+ logo : {
546+ __typename : "AppBrandLogo" as const ,
547+ default : null as any ,
548+ } ,
549+ } ,
550+ } ;
551+
552+ // Act
553+ const result = OrderRefundsViewModel [ "getCreator" ] ( appCreator ) ;
554+
555+ // Assert
556+ expect ( result ) . toStrictEqual ( {
557+ initials : "TE" ,
558+ logoUrl : null ,
559+ } ) ;
560+ } ) ;
561+
562+ it ( "should return user creator with initials and avatar" , ( ) => {
563+ // Arrange
564+ const userCreator = {
565+ __typename : "User" as const ,
566+ id : "user-1" ,
567+ email : "john.doe@example.com" ,
568+ firstName : "John" ,
569+ lastName : "Doe" ,
570+ isActive : true ,
571+ avatar : {
572+ __typename : "Image" as const ,
573+ url : "https://example.com/user-avatar.jpg" ,
574+ } ,
575+ } ;
576+
577+ // Act
578+ const result = OrderRefundsViewModel [ "getCreator" ] ( userCreator ) ;
579+
580+ // Assert
581+ expect ( result ) . toStrictEqual ( {
582+ initials : "JD" ,
583+ logoUrl : "https://example.com/user-avatar.jpg" ,
584+ } ) ;
585+ } ) ;
586+
587+ it ( "should return user creator with initials when avatar is missing" , ( ) => {
588+ // Arrange
589+ const userCreator = {
590+ __typename : "User" as const ,
591+ id : "user-2" ,
592+ email : "jane.smith@example.com" ,
593+ firstName : "Jane" ,
594+ lastName : "Smith" ,
595+ isActive : true ,
596+ avatar : null ,
597+ } ;
598+
599+ // Act
600+ const result = OrderRefundsViewModel [ "getCreator" ] ( userCreator ) ;
601+
602+ // Assert
603+ expect ( result ) . toStrictEqual ( {
604+ initials : "JS" ,
605+ logoUrl : null ,
606+ } ) ;
607+ } ) ;
608+
609+ it ( "should handle user with empty name by using email for initials" , ( ) => {
610+ // Arrange
611+ const userCreator = {
612+ __typename : "User" as const ,
613+ id : "user-3" ,
614+ email : "user@example.com" ,
615+ firstName : "" ,
616+ lastName : "" ,
617+ isActive : true ,
618+ avatar : null ,
619+ } ;
620+
621+ // Act
622+ const result = OrderRefundsViewModel [ "getCreator" ] ( userCreator ) ;
623+
624+ // Assert
625+ // getUserInitials falls back to email when name is empty, generating "US" from "user@example.com"
626+ expect ( result ) . toStrictEqual ( {
627+ initials : "US" ,
628+ logoUrl : null ,
629+ } ) ;
630+ } ) ;
631+
632+ it ( "should handle null creator" , ( ) => {
633+ // Arrange
634+ const creator = null ;
635+
636+ // Act
637+ const result = OrderRefundsViewModel [ "getCreator" ] ( creator ) ;
638+
639+ // Assert
640+ expect ( result ) . toBeNull ( ) ;
641+ } ) ;
642+ } ) ;
643+
473644 describe ( "groupEventsByPspReference" , ( ) => {
474645 it . each ( [
475646 [
0 commit comments