@webitel/api-services 26.12.37 → 26.12.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -146,6 +146,46 @@ describe('WorkingConditionsAPI', () => {
|
|
|
146
146
|
});
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
+
it.each([
|
|
150
|
+
'add',
|
|
151
|
+
'update',
|
|
152
|
+
] as const)('%s sends a cleared shift template (`{}`) as null', async (method) => {
|
|
153
|
+
await WorkingConditionsAPI[method]({
|
|
154
|
+
itemId: '1',
|
|
155
|
+
itemInstance: {
|
|
156
|
+
...formItem,
|
|
157
|
+
shiftTemplate: {},
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const serviceMethod =
|
|
162
|
+
method === 'add'
|
|
163
|
+
? service.workingConditionServiceCreateWorkingCondition
|
|
164
|
+
: service.workingConditionServiceUpdateWorkingCondition;
|
|
165
|
+
const body = serviceMethod.mock.calls[0].at(-1);
|
|
166
|
+
expect(body.item.shift_template).toBeNull();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('keeps a selected shift template', async () => {
|
|
170
|
+
await WorkingConditionsAPI.update({
|
|
171
|
+
itemId: '1',
|
|
172
|
+
itemInstance: {
|
|
173
|
+
...formItem,
|
|
174
|
+
shiftTemplate: {
|
|
175
|
+
id: '3',
|
|
176
|
+
name: 'Full time',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const [, body] =
|
|
182
|
+
service.workingConditionServiceUpdateWorkingCondition.mock.calls[0];
|
|
183
|
+
expect(body.item.shift_template).toEqual({
|
|
184
|
+
id: '3',
|
|
185
|
+
name: 'Full time',
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
149
189
|
it('update sends the id separately and drops it from the item', async () => {
|
|
150
190
|
await WorkingConditionsAPI.update({
|
|
151
191
|
itemId: '1',
|
|
@@ -33,6 +33,15 @@ const itemResponseHandler = (response: ApiParams) => ({
|
|
|
33
33
|
...response.item,
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
const clearEmptyShiftTemplate = (item: ApiParams) => ({
|
|
37
|
+
...item,
|
|
38
|
+
...(item.shiftTemplate && !item.shiftTemplate.id
|
|
39
|
+
? {
|
|
40
|
+
shiftTemplate: null,
|
|
41
|
+
}
|
|
42
|
+
: {}),
|
|
43
|
+
});
|
|
44
|
+
|
|
36
45
|
const getWorkingConditionsList = async (params: ApiParams) => {
|
|
37
46
|
const requestParams = applyTransform(params, [
|
|
38
47
|
merge(getDefaultGetParams()),
|
|
@@ -89,6 +98,7 @@ const getWorkingCondition = async ({ itemId: id }: GetItemParams) => {
|
|
|
89
98
|
const addWorkingCondition = async ({ itemInstance }: AddItemParams) => {
|
|
90
99
|
const item = applyTransform(itemInstance, [
|
|
91
100
|
sanitizeToWire(fieldsToSend),
|
|
101
|
+
clearEmptyShiftTemplate,
|
|
92
102
|
camelToSnake(),
|
|
93
103
|
]);
|
|
94
104
|
try {
|
|
@@ -115,6 +125,7 @@ const updateWorkingCondition = async ({
|
|
|
115
125
|
}: UpdateItemParams) => {
|
|
116
126
|
const item = applyTransform(itemInstance, [
|
|
117
127
|
sanitizeToWire(fieldsToSend),
|
|
128
|
+
clearEmptyShiftTemplate,
|
|
118
129
|
camelToSnake(),
|
|
119
130
|
]);
|
|
120
131
|
try {
|