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
5 changes: 5 additions & 0 deletions .changeset/quick-lines-save.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools/sync-actions': minor
---

Add support for the `setSavedToLineItem` update action on product type attribute definitions.
4 changes: 4 additions & 0 deletions packages/sync-actions/src/product-types-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ const generateUpdateActionsForAttributeDefinitions = (
action: 'changeAttributeConstraint',
attributeName: updatedAttributeDefinition.previous.name,
},
savedToLineItem: {
action: 'setSavedToLineItem',
attributeName: updatedAttributeDefinition.previous.name,
},
}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ Array [
"attributeName": "attribute-name",
"newValue": "None",
},
Object {
"action": "setSavedToLineItem",
"attributeName": "attribute-name",
"savedToLineItem": true,
},
]
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ describe('product type hints', () => {
inputTip: { en: 'next-input-tip' },
inputHint: 'MultiLine',
isSearchable: true,
savedToLineItem: true,
},
})
updateActions = sync.buildActions(
Expand Down Expand Up @@ -418,6 +419,14 @@ describe('product type hints', () => {
newValue: 'None',
},
],
[
'savedToLineItem',
{
action: 'setSavedToLineItem',
attributeName: 'attribute-name',
savedToLineItem: true,
},
],
]
it.each(changes)(
'should generate update action for %s',
Expand All @@ -429,6 +438,53 @@ describe('product type hints', () => {
)
})
})
describe('with `savedToLineItem` changes', () => {
const build = (previous, next) => {
const base = createAttributeDefinitionDraftItem()
return sync.buildActions(
{},
{},
{
nestedValuesChanges: {
attributeDefinitions: [
{
previous: { ...base.previous, ...previous },
next: { ...base.next, ...next },
},
],
},
}
)
}
it('should set `false` when changing from `true`', () => {
expect(
build({ savedToLineItem: true }, { savedToLineItem: false })
).toEqual([
{
action: 'setSavedToLineItem',
attributeName: 'attribute-name',
savedToLineItem: false,
},
])
})
it('should set `false` when previously undefined', () => {
expect(build({}, { savedToLineItem: false })).toEqual([
{
action: 'setSavedToLineItem',
attributeName: 'attribute-name',
savedToLineItem: false,
},
])
})
it('should omit the value when changing to undefined', () => {
expect(build({ savedToLineItem: false }, {})).toEqual([
{ action: 'setSavedToLineItem', attributeName: 'attribute-name' },
])
})
it('should not generate an action when both are undefined', () => {
expect(build({}, {})).toEqual([])
})
})
describe('without next', () => {
beforeEach(() => {
attributeDefinitionDraftItem = createAttributeDefinitionDraftItem({
Expand Down
Loading