Skip to content

Commit

Permalink
Merge pull request #4162 from Shopify/js-migration-pos-to-ui
Browse files Browse the repository at this point in the history
Add pos_ui_extension to migration for ui_extension
  • Loading branch information
js-goupil authored Jul 5, 2024
2 parents 9c31d35 + cb06f10 commit 8a42356
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-lizards-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli': minor
---

Added extension type pos_ui_extension to the ui_extension migration process
4 changes: 3 additions & 1 deletion packages/app/src/cli/services/context/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ export async function extensionMigrationPrompt(
.map((name) => `"${name}"`)
.join(', ')

const migrationEndType = toMigrate.map(({local}) => `"${local.type}"`).join(', ')

renderInfo({
headline: "Extension migrations can't be undone.",
body: `Your ${migrationNames} configuration has been updated. Migrating gives you access to new features and won't impact the end user experience. All previous extension versions will reflect this change.`,
})

const confirmMessage = includeRemoteType
? `Yes, confirm migration from ${uniqueMigrationTypes}`
? `Yes, confirm migration from ${uniqueMigrationTypes} to ${migrationEndType}`
: 'Yes, confirm migration'

return renderConfirmationPrompt({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ describe('getExtensionsToMigrate()', () => {
}

describe('if local.id matches remote.id', () => {
test('returns extensions where local.type is ui_extension but remote.type is POS_UI_EXTENSION', () => {
// Given
const localExtension = getLocalExtension({type: 'ui_extension'})
const remoteExtension = getRemoteExtension({type: 'POS_UI_EXTENSION'})

// When
const toMigrate = getUIExtensionsToMigrate([localExtension], [remoteExtension], defaultIds)

// Then
expect(toMigrate).toStrictEqual([{local: localExtension, remote: remoteExtension}])
})

test('returns extensions where local.type is ui_extension but remote.type is CHECKOUT_UI_EXTENSION', () => {
// Given
const localExtension = getLocalExtension({type: 'ui_extension'})
Expand All @@ -54,7 +66,7 @@ describe('getExtensionsToMigrate()', () => {
expect(toMigrate).toStrictEqual([])
})

test('does not return extensions where remote.type is not CHECKOUT_UI_EXTENSION', () => {
test('does not return extensions where remote.type is not CHECKOUT_UI_EXTENSION or POS_UI_EXTENSION', () => {
// Given
const localExtension = {...getLocalExtension(), type: 'ui_extension'}
const remoteExtension = {...getRemoteExtension(), type: 'PRODUCT_SUBSCRIPTION_UI_EXTENSION'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getUIExtensionsToMigrate(
identifiers: IdentifiersExtensions,
) {
const ids = getExtensionIds(localSources, identifiers)
const remoteExtensionTypesToMigrate = ['CHECKOUT_UI_EXTENSION']
const remoteExtensionTypesToMigrate = ['CHECKOUT_UI_EXTENSION', 'POS_UI_EXTENSION']

return localSources.reduce<LocalRemoteSource[]>((accumulator, localSource) => {
if (localSource.type === 'ui_extension') {
Expand Down

0 comments on commit 8a42356

Please sign in to comment.