@contentful/field-editor-slug 1.8.13 → 2.0.0
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/dist/cjs/SlugEditor.js +12 -10
- package/dist/cjs/SlugEditor.test.js +46 -35
- package/dist/esm/SlugEditor.js +12 -10
- package/dist/esm/SlugEditor.test.js +46 -35
- package/package.json +5 -5
package/dist/cjs/SlugEditor.js
CHANGED
|
@@ -81,7 +81,7 @@ function FieldConnectorCallback({ Component, value, disabled, setValue, errors,
|
|
|
81
81
|
}
|
|
82
82
|
function SlugEditor(props) {
|
|
83
83
|
const { field, parameters, id } = props;
|
|
84
|
-
const { locales, entry,
|
|
84
|
+
const { locales, entry, cma } = props.baseSdk;
|
|
85
85
|
if (!isSupportedFieldTypes(field.type)) {
|
|
86
86
|
throw new Error(`"${field.type}" field type is not supported by SlugEditor`);
|
|
87
87
|
}
|
|
@@ -92,14 +92,16 @@ function SlugEditor(props) {
|
|
|
92
92
|
const isOptionalFieldLocale = Boolean(!field.required || isLocaleOptional);
|
|
93
93
|
const isOptionalLocaleWithFallback = Boolean(isOptionalFieldLocale && localeFallbackCode && locales.available.includes(localeFallbackCode));
|
|
94
94
|
const performUniqueCheck = _react.useCallback((value)=>{
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
return cma.entry.getMany({
|
|
96
|
+
query: {
|
|
97
|
+
content_type: entrySys?.contentType?.sys?.id,
|
|
98
|
+
[`fields.${field.id}.${field.locale}`]: value,
|
|
99
|
+
'sys.id[ne]': entrySys.id,
|
|
100
|
+
'sys.publishedAt[exists]': true,
|
|
101
|
+
limit: 0
|
|
102
|
+
},
|
|
103
|
+
releaseId: undefined
|
|
104
|
+
}).then((res)=>{
|
|
103
105
|
return res.total === 0;
|
|
104
106
|
});
|
|
105
107
|
}, [
|
|
@@ -107,7 +109,7 @@ function SlugEditor(props) {
|
|
|
107
109
|
field.id,
|
|
108
110
|
field.locale,
|
|
109
111
|
entrySys.id,
|
|
110
|
-
|
|
112
|
+
cma.entry
|
|
111
113
|
]);
|
|
112
114
|
return /*#__PURE__*/ _react.createElement(_TrackingFieldConnector.TrackingFieldConnector, {
|
|
113
115
|
sdk: props.baseSdk,
|
|
@@ -79,10 +79,12 @@ function createMocks(initialValues = {}) {
|
|
|
79
79
|
}), initialValues.descriptionField || '');
|
|
80
80
|
const sdk = {
|
|
81
81
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)(),
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
cma: {
|
|
83
|
+
entry: {
|
|
84
|
+
getMany: jest.fn().mockResolvedValue({
|
|
85
|
+
total: 0
|
|
86
|
+
})
|
|
87
|
+
}
|
|
86
88
|
},
|
|
87
89
|
entry: {
|
|
88
90
|
getSys: jest.fn().mockReturnValue({
|
|
@@ -129,7 +131,7 @@ describe('SlugEditor', ()=>{
|
|
|
129
131
|
await (0, _react1.waitFor)(()=>{
|
|
130
132
|
expect(field.setValue).not.toHaveBeenCalled();
|
|
131
133
|
expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
|
|
132
|
-
expect(sdk.
|
|
134
|
+
expect(sdk.cma.entry.getMany).not.toHaveBeenCalled();
|
|
133
135
|
expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
|
|
134
136
|
expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
|
|
135
137
|
});
|
|
@@ -178,7 +180,7 @@ describe('SlugEditor', ()=>{
|
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
182
|
});
|
|
181
|
-
sdk.
|
|
183
|
+
sdk.cma.entry.getMany.mockResolvedValue({
|
|
182
184
|
total: 0
|
|
183
185
|
});
|
|
184
186
|
const { queryByTestId, queryByText } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_SlugEditor.SlugEditor, {
|
|
@@ -188,14 +190,17 @@ describe('SlugEditor', ()=>{
|
|
|
188
190
|
}));
|
|
189
191
|
await (0, _react1.waitFor)(()=>{
|
|
190
192
|
expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
|
|
191
|
-
expect(sdk.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
193
|
+
expect(sdk.cma.entry.getMany).toHaveBeenLastCalledWith({
|
|
194
|
+
query: {
|
|
195
|
+
content_type: 'content-type-id',
|
|
196
|
+
'fields.slug-id.en-US': 'slug-value',
|
|
197
|
+
limit: 0,
|
|
198
|
+
'sys.id[ne]': 'entry-id',
|
|
199
|
+
'sys.publishedAt[exists]': true
|
|
200
|
+
},
|
|
201
|
+
releaseid: undefined
|
|
197
202
|
});
|
|
198
|
-
expect(sdk.
|
|
203
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(1);
|
|
199
204
|
expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
|
|
200
205
|
expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
|
|
201
206
|
});
|
|
@@ -214,7 +219,7 @@ describe('SlugEditor', ()=>{
|
|
|
214
219
|
}
|
|
215
220
|
}
|
|
216
221
|
});
|
|
217
|
-
sdk.
|
|
222
|
+
sdk.cma.entry.getMany.mockResolvedValue({
|
|
218
223
|
total: 2
|
|
219
224
|
});
|
|
220
225
|
const { queryByTestId, queryByText, getByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_SlugEditor.SlugEditor, {
|
|
@@ -224,19 +229,22 @@ describe('SlugEditor', ()=>{
|
|
|
224
229
|
}));
|
|
225
230
|
await (0, _react1.waitFor)(()=>{
|
|
226
231
|
expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
|
|
227
|
-
expect(sdk.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
232
|
+
expect(sdk.cma.entry.getMany).toHaveBeenLastCalledWith({
|
|
233
|
+
query: {
|
|
234
|
+
content_type: 'content-type-id',
|
|
235
|
+
'fields.slug-id.en-US': 'slug-value',
|
|
236
|
+
limit: 0,
|
|
237
|
+
'sys.id[ne]': 'entry-id',
|
|
238
|
+
'sys.publishedAt[exists]': true
|
|
239
|
+
},
|
|
240
|
+
releaseid: undefined
|
|
233
241
|
});
|
|
234
|
-
expect(sdk.
|
|
242
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(1);
|
|
235
243
|
expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
|
|
236
244
|
expect(queryByText('This slug has already been published in another entry')).toBeInTheDocument();
|
|
237
245
|
expect(getByTestId('cf-ui-text-input')).toHaveValue('slug-value');
|
|
238
246
|
});
|
|
239
|
-
sdk.
|
|
247
|
+
sdk.cma.entry.getMany.mockResolvedValue({
|
|
240
248
|
total: 0
|
|
241
249
|
});
|
|
242
250
|
_react1.fireEvent.change(getByTestId('cf-ui-text-input'), {
|
|
@@ -247,13 +255,16 @@ describe('SlugEditor', ()=>{
|
|
|
247
255
|
await (0, _react1.waitFor)(()=>{
|
|
248
256
|
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
249
257
|
expect(field.setValue).toHaveBeenCalledWith('123');
|
|
250
|
-
expect(sdk.
|
|
251
|
-
expect(sdk.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
258
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(2);
|
|
259
|
+
expect(sdk.cma.entry.getMany).toHaveBeenLastCalledWith({
|
|
260
|
+
query: {
|
|
261
|
+
content_type: 'content-type-id',
|
|
262
|
+
'fields.slug-id.en-US': '123',
|
|
263
|
+
limit: 0,
|
|
264
|
+
'sys.id[ne]': 'entry-id',
|
|
265
|
+
'sys.publishedAt[exists]': true
|
|
266
|
+
},
|
|
267
|
+
releaseid: undefined
|
|
257
268
|
});
|
|
258
269
|
expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
|
|
259
270
|
});
|
|
@@ -273,7 +284,7 @@ describe('SlugEditor', ()=>{
|
|
|
273
284
|
await (0, _react1.waitFor)(()=>{
|
|
274
285
|
expect(field.setValue).toHaveBeenCalled();
|
|
275
286
|
expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
|
|
276
|
-
expect(sdk.
|
|
287
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalled();
|
|
277
288
|
expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
|
|
278
289
|
expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
|
|
279
290
|
});
|
|
@@ -297,13 +308,13 @@ describe('SlugEditor', ()=>{
|
|
|
297
308
|
await (0, _react1.waitFor)(()=>{
|
|
298
309
|
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
299
310
|
expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
|
|
300
|
-
expect(sdk.
|
|
311
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(2);
|
|
301
312
|
});
|
|
302
313
|
await sdk.entry.fields['title-id'].setValue('фраза написанная по русски');
|
|
303
314
|
await (0, _react1.waitFor)(()=>{
|
|
304
315
|
expect(field.setValue).toHaveBeenCalledTimes(3);
|
|
305
316
|
expect(field.setValue).toHaveBeenLastCalledWith('fraza-napisannaya-po-russki');
|
|
306
|
-
expect(sdk.
|
|
317
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(3);
|
|
307
318
|
});
|
|
308
319
|
});
|
|
309
320
|
it('should generate value from title if it is not empty', async ()=>{
|
|
@@ -325,7 +336,7 @@ describe('SlugEditor', ()=>{
|
|
|
325
336
|
await (0, _react1.waitFor)(()=>{
|
|
326
337
|
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
327
338
|
expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
|
|
328
|
-
expect(sdk.
|
|
339
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(2);
|
|
329
340
|
});
|
|
330
341
|
});
|
|
331
342
|
it('should stop tracking value after user intentionally changes slug value', async ()=>{
|
|
@@ -346,7 +357,7 @@ describe('SlugEditor', ()=>{
|
|
|
346
357
|
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
347
358
|
expect(field.setValue).toHaveBeenCalledWith('untitled-entry-2020-01-24-at-15-33-47');
|
|
348
359
|
expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
|
|
349
|
-
expect(sdk.
|
|
360
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(2);
|
|
350
361
|
});
|
|
351
362
|
_react1.fireEvent.change(getByTestId('cf-ui-text-input'), {
|
|
352
363
|
target: {
|
|
@@ -523,7 +534,7 @@ describe('SlugEditor', ()=>{
|
|
|
523
534
|
await (0, _react1.waitFor)(()=>{
|
|
524
535
|
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
525
536
|
expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
|
|
526
|
-
expect(sdk.
|
|
537
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(2);
|
|
527
538
|
});
|
|
528
539
|
});
|
|
529
540
|
});
|
package/dist/esm/SlugEditor.js
CHANGED
|
@@ -30,7 +30,7 @@ function FieldConnectorCallback({ Component, value, disabled, setValue, errors,
|
|
|
30
30
|
}
|
|
31
31
|
export function SlugEditor(props) {
|
|
32
32
|
const { field, parameters, id } = props;
|
|
33
|
-
const { locales, entry,
|
|
33
|
+
const { locales, entry, cma } = props.baseSdk;
|
|
34
34
|
if (!isSupportedFieldTypes(field.type)) {
|
|
35
35
|
throw new Error(`"${field.type}" field type is not supported by SlugEditor`);
|
|
36
36
|
}
|
|
@@ -41,14 +41,16 @@ export function SlugEditor(props) {
|
|
|
41
41
|
const isOptionalFieldLocale = Boolean(!field.required || isLocaleOptional);
|
|
42
42
|
const isOptionalLocaleWithFallback = Boolean(isOptionalFieldLocale && localeFallbackCode && locales.available.includes(localeFallbackCode));
|
|
43
43
|
const performUniqueCheck = React.useCallback((value)=>{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
return cma.entry.getMany({
|
|
45
|
+
query: {
|
|
46
|
+
content_type: entrySys?.contentType?.sys?.id,
|
|
47
|
+
[`fields.${field.id}.${field.locale}`]: value,
|
|
48
|
+
'sys.id[ne]': entrySys.id,
|
|
49
|
+
'sys.publishedAt[exists]': true,
|
|
50
|
+
limit: 0
|
|
51
|
+
},
|
|
52
|
+
releaseId: undefined
|
|
53
|
+
}).then((res)=>{
|
|
52
54
|
return res.total === 0;
|
|
53
55
|
});
|
|
54
56
|
}, [
|
|
@@ -56,7 +58,7 @@ export function SlugEditor(props) {
|
|
|
56
58
|
field.id,
|
|
57
59
|
field.locale,
|
|
58
60
|
entrySys.id,
|
|
59
|
-
|
|
61
|
+
cma.entry
|
|
60
62
|
]);
|
|
61
63
|
return /*#__PURE__*/ React.createElement(TrackingFieldConnector, {
|
|
62
64
|
sdk: props.baseSdk,
|
|
@@ -34,10 +34,12 @@ function createMocks(initialValues = {}) {
|
|
|
34
34
|
}), initialValues.descriptionField || '');
|
|
35
35
|
const sdk = {
|
|
36
36
|
locales: createFakeLocalesAPI(),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
cma: {
|
|
38
|
+
entry: {
|
|
39
|
+
getMany: jest.fn().mockResolvedValue({
|
|
40
|
+
total: 0
|
|
41
|
+
})
|
|
42
|
+
}
|
|
41
43
|
},
|
|
42
44
|
entry: {
|
|
43
45
|
getSys: jest.fn().mockReturnValue({
|
|
@@ -84,7 +86,7 @@ describe('SlugEditor', ()=>{
|
|
|
84
86
|
await waitFor(()=>{
|
|
85
87
|
expect(field.setValue).not.toHaveBeenCalled();
|
|
86
88
|
expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
|
|
87
|
-
expect(sdk.
|
|
89
|
+
expect(sdk.cma.entry.getMany).not.toHaveBeenCalled();
|
|
88
90
|
expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
|
|
89
91
|
expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
|
|
90
92
|
});
|
|
@@ -133,7 +135,7 @@ describe('SlugEditor', ()=>{
|
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
});
|
|
136
|
-
sdk.
|
|
138
|
+
sdk.cma.entry.getMany.mockResolvedValue({
|
|
137
139
|
total: 0
|
|
138
140
|
});
|
|
139
141
|
const { queryByTestId, queryByText } = render(/*#__PURE__*/ React.createElement(SlugEditor, {
|
|
@@ -143,14 +145,17 @@ describe('SlugEditor', ()=>{
|
|
|
143
145
|
}));
|
|
144
146
|
await waitFor(()=>{
|
|
145
147
|
expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
|
|
146
|
-
expect(sdk.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
expect(sdk.cma.entry.getMany).toHaveBeenLastCalledWith({
|
|
149
|
+
query: {
|
|
150
|
+
content_type: 'content-type-id',
|
|
151
|
+
'fields.slug-id.en-US': 'slug-value',
|
|
152
|
+
limit: 0,
|
|
153
|
+
'sys.id[ne]': 'entry-id',
|
|
154
|
+
'sys.publishedAt[exists]': true
|
|
155
|
+
},
|
|
156
|
+
releaseid: undefined
|
|
152
157
|
});
|
|
153
|
-
expect(sdk.
|
|
158
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(1);
|
|
154
159
|
expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
|
|
155
160
|
expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
|
|
156
161
|
});
|
|
@@ -169,7 +174,7 @@ describe('SlugEditor', ()=>{
|
|
|
169
174
|
}
|
|
170
175
|
}
|
|
171
176
|
});
|
|
172
|
-
sdk.
|
|
177
|
+
sdk.cma.entry.getMany.mockResolvedValue({
|
|
173
178
|
total: 2
|
|
174
179
|
});
|
|
175
180
|
const { queryByTestId, queryByText, getByTestId } = render(/*#__PURE__*/ React.createElement(SlugEditor, {
|
|
@@ -179,19 +184,22 @@ describe('SlugEditor', ()=>{
|
|
|
179
184
|
}));
|
|
180
185
|
await waitFor(()=>{
|
|
181
186
|
expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
|
|
182
|
-
expect(sdk.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
expect(sdk.cma.entry.getMany).toHaveBeenLastCalledWith({
|
|
188
|
+
query: {
|
|
189
|
+
content_type: 'content-type-id',
|
|
190
|
+
'fields.slug-id.en-US': 'slug-value',
|
|
191
|
+
limit: 0,
|
|
192
|
+
'sys.id[ne]': 'entry-id',
|
|
193
|
+
'sys.publishedAt[exists]': true
|
|
194
|
+
},
|
|
195
|
+
releaseid: undefined
|
|
188
196
|
});
|
|
189
|
-
expect(sdk.
|
|
197
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(1);
|
|
190
198
|
expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
|
|
191
199
|
expect(queryByText('This slug has already been published in another entry')).toBeInTheDocument();
|
|
192
200
|
expect(getByTestId('cf-ui-text-input')).toHaveValue('slug-value');
|
|
193
201
|
});
|
|
194
|
-
sdk.
|
|
202
|
+
sdk.cma.entry.getMany.mockResolvedValue({
|
|
195
203
|
total: 0
|
|
196
204
|
});
|
|
197
205
|
fireEvent.change(getByTestId('cf-ui-text-input'), {
|
|
@@ -202,13 +210,16 @@ describe('SlugEditor', ()=>{
|
|
|
202
210
|
await waitFor(()=>{
|
|
203
211
|
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
204
212
|
expect(field.setValue).toHaveBeenCalledWith('123');
|
|
205
|
-
expect(sdk.
|
|
206
|
-
expect(sdk.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
213
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(2);
|
|
214
|
+
expect(sdk.cma.entry.getMany).toHaveBeenLastCalledWith({
|
|
215
|
+
query: {
|
|
216
|
+
content_type: 'content-type-id',
|
|
217
|
+
'fields.slug-id.en-US': '123',
|
|
218
|
+
limit: 0,
|
|
219
|
+
'sys.id[ne]': 'entry-id',
|
|
220
|
+
'sys.publishedAt[exists]': true
|
|
221
|
+
},
|
|
222
|
+
releaseid: undefined
|
|
212
223
|
});
|
|
213
224
|
expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
|
|
214
225
|
});
|
|
@@ -228,7 +239,7 @@ describe('SlugEditor', ()=>{
|
|
|
228
239
|
await waitFor(()=>{
|
|
229
240
|
expect(field.setValue).toHaveBeenCalled();
|
|
230
241
|
expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
|
|
231
|
-
expect(sdk.
|
|
242
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalled();
|
|
232
243
|
expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
|
|
233
244
|
expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
|
|
234
245
|
});
|
|
@@ -252,13 +263,13 @@ describe('SlugEditor', ()=>{
|
|
|
252
263
|
await waitFor(()=>{
|
|
253
264
|
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
254
265
|
expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
|
|
255
|
-
expect(sdk.
|
|
266
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(2);
|
|
256
267
|
});
|
|
257
268
|
await sdk.entry.fields['title-id'].setValue('фраза написанная по русски');
|
|
258
269
|
await waitFor(()=>{
|
|
259
270
|
expect(field.setValue).toHaveBeenCalledTimes(3);
|
|
260
271
|
expect(field.setValue).toHaveBeenLastCalledWith('fraza-napisannaya-po-russki');
|
|
261
|
-
expect(sdk.
|
|
272
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(3);
|
|
262
273
|
});
|
|
263
274
|
});
|
|
264
275
|
it('should generate value from title if it is not empty', async ()=>{
|
|
@@ -280,7 +291,7 @@ describe('SlugEditor', ()=>{
|
|
|
280
291
|
await waitFor(()=>{
|
|
281
292
|
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
282
293
|
expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
|
|
283
|
-
expect(sdk.
|
|
294
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(2);
|
|
284
295
|
});
|
|
285
296
|
});
|
|
286
297
|
it('should stop tracking value after user intentionally changes slug value', async ()=>{
|
|
@@ -301,7 +312,7 @@ describe('SlugEditor', ()=>{
|
|
|
301
312
|
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
302
313
|
expect(field.setValue).toHaveBeenCalledWith('untitled-entry-2020-01-24-at-15-33-47');
|
|
303
314
|
expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
|
|
304
|
-
expect(sdk.
|
|
315
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(2);
|
|
305
316
|
});
|
|
306
317
|
fireEvent.change(getByTestId('cf-ui-text-input'), {
|
|
307
318
|
target: {
|
|
@@ -478,7 +489,7 @@ describe('SlugEditor', ()=>{
|
|
|
478
489
|
await waitFor(()=>{
|
|
479
490
|
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
480
491
|
expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
|
|
481
|
-
expect(sdk.
|
|
492
|
+
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(2);
|
|
482
493
|
});
|
|
483
494
|
});
|
|
484
495
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-slug",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@contentful/f36-components": "^5.4.1",
|
|
40
40
|
"@contentful/f36-icons": "^5.4.1",
|
|
41
41
|
"@contentful/f36-tokens": "^5.1.0",
|
|
42
|
-
"@contentful/field-editor-shared": "^2.13.
|
|
42
|
+
"@contentful/field-editor-shared": "^2.13.8",
|
|
43
43
|
"@types/speakingurl": "^13.0.2",
|
|
44
44
|
"emotion": "^10.0.17",
|
|
45
45
|
"lodash": "^4.17.15",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
"use-debounce": "^10.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@contentful/app-sdk": "^4.
|
|
50
|
+
"@contentful/app-sdk": "^4.45.0",
|
|
51
51
|
"@contentful/field-editor-test-utils": "^1.6.2",
|
|
52
52
|
"@lingui/core": "5.3.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@contentful/app-sdk": "^4.
|
|
55
|
+
"@contentful/app-sdk": "^4.45.0",
|
|
56
56
|
"@lingui/core": "^5.3.0",
|
|
57
57
|
"react": ">=16.8.0"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"registry": "https://npm.pkg.github.com/"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "84767c885db51a13c76ee44481f81bdbda708d3e"
|
|
63
63
|
}
|