Skip to content

Commit

Permalink
feat(customers): add missing search and bu actions (#1903)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMoll authored Aug 21, 2024
1 parent ce8b818 commit 164f1ce
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-seas-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools/sync-actions': minor
---

Add sync actions changeMyBusinessUnitStatusOnCreation, setMyBusinessUnitAssociateRoleOnCreation and changeCustomerSearchStatus
9 changes: 9 additions & 0 deletions packages/sync-actions/src/projects-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ export const baseActionsList = [
{ action: 'changeLanguages', key: 'languages' },
{ action: 'changeMessagesConfiguration', key: 'messagesConfiguration' },
{ action: 'setShippingRateInputType', key: 'shippingRateInputType' },
{
action: 'changeMyBusinessUnitStatusOnCreation',
key: 'myBusinessUnitStatusOnCreation',
},
{
action: 'setMyBusinessUnitAssociateRoleOnCreation',
key: 'myBusinessUnitAssociateRoleOnCreation',
},
{ action: 'changeCustomerSearchStatus', key: 'customerSearchStatus' },
]

export function actionsMapBase(diff, oldObj, newObj, config = {}) {
Expand Down
82 changes: 82 additions & 0 deletions packages/sync-actions/test/projects-sync.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,39 @@ describe('Exports', () => {
])
)
})

test('should contain `changeMyBusinessUnitStatusOnCreation` action', () => {
expect(baseActionsList).toEqual(
expect.arrayContaining([
{
action: 'changeMyBusinessUnitStatusOnCreation',
key: 'myBusinessUnitStatusOnCreation',
},
])
)
})

test('should contain `setMyBusinessUnitAssociateRoleOnCreation` action', () => {
expect(baseActionsList).toEqual(
expect.arrayContaining([
{
action: 'setMyBusinessUnitAssociateRoleOnCreation',
key: 'myBusinessUnitAssociateRoleOnCreation',
},
])
)
})

test('should contain `changeCustomerSearchStatus` action', () => {
expect(baseActionsList).toEqual(
expect.arrayContaining([
{
action: 'changeCustomerSearchStatus',
key: 'customerSearchStatus',
},
])
)
})
})
})

Expand Down Expand Up @@ -212,4 +245,53 @@ describe('Actions', () => {
]
expect(actual).toEqual(expected)
})

test('should build `changeMyBusinessUnitStatusOnCreation` action', () => {
const before = { myBusinessUnitStatusOnCreation: 'Active' }
const now = { myBusinessUnitStatusOnCreation: 'Deactive' }
const actual = projectsSync.buildActions(now, before)
const expected = [
{
action: 'changeMyBusinessUnitStatusOnCreation',
...now,
},
]
expect(actual).toEqual(expected)
})

test('should build `setMyBusinessUnitAssociateRoleOnCreation` action', () => {
const before = {
myBusinessUnitAssociateRoleOnCreation: {
typeId: 'associate-role',
key: 'old-role',
},
}
const now = {
myBusinessUnitAssociateRoleOnCreation: {
typeId: 'associate-role',
key: 'new-role',
},
}
const actual = projectsSync.buildActions(now, before)
const expected = [
{
action: 'setMyBusinessUnitAssociateRoleOnCreation',
...now,
},
]
expect(actual).toEqual(expected)
})

test('should build `changeCustomerSearchStatus` action', () => {
const before = { customerSearchStatus: 'Activated' }
const now = { customerSearchStatus: 'Deactivated' }
const actual = projectsSync.buildActions(now, before)
const expected = [
{
action: 'changeCustomerSearchStatus',
...now,
},
]
expect(actual).toEqual(expected)
})
})

0 comments on commit 164f1ce

Please sign in to comment.