@@ -75,6 +75,21 @@ const MODULE_CLI_A: AppModuleVersion = {
7575 } ,
7676}
7777
78+ const MODULE_CLI_A_NO_UID : AppModuleVersion = {
79+ registrationId : '' ,
80+ registrationUuid : 'UUID_A' ,
81+ registrationTitle : 'Checkout post purchase' ,
82+ type : 'checkout_post_purchase' ,
83+ specification : {
84+ identifier : 'checkout_post_purchase' ,
85+ name : 'Post purchase UI extension' ,
86+ experience : 'extension' ,
87+ options : {
88+ managementExperience : 'cli' ,
89+ } ,
90+ } ,
91+ }
92+
7893const MODULE_DASHBOARD_MIGRATED_CLI_A : AppModuleVersion = {
7994 registrationId : 'A' ,
8095 registrationUuid : 'UUID_A' ,
@@ -413,6 +428,7 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
413428 onlyRemote : [ ] ,
414429 toCreate : [ ] ,
415430 toUpdate : [ buildExtensionBreakdownInfo ( 'EXTENSION_A' ) , buildExtensionBreakdownInfo ( 'extension-a-2' ) ] ,
431+ unchanged : [ ] ,
416432 } ,
417433 extensionsToConfirm,
418434 remoteExtensionsRegistrations : remoteExtensionRegistrations . app ,
@@ -453,6 +469,7 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
453469 buildDashboardBreakdownInfo ( 'Dashboard A' ) ,
454470 ] ,
455471 toUpdate : [ ] ,
472+ unchanged : [ ] ,
456473 } ,
457474 extensionsToConfirm,
458475 remoteExtensionsRegistrations : remoteExtensionRegistrations . app ,
@@ -489,13 +506,14 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
489506 extensionIdentifiersBreakdown : {
490507 onlyRemote : [ ] ,
491508 toCreate : [ buildExtensionBreakdownInfo ( 'EXTENSION_A' ) , buildExtensionBreakdownInfo ( 'extension-a-2' ) ] ,
492- toUpdate : [ buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
509+ toUpdate : [ ] ,
510+ unchanged : [ buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
493511 } ,
494512 extensionsToConfirm,
495513 remoteExtensionsRegistrations : remoteExtensionRegistrations . app ,
496514 } )
497515 } )
498- test ( 'and there is an active version with matching cli app modules then cli extension should be updated, and no dashboard extension should be migrated' , async ( ) => {
516+ test ( 'and there is an active version with matching cli app modules then cli extension should be updated as "unchanged" , and no dashboard extension should be migrated' , async ( ) => {
499517 // Given
500518 const extensionsToConfirm = {
501519 validMatches : { EXTENSION_A : 'UUID_A' } ,
@@ -534,7 +552,8 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
534552 extensionIdentifiersBreakdown : {
535553 onlyRemote : [ ] ,
536554 toCreate : [ buildExtensionBreakdownInfo ( 'extension-a-2' ) ] ,
537- toUpdate : [ buildExtensionBreakdownInfo ( 'EXTENSION_A' ) , buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
555+ toUpdate : [ ] ,
556+ unchanged : [ buildExtensionBreakdownInfo ( 'EXTENSION_A' ) , buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
538557 } ,
539558 extensionsToConfirm,
540559 remoteExtensionsRegistrations : remoteExtensionRegistrations . app ,
@@ -582,7 +601,8 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
582601 buildExtensionBreakdownInfo ( 'DASH_MIGRATED_EXTENSION_A' ) ,
583602 buildExtensionBreakdownInfo ( 'extension-a-2' ) ,
584603 ] ,
585- toUpdate : [ buildExtensionBreakdownInfo ( 'EXTENSION_A' ) , buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
604+ toUpdate : [ ] ,
605+ unchanged : [ buildExtensionBreakdownInfo ( 'EXTENSION_A' ) , buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
586606 } ,
587607 extensionsToConfirm,
588608 remoteExtensionsRegistrations : remoteExtensionRegistrations . app ,
@@ -638,7 +658,55 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
638658 buildExtensionBreakdownInfo ( 'extension-a-2' ) ,
639659 buildDashboardBreakdownInfo ( 'Dashboard New' ) ,
640660 ] ,
641- toUpdate : [ buildExtensionBreakdownInfo ( 'EXTENSION_A' ) , buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
661+ toUpdate : [ ] ,
662+ unchanged : [ buildExtensionBreakdownInfo ( 'EXTENSION_A' ) , buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
663+ } ,
664+ extensionsToConfirm,
665+ remoteExtensionsRegistrations : remoteExtensionRegistrations . app ,
666+ } )
667+ } )
668+
669+ test ( 'and there is an active version with modules without UID, those should be returned as toUpdate, the rest, unchanged' , async ( ) => {
670+ // Given
671+ const extensionsToConfirm = {
672+ validMatches : { EXTENSION_A : 'UUID_A' } ,
673+ dashboardOnlyExtensions : [ REGISTRATION_DASHBOARD_A ] ,
674+ extensionsToCreate : [ EXTENSION_A_2 ] ,
675+ didMigrateDashboardExtensions : false ,
676+ }
677+ vi . mocked ( ensureExtensionsIds ) . mockResolvedValue ( extensionsToConfirm )
678+ const remoteExtensionRegistrations = {
679+ app : {
680+ extensionRegistrations : [ REGISTRATION_A ] ,
681+ configurationRegistrations : [ ] ,
682+ dashboardManagedExtensionRegistrations : [ REGISTRATION_DASHBOARD_A ] ,
683+ } ,
684+ }
685+ const activeAppVersion = {
686+ appModuleVersions : [ MODULE_CONFIG_A , MODULE_DASHBOARD_A , MODULE_CLI_A_NO_UID ] ,
687+ }
688+ let fetchActiveAppVersionCalled = false
689+ const developerPlatformClient : DeveloperPlatformClient = testDeveloperPlatformClient ( {
690+ appExtensionRegistrations : ( _app : MinimalAppIdentifiers ) => Promise . resolve ( remoteExtensionRegistrations ) ,
691+ activeAppVersion : ( _app : MinimalAppIdentifiers ) => {
692+ fetchActiveAppVersionCalled = true
693+ return Promise . resolve ( activeAppVersion )
694+ } ,
695+ } )
696+
697+ // When
698+ const result = await extensionsIdentifiersDeployBreakdown (
699+ await options ( { uiExtensions, developerPlatformClient, activeAppVersion} ) ,
700+ )
701+
702+ // Then
703+ expect ( fetchActiveAppVersionCalled ) . toBe ( false )
704+ expect ( result ) . toEqual ( {
705+ extensionIdentifiersBreakdown : {
706+ onlyRemote : [ ] ,
707+ toCreate : [ buildExtensionBreakdownInfo ( 'extension-a-2' ) ] ,
708+ toUpdate : [ buildExtensionBreakdownInfo ( 'EXTENSION_A' ) ] ,
709+ unchanged : [ buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
642710 } ,
643711 extensionsToConfirm,
644712 remoteExtensionsRegistrations : remoteExtensionRegistrations . app ,
@@ -676,6 +744,7 @@ describe('extensionsIdentifiersReleaseBreakdown', () => {
676744 onlyRemote : [ ] ,
677745 toCreate : [ ] ,
678746 toUpdate : [ ] ,
747+ unchanged : [ ] ,
679748 } ,
680749 versionDetails : versionDiff . versionDetails ,
681750 } )
@@ -708,7 +777,8 @@ describe('extensionsIdentifiersReleaseBreakdown', () => {
708777 extensionIdentifiersBreakdown : {
709778 onlyRemote : [ buildExtensionBreakdownInfo ( 'Checkout post purchase Deleted B' ) ] ,
710779 toCreate : [ buildExtensionBreakdownInfo ( 'Checkout post purchase' ) ] ,
711- toUpdate : [ buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
780+ toUpdate : [ ] ,
781+ unchanged : [ buildDashboardBreakdownInfo ( 'Dashboard A' ) ] ,
712782 } ,
713783 versionDetails : versionDiff . versionDetails ,
714784 } )
@@ -742,6 +812,7 @@ describe('extensionsIdentifiersReleaseBreakdown', () => {
742812 toCreate : [ ] ,
743813 toUpdate : [ ] ,
744814 onlyRemote : [ buildExtensionBreakdownInfo ( 'Checkout post purchase Deleted B' ) ] ,
815+ unchanged : [ ] ,
745816 } ,
746817 versionDetails : versionDiff . versionDetails ,
747818 } )
0 commit comments