diff --git a/packages/app/src/cli/services/context/breakdown-extensions.test.ts b/packages/app/src/cli/services/context/breakdown-extensions.test.ts index a91a5d183c5..7ac6882d58c 100644 --- a/packages/app/src/cli/services/context/breakdown-extensions.test.ts +++ b/packages/app/src/cli/services/context/breakdown-extensions.test.ts @@ -90,6 +90,21 @@ const MODULE_CLI_A_NO_UID: AppModuleVersion = { }, } +const MODULE_CLI_A_EXTERNAL_IDENTIFIER: AppModuleVersion = { + registrationId: 'A', + registrationUuid: 'UUID_A', + registrationTitle: 'Checkout post purchase', + type: 'checkout_post_purchase_external', + specification: { + identifier: 'checkout_post_purchase_external', + name: 'Post purchase UI extension', + experience: 'extension', + options: { + managementExperience: 'cli', + }, + }, +} + const MODULE_DASHBOARD_MIGRATED_CLI_A: AppModuleVersion = { registrationId: 'A', registrationUuid: 'UUID_A', @@ -567,6 +582,49 @@ describe('extensionsIdentifiersDeployBreakdown', () => { remoteExtensionsRegistrations: remoteExtensionRegistrations.app, }) }) + + test('and there is an active version with a module matching a local spec external identifier then cli extension should be unchanged', async () => { + // Given + const extensionsToConfirm = { + validMatches: {EXTENSION_A: 'UUID_A'}, + dashboardOnlyExtensions: [], + extensionsToCreate: [], + didMigrateDashboardExtensions: false, + } + vi.mocked(ensureExtensionsIds).mockResolvedValue(extensionsToConfirm) + const remoteExtensionRegistrations = { + app: { + extensionRegistrations: [REGISTRATION_A], + configurationRegistrations: [], + dashboardManagedExtensionRegistrations: [], + }, + } + const activeAppVersion = { + appModuleVersions: [MODULE_CLI_A_EXTERNAL_IDENTIFIER], + } + + const developerPlatformClient: DeveloperPlatformClient = testDeveloperPlatformClient({ + appExtensionRegistrations: (_app: MinimalAppIdentifiers) => Promise.resolve(remoteExtensionRegistrations), + }) + + // When + const result = await extensionsIdentifiersDeployBreakdown( + await options({uiExtensions: [EXTENSION_A], developerPlatformClient, activeAppVersion}), + ) + + // Then + expect(result).toEqual({ + extensionIdentifiersBreakdown: { + onlyRemote: [], + toCreate: [], + toUpdate: [], + unchanged: [buildExtensionBreakdownInfo('EXTENSION_A', undefined)], + }, + extensionsToConfirm, + remoteExtensionsRegistrations: remoteExtensionRegistrations.app, + }) + }) + test('and there is an active version with matching dashboard migrated cli app modules then migrated extension should be returned in the to create', async () => { // Given const remoteExtensionRegistrations = { diff --git a/packages/app/src/cli/services/context/breakdown-extensions.ts b/packages/app/src/cli/services/context/breakdown-extensions.ts index 9d854e8339a..aad339444f5 100644 --- a/packages/app/src/cli/services/context/breakdown-extensions.ts +++ b/packages/app/src/cli/services/context/breakdown-extensions.ts @@ -348,7 +348,10 @@ function loadExtensionsIdentifiersBreakdown( developerPlatformClient: DeveloperPlatformClient, ) { const extensionModules = activeAppVersion?.appModuleVersions.filter((ext) => { - const spec = specs.find((spec) => spec.identifier === ext.specification?.identifier) + const spec = specs.find( + (spec) => + spec.identifier === ext.specification?.identifier || spec.externalIdentifier === ext.specification?.identifier, + ) return spec && !isAppConfigSpecification(spec) })