Description
When an empty string is provided as the orderHint
of a category an invalid sync-action
is generated.
I created the following tests which should succeed but fail currently (first one fails, second one is to ensure we don't change existing behaviour and currently succeeds):
// nodejs/packages/sync-actions/test/category-sync.spec.js
describe('changeOrderHint', () => {
describe('when setting to an empty string', () => {
it('should build a `changeOrderHint` action', () => {
const before = { orderHint: 'foo' }
const now = { orderHint: '' }
const actual = categorySync.buildActions(now, before)
const expected = [
{
action: 'changeOrderHint',
value: '',
},
]
expect(actual).toEqual(expected)
})
})
describe('when not provided', () => {
it('should not build an update action', () => {
const before = { orderHint: 'foo' }
const now = {}
const actual = categorySync.buildActions(now, before)
const expected = []
expect(actual).toEqual(expected)
})
})
})
Expected Behavior
The following sync-actions should be generated in the first case:
[
{
action: 'changeOrderHint',
value: '',
},
]
Current Behavior
The following sync action is generated in the first case:
[
{
action: 'changeOrderHint',
},
]
This is an invalid sync action as value
is a required field. Providing an empty string as the value is valid and supported by the API.
Context
In the MC, when trying to let users set an empty orderHint
for a category they get an API error instead of having the changes saved successfully.
Possible Solution
Note
I tried to push a failing test so you could work on that, but I don't have sufficient permissions to this repository :( You can add the snippet I provided above to the Actions
section of the tests.