@@ -868,4 +868,321 @@ describe('Standard Data Model with Metadata API Enabled - Storage Preparation On
868868 } ) ;
869869 } ) ;
870870 } ) ;
871+
872+ describe ( 'Storage migrationSuccess Flag - Metadata API Enabled' , ( ) => {
873+ beforeEach ( ( ) => {
874+ // Clear storage before each test
875+ const migrationStorage = StorageUtil . getOmnistudioMigrationStorage ( ) ;
876+ migrationStorage . osStorage . clear ( ) ;
877+ migrationStorage . osStandardStorage . clear ( ) ;
878+ migrationStorage . fcStorage . clear ( ) ;
879+
880+ const assessmentStorage = StorageUtil . getOmnistudioAssessmentStorage ( ) ;
881+ assessmentStorage . osStorage . clear ( ) ;
882+ assessmentStorage . osStandardStorage . clear ( ) ;
883+ assessmentStorage . fcStorage . clear ( ) ;
884+ } ) ;
885+
886+ describe ( 'OmniScript - migrationSuccess should be true (direct method test)' , ( ) => {
887+ it ( 'should set migrationSuccess to true when prepareStorageForRelatedObjectsWhenMetadataAPIEnabled is called' , ( ) => {
888+ const omniScriptTool = new OmniScriptMigrationTool (
889+ OmniScriptExportType . All ,
890+ '' ,
891+ mockConnection ,
892+ mockLogger ,
893+ mockMessages ,
894+ mockUx ,
895+ false
896+ ) ;
897+
898+ const mockOmniscripts = [
899+ {
900+ Id : 'os1' ,
901+ Name : 'TestOmniScript' ,
902+ Type : 'Customer' ,
903+ SubType : 'Profile' ,
904+ Language : 'English' ,
905+ VersionNumber : '1' ,
906+ IsIntegrationProcedure : false ,
907+ IsWebCompEnabled : true ,
908+ IsActive : true ,
909+ } ,
910+ {
911+ Id : 'os2' ,
912+ Name : 'AnotherOmniScript' ,
913+ Type : 'Product' ,
914+ SubType : 'Details' ,
915+ Language : 'Spanish' ,
916+ VersionNumber : '2' ,
917+ IsIntegrationProcedure : false ,
918+ IsWebCompEnabled : true ,
919+ IsActive : true ,
920+ } ,
921+ ] ;
922+
923+ // Call the private method directly
924+ const storage = StorageUtil . getOmnistudioAssessmentStorage ( ) ;
925+ ( omniScriptTool as any ) . prepareStorageForRelatedObjectsWhenMetadataAPIEnabled ( storage , mockOmniscripts ) ;
926+
927+ // Verify OmniScripts are in storage with migrationSuccess = true
928+ const key1 = 'customerprofileenglish' ;
929+ const key2 = 'productdetailsspanish' ;
930+
931+ expect ( storage . osStorage . has ( key1 ) ) . to . be . true ;
932+ expect ( storage . osStorage . has ( key2 ) ) . to . be . true ;
933+
934+ const osData1 = storage . osStorage . get ( key1 ) ;
935+ const osData2 = storage . osStorage . get ( key2 ) ;
936+
937+ expect ( osData1 ) . to . not . be . undefined ;
938+ expect ( osData1 . migrationSuccess ) . to . be . true ;
939+ expect ( osData1 . type ) . to . equal ( 'Customer' ) ;
940+ expect ( osData1 . subtype ) . to . equal ( 'Profile' ) ;
941+ expect ( osData1 . language ) . to . equal ( 'English' ) ;
942+
943+ expect ( osData2 ) . to . not . be . undefined ;
944+ expect ( osData2 . migrationSuccess ) . to . be . true ;
945+ expect ( osData2 . type ) . to . equal ( 'Product' ) ;
946+ expect ( osData2 . subtype ) . to . equal ( 'Details' ) ;
947+ expect ( osData2 . language ) . to . equal ( 'Spanish' ) ;
948+ } ) ;
949+
950+ it ( 'should skip Integration Procedures when populating storage' , ( ) => {
951+ const omniScriptTool = new OmniScriptMigrationTool (
952+ OmniScriptExportType . All ,
953+ '' ,
954+ mockConnection ,
955+ mockLogger ,
956+ mockMessages ,
957+ mockUx ,
958+ false
959+ ) ;
960+
961+ const mockOmniscripts = [
962+ {
963+ Id : 'os1' ,
964+ Name : 'TestOmniScript' ,
965+ Type : 'Customer' ,
966+ SubType : 'Profile' ,
967+ Language : 'English' ,
968+ IsIntegrationProcedure : false , // OmniScript
969+ } ,
970+ {
971+ Id : 'ip1' ,
972+ Name : 'TestIP' ,
973+ Type : 'API' ,
974+ SubType : 'Gateway' ,
975+ IsIntegrationProcedure : true , // Integration Procedure - should be skipped
976+ } ,
977+ ] ;
978+
979+ const storage = StorageUtil . getOmnistudioAssessmentStorage ( ) ;
980+ ( omniScriptTool as any ) . prepareStorageForRelatedObjectsWhenMetadataAPIEnabled ( storage , mockOmniscripts ) ;
981+
982+ // OmniScript should be in storage
983+ const osKey = 'customerprofileenglish' ;
984+ expect ( storage . osStorage . has ( osKey ) ) . to . be . true ;
985+ expect ( storage . osStorage . get ( osKey ) ! . migrationSuccess ) . to . be . true ;
986+
987+ // Only 1 entry should be in storage (IP was skipped)
988+ expect ( storage . osStorage . size ) . to . equal ( 1 ) ;
989+ } ) ;
990+
991+ it ( 'should work for both assessment and migration storage' , ( ) => {
992+ const omniScriptTool = new OmniScriptMigrationTool (
993+ OmniScriptExportType . All ,
994+ '' ,
995+ mockConnection ,
996+ mockLogger ,
997+ mockMessages ,
998+ mockUx ,
999+ false
1000+ ) ;
1001+
1002+ const mockOmniscripts = [
1003+ {
1004+ Id : 'os1' ,
1005+ Name : 'TestOmniScript' ,
1006+ Type : 'TestWrapperOmni' ,
1007+ SubType : 'Q3' ,
1008+ Language : 'English' ,
1009+ IsIntegrationProcedure : false ,
1010+ } ,
1011+ ] ;
1012+
1013+ // Test with assessment storage
1014+ const assessmentStorage = StorageUtil . getOmnistudioAssessmentStorage ( ) ;
1015+ ( omniScriptTool as any ) . prepareStorageForRelatedObjectsWhenMetadataAPIEnabled (
1016+ assessmentStorage ,
1017+ mockOmniscripts
1018+ ) ;
1019+
1020+ const assessKey = 'testwrapperomniq3english' ;
1021+ expect ( assessmentStorage . osStorage . has ( assessKey ) ) . to . be . true ;
1022+ expect ( assessmentStorage . osStorage . get ( assessKey ) ! . migrationSuccess ) . to . be . true ;
1023+
1024+ // Test with migration storage
1025+ const migrationStorage = StorageUtil . getOmnistudioMigrationStorage ( ) ;
1026+ ( omniScriptTool as any ) . prepareStorageForRelatedObjectsWhenMetadataAPIEnabled (
1027+ migrationStorage ,
1028+ mockOmniscripts
1029+ ) ;
1030+
1031+ expect ( migrationStorage . osStorage . has ( assessKey ) ) . to . be . true ;
1032+ expect ( migrationStorage . osStorage . get ( assessKey ) ! . migrationSuccess ) . to . be . true ;
1033+ } ) ;
1034+ } ) ;
1035+
1036+ describe ( 'FlexCard - migrationSuccess should be true (direct method test)' , ( ) => {
1037+ it ( 'should set migrationSuccess to true when prepareStorageForRelatedObjectsWhenMetadataAPIEnabled is called' , ( ) => {
1038+ const cardTool = new CardMigrationTool ( '' , mockConnection , mockLogger , mockMessages , mockUx , false ) ;
1039+
1040+ const mockFlexCards = [
1041+ {
1042+ Id : 'fc1' ,
1043+ Name : 'CustomerDashboard' ,
1044+ } ,
1045+ {
1046+ Id : 'fc2' ,
1047+ Name : 'ProductDetails' ,
1048+ } ,
1049+ ] ;
1050+
1051+ const storage = StorageUtil . getOmnistudioAssessmentStorage ( ) ;
1052+ ( cardTool as any ) . prepareStorageForRelatedObjectsWhenMetadataAPIEnabled ( storage , mockFlexCards ) ;
1053+
1054+ const key1 = 'customerdashboard' ;
1055+ const key2 = 'productdetails' ;
1056+
1057+ expect ( storage . fcStorage . has ( key1 ) ) . to . be . true ;
1058+ expect ( storage . fcStorage . has ( key2 ) ) . to . be . true ;
1059+
1060+ const fcData1 = storage . fcStorage . get ( key1 ) ;
1061+ const fcData2 = storage . fcStorage . get ( key2 ) ;
1062+
1063+ expect ( fcData1 ) . to . not . be . undefined ;
1064+ expect ( fcData1 . migrationSuccess ) . to . be . true ;
1065+ expect ( fcData1 . name ) . to . equal ( 'CustomerDashboard' ) ;
1066+ expect ( fcData1 . originalName ) . to . equal ( 'CustomerDashboard' ) ;
1067+
1068+ expect ( fcData2 ) . to . not . be . undefined ;
1069+ expect ( fcData2 . migrationSuccess ) . to . be . true ;
1070+ expect ( fcData2 . name ) . to . equal ( 'ProductDetails' ) ;
1071+ expect ( fcData2 . originalName ) . to . equal ( 'ProductDetails' ) ;
1072+ } ) ;
1073+
1074+ it ( 'should work for multiple FlexCards' , ( ) => {
1075+ const cardTool = new CardMigrationTool ( '' , mockConnection , mockLogger , mockMessages , mockUx , false ) ;
1076+
1077+ const mockFlexCards = Array . from ( { length : 5 } , ( _ , i ) => ( {
1078+ Id : `fc${ i } ` ,
1079+ Name : `FlexCard${ i } ` ,
1080+ } ) ) ;
1081+
1082+ const storage = StorageUtil . getOmnistudioAssessmentStorage ( ) ;
1083+ ( cardTool as any ) . prepareStorageForRelatedObjectsWhenMetadataAPIEnabled ( storage , mockFlexCards ) ;
1084+
1085+ for ( let i = 0 ; i < 5 ; i ++ ) {
1086+ const key = `flexcard${ i } ` ;
1087+ expect ( storage . fcStorage . has ( key ) ) . to . be . true ;
1088+ const fcData = storage . fcStorage . get ( key ) ;
1089+ expect ( fcData ) . to . not . be . undefined ;
1090+ expect ( fcData . migrationSuccess ) . to . be . true ;
1091+ }
1092+ } ) ;
1093+
1094+ it ( 'should work for both assessment and migration storage' , ( ) => {
1095+ const cardTool = new CardMigrationTool ( '' , mockConnection , mockLogger , mockMessages , mockUx , false ) ;
1096+
1097+ const mockFlexCards = [
1098+ {
1099+ Id : 'fc1' ,
1100+ Name : 'TestFlexCard' ,
1101+ } ,
1102+ ] ;
1103+
1104+ // Test with assessment storage
1105+ const assessmentStorage = StorageUtil . getOmnistudioAssessmentStorage ( ) ;
1106+ ( cardTool as any ) . prepareStorageForRelatedObjectsWhenMetadataAPIEnabled ( assessmentStorage , mockFlexCards ) ;
1107+
1108+ const key = 'testflexcard' ;
1109+ expect ( assessmentStorage . fcStorage . has ( key ) ) . to . be . true ;
1110+ expect ( assessmentStorage . fcStorage . get ( key ) ! . migrationSuccess ) . to . be . true ;
1111+
1112+ // Test with migration storage
1113+ const migrationStorage = StorageUtil . getOmnistudioMigrationStorage ( ) ;
1114+ ( cardTool as any ) . prepareStorageForRelatedObjectsWhenMetadataAPIEnabled ( migrationStorage , mockFlexCards ) ;
1115+
1116+ expect ( migrationStorage . fcStorage . has ( key ) ) . to . be . true ;
1117+ expect ( migrationStorage . fcStorage . get ( key ) ! . migrationSuccess ) . to . be . true ;
1118+ } ) ;
1119+ } ) ;
1120+
1121+ describe ( 'FlexiPage Migration - Storage lookup should find migrationSuccess = true' , ( ) => {
1122+ it ( 'should have migrationSuccess = true for OmniScript referenced by FlexiPage wrapper' , ( ) => {
1123+ const omniScriptTool = new OmniScriptMigrationTool (
1124+ OmniScriptExportType . All ,
1125+ '' ,
1126+ mockConnection ,
1127+ mockLogger ,
1128+ mockMessages ,
1129+ mockUx ,
1130+ false
1131+ ) ;
1132+
1133+ // Simulate an OmniScript that a FlexiPage wrapper references (testWrapperOmniQ3English)
1134+ const mockOmniscripts = [
1135+ {
1136+ Id : 'os1' ,
1137+ Name : 'TestWrapperOmniQ3English' ,
1138+ Type : 'TestWrapperOmni' ,
1139+ SubType : 'Q3' ,
1140+ Language : 'English' ,
1141+ IsIntegrationProcedure : false ,
1142+ } ,
1143+ ] ;
1144+
1145+ const storage = StorageUtil . getOmnistudioAssessmentStorage ( ) ;
1146+ ( omniScriptTool as any ) . prepareStorageForRelatedObjectsWhenMetadataAPIEnabled ( storage , mockOmniscripts ) ;
1147+
1148+ // This is the key that FlexiPage transformer looks up
1149+ const key = 'testwrapperomniq3english' ;
1150+
1151+ expect ( storage . osStorage . has ( key ) ) . to . be . true ;
1152+ const osData = storage . osStorage . get ( key ) ;
1153+ expect ( osData ) . to . not . be . undefined ;
1154+ expect ( osData . migrationSuccess ) . to . be . true ;
1155+
1156+ // This proves the fix works - previously migrationSuccess was undefined,
1157+ // which would cause FlexiPage migration to fail with:
1158+ // "Key testwrapperomniq3english can not be processed"
1159+ } ) ;
1160+
1161+ it ( 'should have migrationSuccess = true for FlexCard referenced by FlexiPage' , ( ) => {
1162+ const cardTool = new CardMigrationTool ( '' , mockConnection , mockLogger , mockMessages , mockUx , false ) ;
1163+
1164+ const mockFlexCards = [
1165+ {
1166+ Id : 'fc1' ,
1167+ Name : 'TestFlexCard' ,
1168+ } ,
1169+ ] ;
1170+
1171+ const storage = StorageUtil . getOmnistudioAssessmentStorage ( ) ;
1172+ ( cardTool as any ) . prepareStorageForRelatedObjectsWhenMetadataAPIEnabled ( storage , mockFlexCards ) ;
1173+
1174+ // This is the key that FlexiPage transformer looks up
1175+ const key = 'testflexcard' ;
1176+
1177+ expect ( storage . fcStorage . has ( key ) ) . to . be . true ;
1178+ const fcData = storage . fcStorage . get ( key ) ;
1179+ expect ( fcData ) . to . not . be . undefined ;
1180+ expect ( fcData . migrationSuccess ) . to . be . true ;
1181+
1182+ // This proves the fix works - previously migrationSuccess was undefined,
1183+ // which would cause FlexiPage migration to fail with:
1184+ // "Key testflexcard can not be processed"
1185+ } ) ;
1186+ } ) ;
1187+ } ) ;
8711188} ) ;
0 commit comments