@@ -928,6 +928,197 @@ describe('Rokt Forwarder', () => {
928928 }
929929 ) ;
930930 } ) ;
931+
932+ it ( 'should map other userIdentities to emailsha256' , async ( ) => {
933+ window . mParticle . Rokt . filters = {
934+ userAttributeFilters : [ ] ,
935+ filterUserAttributes : function ( ) {
936+ return { } ;
937+ } ,
938+ filteredUser : {
939+ getMPID : function ( ) {
940+ return '234' ;
941+ } ,
942+ getUserIdentities : function ( ) {
943+ return {
944+ userIdentities : {
945+ customerid : 'customer123' ,
946+ other : 'sha256-test@gmail.com' ,
947+ } ,
948+ } ;
949+ } ,
950+ } ,
951+ } ;
952+
953+ // Set up the createLauncher to properly resolve asynchronously
954+ window . Rokt . createLauncher = async function ( ) {
955+ return Promise . resolve ( {
956+ selectPlacements : function ( options ) {
957+ window . mParticle . Rokt . selectPlacementsOptions =
958+ options ;
959+ window . mParticle . Rokt . selectPlacementsCalled = true ;
960+ } ,
961+ } ) ;
962+ } ;
963+ await window . mParticle . forwarder . init (
964+ {
965+ accountId : '123456' ,
966+ } ,
967+ reportService . cb ,
968+ true ,
969+ null ,
970+ { }
971+ ) ;
972+ // Wait for initialization to complete (after launcher is created)
973+ await waitForCondition ( ( ) => {
974+ return window . mParticle . forwarder . isInitialized ;
975+ } ) ;
976+
977+ await window . mParticle . forwarder . selectPlacements ( {
978+ identifier : 'test-placement' ,
979+ attributes : { } ,
980+ } ) ;
981+
982+ window . Rokt . selectPlacementsOptions . attributes . should . deepEqual (
983+ {
984+ customerid : 'customer123' ,
985+ emailsha256 : 'sha256-test@gmail.com' ,
986+ mpid : '234' ,
987+ }
988+ ) ;
989+ } ) ;
990+
991+ it ( 'should map other to emailsha256 when other is passed through selectPlacements' , async ( ) => {
992+ window . mParticle . Rokt . filters = {
993+ userAttributeFilters : [ ] ,
994+ filterUserAttributes : function ( attributes ) {
995+ return attributes ;
996+ } ,
997+ filteredUser : {
998+ getMPID : function ( ) {
999+ return '123' ;
1000+ } ,
1001+ getUserIdentities : function ( ) {
1002+ return {
1003+ userIdentities : {
1004+ customerid : 'customer123' ,
1005+ } ,
1006+ } ;
1007+ } ,
1008+ } ,
1009+ } ;
1010+
1011+ // Set up the createLauncher to properly resolve asynchronously
1012+ window . Rokt . createLauncher = async function ( ) {
1013+ return Promise . resolve ( {
1014+ selectPlacements : function ( options ) {
1015+ window . mParticle . Rokt . selectPlacementsOptions =
1016+ options ;
1017+ window . mParticle . Rokt . selectPlacementsCalled = true ;
1018+ } ,
1019+ } ) ;
1020+ } ;
1021+
1022+ await window . mParticle . forwarder . init (
1023+ {
1024+ accountId : '123456' ,
1025+ } ,
1026+ reportService . cb ,
1027+ true ,
1028+ null ,
1029+ {
1030+ 'test-attribute' : 'test-value' ,
1031+ }
1032+ ) ;
1033+
1034+ // Wait for initialization to complete (after launcher is created)
1035+ await waitForCondition ( ( ) => {
1036+ return window . mParticle . forwarder . isInitialized ;
1037+ } ) ;
1038+
1039+ await window . mParticle . forwarder . selectPlacements ( {
1040+ identifier : 'test-placement' ,
1041+ attributes : {
1042+ other : 'sha256-test@gmail.com' ,
1043+ } ,
1044+ } ) ;
1045+
1046+ window . Rokt . selectPlacementsOptions . attributes . should . deepEqual (
1047+ {
1048+ 'test-attribute' : 'test-value' ,
1049+ customerid : 'customer123' ,
1050+ emailsha256 : 'sha256-test@gmail.com' ,
1051+ mpid : '123' ,
1052+ }
1053+ ) ;
1054+ } ) ;
1055+
1056+ it ( 'should prioritize other passed to selectPlacements over other in userIdentities' , async ( ) => {
1057+ window . mParticle . Rokt . filters = {
1058+ userAttributeFilters : [ ] ,
1059+ filterUserAttributes : function ( attributes ) {
1060+ return attributes ;
1061+ } ,
1062+ filteredUser : {
1063+ getMPID : function ( ) {
1064+ return '123' ;
1065+ } ,
1066+ getUserIdentities : function ( ) {
1067+ return {
1068+ userIdentities : {
1069+ customerid : 'customer123' ,
1070+ other : 'not-prioritized-from-userIdentities@gmail.com' ,
1071+ } ,
1072+ } ;
1073+ } ,
1074+ } ,
1075+ } ;
1076+
1077+ // Set up the createLauncher to properly resolve asynchronously
1078+ window . Rokt . createLauncher = async function ( ) {
1079+ return Promise . resolve ( {
1080+ selectPlacements : function ( options ) {
1081+ window . mParticle . Rokt . selectPlacementsOptions =
1082+ options ;
1083+ window . mParticle . Rokt . selectPlacementsCalled = true ;
1084+ } ,
1085+ } ) ;
1086+ } ;
1087+
1088+ await window . mParticle . forwarder . init (
1089+ {
1090+ accountId : '123456' ,
1091+ } ,
1092+ reportService . cb ,
1093+ true ,
1094+ null ,
1095+ {
1096+ 'test-attribute' : 'test-value' ,
1097+ }
1098+ ) ;
1099+
1100+ // Wait for initialization to complete (after launcher is created)
1101+ await waitForCondition ( ( ) => {
1102+ return window . mParticle . forwarder . isInitialized ;
1103+ } ) ;
1104+
1105+ await window . mParticle . forwarder . selectPlacements ( {
1106+ identifier : 'test-placement' ,
1107+ attributes : {
1108+ other : 'prioritized-from-selectPlacements@gmail.com' ,
1109+ } ,
1110+ } ) ;
1111+
1112+ window . Rokt . selectPlacementsOptions . attributes . should . deepEqual (
1113+ {
1114+ 'test-attribute' : 'test-value' ,
1115+ customerid : 'customer123' ,
1116+ emailsha256 :
1117+ 'prioritized-from-selectPlacements@gmail.com' ,
1118+ mpid : '123' ,
1119+ }
1120+ ) ;
1121+ } ) ;
9311122 } ) ;
9321123 } ) ;
9331124
0 commit comments