Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down
Loading