@contentful/field-editor-slug 1.3.0 → 1.3.2

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.
@@ -5,14 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  const _react = _interop_require_wildcard(require("react"));
6
6
  const _fieldeditortestutils = require("@contentful/field-editor-test-utils");
7
7
  const _react1 = require("@testing-library/react");
8
- const _identity = _interop_require_default(require("lodash/identity"));
9
8
  require("@testing-library/jest-dom/extend-expect");
10
9
  const _SlugEditor = require("./SlugEditor");
11
- function _interop_require_default(obj) {
12
- return obj && obj.__esModule ? obj : {
13
- default: obj
14
- };
15
- }
16
10
  function _getRequireWildcardCache(nodeInterop) {
17
11
  if (typeof WeakMap !== "function") return null;
18
12
  var cacheBabelInterop = new WeakMap();
@@ -55,11 +49,6 @@ function _interop_require_wildcard(obj, nodeInterop) {
55
49
  (0, _react1.configure)({
56
50
  testIdAttribute: 'data-test-id'
57
51
  });
58
- jest.mock('lodash/throttle', ()=>({
59
- default: _identity.default
60
- }), {
61
- virtual: true
62
- });
63
52
  jest.mock('use-debounce', ()=>({
64
53
  useDebounce: (text)=>[
65
54
  text
@@ -135,12 +124,13 @@ describe('SlugEditor', ()=>{
135
124
  baseSdk: sdk,
136
125
  isInitiallyDisabled: false
137
126
  }));
138
- await (0, _react1.wait)();
139
- expect(field.setValue).not.toHaveBeenCalled();
140
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
141
- expect(sdk.space.getEntries).not.toHaveBeenCalled();
142
- expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
143
- expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
127
+ await (0, _react1.waitFor)(()=>{
128
+ expect(field.setValue).not.toHaveBeenCalled();
129
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
130
+ expect(sdk.space.getEntries).not.toHaveBeenCalled();
131
+ expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
132
+ expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
133
+ });
144
134
  });
145
135
  it('when title and slug are the same field', async ()=>{
146
136
  const { field , titleField , sdk } = createMocks();
@@ -150,9 +140,10 @@ describe('SlugEditor', ()=>{
150
140
  baseSdk: sdk,
151
141
  isInitiallyDisabled: false
152
142
  }));
153
- await (0, _react1.wait)();
154
- expect(titleField.onValueChanged).not.toHaveBeenCalled();
155
- expect(field.setValue).not.toHaveBeenCalled();
143
+ await (0, _react1.waitFor)(()=>{
144
+ expect(titleField.onValueChanged).not.toHaveBeenCalled();
145
+ expect(field.setValue).not.toHaveBeenCalled();
146
+ });
156
147
  });
157
148
  it('when a saved slug is different from a title at the render', async ()=>{
158
149
  const { field , titleField , sdk } = createMocks({
@@ -164,9 +155,10 @@ describe('SlugEditor', ()=>{
164
155
  baseSdk: sdk,
165
156
  isInitiallyDisabled: false
166
157
  }));
167
- await (0, _react1.wait)();
168
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
169
- expect(field.setValue).not.toHaveBeenCalled();
158
+ await (0, _react1.waitFor)(()=>{
159
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
160
+ expect(field.setValue).not.toHaveBeenCalled();
161
+ });
170
162
  });
171
163
  });
172
164
  describe('should check for uniqueness', ()=>{
@@ -192,18 +184,19 @@ describe('SlugEditor', ()=>{
192
184
  baseSdk: sdk,
193
185
  isInitiallyDisabled: false
194
186
  }));
195
- await (0, _react1.wait)();
196
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
197
- expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
198
- content_type: 'content-type-id',
199
- 'fields.slug-id.en-US': 'slug-value',
200
- limit: 0,
201
- 'sys.id[ne]': 'entry-id',
202
- 'sys.publishedAt[exists]': true
203
- });
204
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(1);
205
- expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
206
- expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
187
+ await (0, _react1.waitFor)(()=>{
188
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
189
+ expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
190
+ content_type: 'content-type-id',
191
+ 'fields.slug-id.en-US': 'slug-value',
192
+ limit: 0,
193
+ 'sys.id[ne]': 'entry-id',
194
+ 'sys.publishedAt[exists]': true
195
+ });
196
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(1);
197
+ expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
198
+ expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
199
+ });
207
200
  });
208
201
  it('if it is not published', async ()=>{
209
202
  const { field , titleField , sdk } = createMocks({
@@ -227,19 +220,20 @@ describe('SlugEditor', ()=>{
227
220
  baseSdk: sdk,
228
221
  isInitiallyDisabled: false
229
222
  }));
230
- await (0, _react1.wait)();
231
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
232
- expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
233
- content_type: 'content-type-id',
234
- 'fields.slug-id.en-US': 'slug-value',
235
- limit: 0,
236
- 'sys.id[ne]': 'entry-id',
237
- 'sys.publishedAt[exists]': true
238
- });
239
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(1);
240
- expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
241
- expect(queryByText('This slug has already been published in another entry')).toBeInTheDocument();
242
- expect(getByTestId('cf-ui-text-input')).toHaveValue('slug-value');
223
+ await (0, _react1.waitFor)(()=>{
224
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
225
+ expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
226
+ content_type: 'content-type-id',
227
+ 'fields.slug-id.en-US': 'slug-value',
228
+ limit: 0,
229
+ 'sys.id[ne]': 'entry-id',
230
+ 'sys.publishedAt[exists]': true
231
+ });
232
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(1);
233
+ expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
234
+ expect(queryByText('This slug has already been published in another entry')).toBeInTheDocument();
235
+ expect(getByTestId('cf-ui-text-input')).toHaveValue('slug-value');
236
+ });
243
237
  sdk.space.getEntries.mockResolvedValue({
244
238
  total: 0
245
239
  });
@@ -248,18 +242,19 @@ describe('SlugEditor', ()=>{
248
242
  value: '123'
249
243
  }
250
244
  });
251
- await (0, _react1.wait)();
252
- expect(field.setValue).toHaveBeenCalledTimes(1);
253
- expect(field.setValue).toHaveBeenCalledWith('123');
254
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
255
- expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
256
- content_type: 'content-type-id',
257
- 'fields.slug-id.en-US': '123',
258
- limit: 0,
259
- 'sys.id[ne]': 'entry-id',
260
- 'sys.publishedAt[exists]': true
261
- });
262
- expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
245
+ await (0, _react1.waitFor)(()=>{
246
+ expect(field.setValue).toHaveBeenCalledTimes(1);
247
+ expect(field.setValue).toHaveBeenCalledWith('123');
248
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
249
+ expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
250
+ content_type: 'content-type-id',
251
+ 'fields.slug-id.en-US': '123',
252
+ limit: 0,
253
+ 'sys.id[ne]': 'entry-id',
254
+ 'sys.publishedAt[exists]': true
255
+ });
256
+ expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
257
+ });
263
258
  });
264
259
  });
265
260
  describe('should react to title changes', ()=>{
@@ -273,12 +268,13 @@ describe('SlugEditor', ()=>{
273
268
  baseSdk: sdk,
274
269
  isInitiallyDisabled: true
275
270
  }));
276
- await (0, _react1.wait)();
277
- expect(field.setValue).toHaveBeenCalled();
278
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
279
- expect(sdk.space.getEntries).toHaveBeenCalled();
280
- expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
281
- expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
271
+ await (0, _react1.waitFor)(()=>{
272
+ expect(field.setValue).toHaveBeenCalled();
273
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
274
+ expect(sdk.space.getEntries).toHaveBeenCalled();
275
+ expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
276
+ expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
277
+ });
282
278
  });
283
279
  it('should generate unique value with date if title is empty', async ()=>{
284
280
  const { field , titleField , sdk } = createMocks({
@@ -290,20 +286,23 @@ describe('SlugEditor', ()=>{
290
286
  baseSdk: sdk,
291
287
  isInitiallyDisabled: false
292
288
  }));
293
- await (0, _react1.wait)();
294
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
295
- expect(field.setValue).toHaveBeenCalledTimes(1);
296
- expect(field.setValue).toHaveBeenLastCalledWith('untitled-entry-2020-01-24-at-15-33-47');
289
+ await (0, _react1.waitFor)(()=>{
290
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
291
+ expect(field.setValue).toHaveBeenCalledTimes(1);
292
+ expect(field.setValue).toHaveBeenLastCalledWith('untitled-entry-2020-01-24-at-15-33-47');
293
+ });
297
294
  await sdk.entry.fields['title-id'].setValue('Hello world!');
298
- await (0, _react1.wait)();
299
- expect(field.setValue).toHaveBeenCalledTimes(2);
300
- expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
301
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
295
+ await (0, _react1.waitFor)(()=>{
296
+ expect(field.setValue).toHaveBeenCalledTimes(2);
297
+ expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
298
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
299
+ });
302
300
  await sdk.entry.fields['title-id'].setValue('фраза написанная по русски');
303
- await (0, _react1.wait)();
304
- expect(field.setValue).toHaveBeenCalledTimes(3);
305
- expect(field.setValue).toHaveBeenLastCalledWith('fraza-napisannaya-po-russki');
306
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(3);
301
+ await (0, _react1.waitFor)(()=>{
302
+ expect(field.setValue).toHaveBeenCalledTimes(3);
303
+ expect(field.setValue).toHaveBeenLastCalledWith('fraza-napisannaya-po-russki');
304
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(3);
305
+ });
307
306
  });
308
307
  it('should generate value from title if it is not empty', async ()=>{
309
308
  const { field , titleField , sdk } = createMocks({
@@ -315,15 +314,17 @@ describe('SlugEditor', ()=>{
315
314
  baseSdk: sdk,
316
315
  isInitiallyDisabled: false
317
316
  }));
318
- await (0, _react1.wait)();
319
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
320
- expect(field.setValue).toHaveBeenCalledTimes(1);
321
- expect(field.setValue).toHaveBeenLastCalledWith('this-is-initial-title-value');
317
+ await (0, _react1.waitFor)(()=>{
318
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
319
+ expect(field.setValue).toHaveBeenCalledTimes(1);
320
+ expect(field.setValue).toHaveBeenLastCalledWith('this-is-initial-title-value');
321
+ });
322
322
  await sdk.entry.fields['title-id'].setValue('Hello world!');
323
- await (0, _react1.wait)();
324
- expect(field.setValue).toHaveBeenCalledTimes(2);
325
- expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
326
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
323
+ await (0, _react1.waitFor)(()=>{
324
+ expect(field.setValue).toHaveBeenCalledTimes(2);
325
+ expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
326
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
327
+ });
327
328
  });
328
329
  it('should stop tracking value after user intentionally changes slug value', async ()=>{
329
330
  const { field , titleField , sdk } = createMocks({
@@ -335,28 +336,33 @@ describe('SlugEditor', ()=>{
335
336
  baseSdk: sdk,
336
337
  isInitiallyDisabled: false
337
338
  }));
338
- await (0, _react1.wait)();
339
- await sdk.entry.fields['title-id'].setValue('Hello world!');
340
- await (0, _react1.wait)();
341
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
342
- expect(field.setValue).toHaveBeenCalledTimes(2);
343
- expect(field.setValue).toHaveBeenCalledWith('untitled-entry-2020-01-24-at-15-33-47');
344
- expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
345
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
339
+ await (0, _react1.waitFor)(async ()=>{
340
+ await sdk.entry.fields['title-id'].setValue('Hello world!');
341
+ });
342
+ await (0, _react1.waitFor)(()=>{
343
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
344
+ expect(field.setValue).toHaveBeenCalledTimes(2);
345
+ expect(field.setValue).toHaveBeenCalledWith('untitled-entry-2020-01-24-at-15-33-47');
346
+ expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
347
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
348
+ });
346
349
  _react1.fireEvent.change(getByTestId('cf-ui-text-input'), {
347
350
  target: {
348
351
  value: 'new-custom-slug'
349
352
  }
350
353
  });
351
- await (0, _react1.wait)();
352
- expect(field.setValue).toHaveBeenCalledTimes(3);
353
- expect(field.setValue).toHaveBeenLastCalledWith('new-custom-slug');
354
+ await (0, _react1.waitFor)(()=>{
355
+ expect(field.setValue).toHaveBeenCalledTimes(3);
356
+ expect(field.setValue).toHaveBeenLastCalledWith('new-custom-slug');
357
+ });
354
358
  await sdk.entry.fields['title-id'].setValue('I decided to update my title');
355
- await (0, _react1.wait)();
356
- expect(field.setValue).toHaveBeenCalledTimes(3);
359
+ await (0, _react1.waitFor)(()=>{
360
+ expect(field.setValue).toHaveBeenCalledTimes(3);
361
+ });
357
362
  await sdk.entry.fields['title-id'].setValue('I decided to update my title again');
358
- await (0, _react1.wait)();
359
- expect(field.setValue).toHaveBeenCalledTimes(3);
363
+ await (0, _react1.waitFor)(()=>{
364
+ expect(field.setValue).toHaveBeenCalledTimes(3);
365
+ });
360
366
  });
361
367
  it('should start tracking again after potential slug equals real one', async ()=>{
362
368
  const { field , sdk } = createMocks({
@@ -368,26 +374,31 @@ describe('SlugEditor', ()=>{
368
374
  baseSdk: sdk,
369
375
  isInitiallyDisabled: false
370
376
  }));
371
- await (0, _react1.wait)();
372
- await sdk.entry.fields['title-id'].setValue('ABC DEF');
373
- await (0, _react1.wait)();
374
- expect(field.setValue).toHaveBeenLastCalledWith('abc-def');
375
- expect(field.setValue).toHaveBeenCalledTimes(2);
377
+ await (0, _react1.waitFor)(async ()=>{
378
+ await sdk.entry.fields['title-id'].setValue('ABC DEF');
379
+ });
380
+ await (0, _react1.waitFor)(()=>{
381
+ expect(field.setValue).toHaveBeenLastCalledWith('abc-def');
382
+ expect(field.setValue).toHaveBeenCalledTimes(2);
383
+ });
376
384
  _react1.fireEvent.change(getByTestId('cf-ui-text-input'), {
377
385
  target: {
378
386
  value: 'abc'
379
387
  }
380
388
  });
381
389
  await sdk.entry.fields['title-id'].setValue('ABC D');
382
- await (0, _react1.wait)();
383
- expect(field.setValue).toHaveBeenLastCalledWith('abc');
384
- expect(field.setValue).toHaveBeenCalledTimes(3);
385
- await sdk.entry.fields['title-id'].setValue('ABC');
386
- await sdk.entry.fields['title-id'].setValue('ABC ABC');
387
- await (0, _react1.wait)();
388
- expect(field.setValue).toHaveBeenLastCalledWith('abc-abc');
389
- expect(field.setValue).toHaveBeenCalledTimes(4);
390
- await (0, _react1.wait)();
390
+ await (0, _react1.waitFor)(()=>{
391
+ expect(field.setValue).toHaveBeenLastCalledWith('abc');
392
+ expect(field.setValue).toHaveBeenCalledTimes(3);
393
+ });
394
+ await (0, _react1.waitFor)(async ()=>{
395
+ await sdk.entry.fields['title-id'].setValue('ABC');
396
+ await sdk.entry.fields['title-id'].setValue('ABC ABC');
397
+ });
398
+ await (0, _react1.waitFor)(()=>{
399
+ expect(field.setValue).toHaveBeenLastCalledWith('abc-abc');
400
+ expect(field.setValue).toHaveBeenCalledTimes(4);
401
+ });
391
402
  });
392
403
  });
393
404
  describe('for non default locales', ()=>{
@@ -413,10 +424,11 @@ describe('SlugEditor', ()=>{
413
424
  baseSdk: sdk,
414
425
  isInitiallyDisabled: false
415
426
  }));
416
- await (0, _react1.wait)();
417
- expect(field.setValue).toHaveBeenCalledWith('untitled-entry-2020-01-24-at-15-33-47');
418
- expect(titleField.onValueChanged).toHaveBeenCalledWith('ru-RU', expect.any(Function));
419
- expect(titleField.onValueChanged).toHaveBeenCalledWith('de-DE', expect.any(Function));
427
+ await (0, _react1.waitFor)(()=>{
428
+ expect(field.setValue).toHaveBeenCalledWith('untitled-entry-2020-01-24-at-15-33-47');
429
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('ru-RU', expect.any(Function));
430
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('de-DE', expect.any(Function));
431
+ });
420
432
  });
421
433
  it('locale is optional and has a fallback then it should track only current locale changes', async ()=>{
422
434
  const { sdk , field , titleField } = createMocks();
@@ -440,10 +452,11 @@ describe('SlugEditor', ()=>{
440
452
  baseSdk: sdk,
441
453
  isInitiallyDisabled: false
442
454
  }));
443
- await (0, _react1.wait)();
444
- expect(field.setValue).not.toHaveBeenCalled();
445
- expect(titleField.onValueChanged).toHaveBeenCalledWith('ru-RU', expect.any(Function));
446
- expect(titleField.onValueChanged).not.toHaveBeenCalledWith('de-DE', expect.any(Function));
455
+ await (0, _react1.waitFor)(()=>{
456
+ expect(field.setValue).not.toHaveBeenCalled();
457
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('ru-RU', expect.any(Function));
458
+ expect(titleField.onValueChanged).not.toHaveBeenCalledWith('de-DE', expect.any(Function));
459
+ });
447
460
  });
448
461
  });
449
462
  it('slug suggestion is limited to 75 symbols', async ()=>{
@@ -456,11 +469,13 @@ describe('SlugEditor', ()=>{
456
469
  baseSdk: sdk,
457
470
  isInitiallyDisabled: false
458
471
  }));
459
- await (0, _react1.wait)();
460
- await sdk.entry.fields['title-id'].setValue('a'.repeat(80));
461
- await (0, _react1.wait)();
462
- const expectedSlug = 'a'.repeat(75);
463
- expect(field.setValue).toHaveBeenLastCalledWith(expectedSlug);
472
+ await (0, _react1.waitFor)(async ()=>{
473
+ await sdk.entry.fields['title-id'].setValue('a'.repeat(80));
474
+ });
475
+ await (0, _react1.waitFor)(()=>{
476
+ const expectedSlug = 'a'.repeat(75);
477
+ expect(field.setValue).toHaveBeenLastCalledWith(expectedSlug);
478
+ });
464
479
  });
465
480
  it('slug suggestion does not contain cut-off words', async ()=>{
466
481
  const { field , sdk } = createMocks({
@@ -472,11 +487,13 @@ describe('SlugEditor', ()=>{
472
487
  baseSdk: sdk,
473
488
  isInitiallyDisabled: false
474
489
  }));
475
- await (0, _react1.wait)();
476
- await sdk.entry.fields['title-id'].setValue(`one two three ${'a'.repeat(80)}`);
477
- await (0, _react1.wait)();
478
- const expectedSlug = 'one-two-three';
479
- expect(field.setValue).toHaveBeenLastCalledWith(expectedSlug);
490
+ await (0, _react1.waitFor)(async ()=>{
491
+ await sdk.entry.fields['title-id'].setValue(`one two three ${'a'.repeat(80)}`);
492
+ });
493
+ await (0, _react1.waitFor)(()=>{
494
+ const expectedSlug = 'one-two-three';
495
+ expect(field.setValue).toHaveBeenLastCalledWith(expectedSlug);
496
+ });
480
497
  });
481
498
  it('should subscribe for changes in custom field id', async ()=>{
482
499
  const { field , titleField , descriptionField , sdk } = createMocks({
@@ -494,15 +511,17 @@ describe('SlugEditor', ()=>{
494
511
  }
495
512
  }
496
513
  }));
497
- await (0, _react1.wait)();
498
- expect(titleField.onValueChanged).not.toHaveBeenCalled();
499
- expect(descriptionField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
500
- expect(field.setValue).toHaveBeenCalledTimes(1);
501
- expect(field.setValue).toHaveBeenLastCalledWith('this-is-initial-description-value');
514
+ await (0, _react1.waitFor)(()=>{
515
+ expect(titleField.onValueChanged).not.toHaveBeenCalled();
516
+ expect(descriptionField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
517
+ expect(field.setValue).toHaveBeenCalledTimes(1);
518
+ expect(field.setValue).toHaveBeenLastCalledWith('this-is-initial-description-value');
519
+ });
502
520
  await sdk.entry.fields['description-id'].setValue('Hello world!');
503
- await (0, _react1.wait)();
504
- expect(field.setValue).toHaveBeenCalledTimes(2);
505
- expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
506
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
521
+ await (0, _react1.waitFor)(()=>{
522
+ expect(field.setValue).toHaveBeenCalledTimes(2);
523
+ expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
524
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
525
+ });
507
526
  });
508
527
  });
@@ -1,17 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { createFakeFieldAPI, createFakeLocalesAPI } from '@contentful/field-editor-test-utils';
3
- import { render, configure, cleanup, wait, fireEvent } from '@testing-library/react';
4
- import identity from 'lodash/identity';
3
+ import { cleanup, configure, fireEvent, render, waitFor } from '@testing-library/react';
5
4
  import '@testing-library/jest-dom/extend-expect';
6
5
  import { SlugEditor } from './SlugEditor';
7
6
  configure({
8
7
  testIdAttribute: 'data-test-id'
9
8
  });
10
- jest.mock('lodash/throttle', ()=>({
11
- default: identity
12
- }), {
13
- virtual: true
14
- });
15
9
  jest.mock('use-debounce', ()=>({
16
10
  useDebounce: (text)=>[
17
11
  text
@@ -87,12 +81,13 @@ describe('SlugEditor', ()=>{
87
81
  baseSdk: sdk,
88
82
  isInitiallyDisabled: false
89
83
  }));
90
- await wait();
91
- expect(field.setValue).not.toHaveBeenCalled();
92
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
93
- expect(sdk.space.getEntries).not.toHaveBeenCalled();
94
- expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
95
- expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
84
+ await waitFor(()=>{
85
+ expect(field.setValue).not.toHaveBeenCalled();
86
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
87
+ expect(sdk.space.getEntries).not.toHaveBeenCalled();
88
+ expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
89
+ expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
90
+ });
96
91
  });
97
92
  it('when title and slug are the same field', async ()=>{
98
93
  const { field , titleField , sdk } = createMocks();
@@ -102,9 +97,10 @@ describe('SlugEditor', ()=>{
102
97
  baseSdk: sdk,
103
98
  isInitiallyDisabled: false
104
99
  }));
105
- await wait();
106
- expect(titleField.onValueChanged).not.toHaveBeenCalled();
107
- expect(field.setValue).not.toHaveBeenCalled();
100
+ await waitFor(()=>{
101
+ expect(titleField.onValueChanged).not.toHaveBeenCalled();
102
+ expect(field.setValue).not.toHaveBeenCalled();
103
+ });
108
104
  });
109
105
  it('when a saved slug is different from a title at the render', async ()=>{
110
106
  const { field , titleField , sdk } = createMocks({
@@ -116,9 +112,10 @@ describe('SlugEditor', ()=>{
116
112
  baseSdk: sdk,
117
113
  isInitiallyDisabled: false
118
114
  }));
119
- await wait();
120
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
121
- expect(field.setValue).not.toHaveBeenCalled();
115
+ await waitFor(()=>{
116
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
117
+ expect(field.setValue).not.toHaveBeenCalled();
118
+ });
122
119
  });
123
120
  });
124
121
  describe('should check for uniqueness', ()=>{
@@ -144,18 +141,19 @@ describe('SlugEditor', ()=>{
144
141
  baseSdk: sdk,
145
142
  isInitiallyDisabled: false
146
143
  }));
147
- await wait();
148
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
149
- expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
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
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(1);
157
- expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
158
- expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
144
+ await waitFor(()=>{
145
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
146
+ expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
147
+ content_type: 'content-type-id',
148
+ 'fields.slug-id.en-US': 'slug-value',
149
+ limit: 0,
150
+ 'sys.id[ne]': 'entry-id',
151
+ 'sys.publishedAt[exists]': true
152
+ });
153
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(1);
154
+ expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
155
+ expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
156
+ });
159
157
  });
160
158
  it('if it is not published', async ()=>{
161
159
  const { field , titleField , sdk } = createMocks({
@@ -179,19 +177,20 @@ describe('SlugEditor', ()=>{
179
177
  baseSdk: sdk,
180
178
  isInitiallyDisabled: false
181
179
  }));
182
- await wait();
183
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
184
- expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
185
- content_type: 'content-type-id',
186
- 'fields.slug-id.en-US': 'slug-value',
187
- limit: 0,
188
- 'sys.id[ne]': 'entry-id',
189
- 'sys.publishedAt[exists]': true
190
- });
191
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(1);
192
- expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
193
- expect(queryByText('This slug has already been published in another entry')).toBeInTheDocument();
194
- expect(getByTestId('cf-ui-text-input')).toHaveValue('slug-value');
180
+ await waitFor(()=>{
181
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
182
+ expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
183
+ content_type: 'content-type-id',
184
+ 'fields.slug-id.en-US': 'slug-value',
185
+ limit: 0,
186
+ 'sys.id[ne]': 'entry-id',
187
+ 'sys.publishedAt[exists]': true
188
+ });
189
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(1);
190
+ expect(queryByTestId('slug-editor-spinner')).not.toBeInTheDocument();
191
+ expect(queryByText('This slug has already been published in another entry')).toBeInTheDocument();
192
+ expect(getByTestId('cf-ui-text-input')).toHaveValue('slug-value');
193
+ });
195
194
  sdk.space.getEntries.mockResolvedValue({
196
195
  total: 0
197
196
  });
@@ -200,18 +199,19 @@ describe('SlugEditor', ()=>{
200
199
  value: '123'
201
200
  }
202
201
  });
203
- await wait();
204
- expect(field.setValue).toHaveBeenCalledTimes(1);
205
- expect(field.setValue).toHaveBeenCalledWith('123');
206
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
207
- expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
208
- content_type: 'content-type-id',
209
- 'fields.slug-id.en-US': '123',
210
- limit: 0,
211
- 'sys.id[ne]': 'entry-id',
212
- 'sys.publishedAt[exists]': true
213
- });
214
- expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
202
+ await waitFor(()=>{
203
+ expect(field.setValue).toHaveBeenCalledTimes(1);
204
+ expect(field.setValue).toHaveBeenCalledWith('123');
205
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
206
+ expect(sdk.space.getEntries).toHaveBeenLastCalledWith({
207
+ content_type: 'content-type-id',
208
+ 'fields.slug-id.en-US': '123',
209
+ limit: 0,
210
+ 'sys.id[ne]': 'entry-id',
211
+ 'sys.publishedAt[exists]': true
212
+ });
213
+ expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
214
+ });
215
215
  });
216
216
  });
217
217
  describe('should react to title changes', ()=>{
@@ -225,12 +225,13 @@ describe('SlugEditor', ()=>{
225
225
  baseSdk: sdk,
226
226
  isInitiallyDisabled: true
227
227
  }));
228
- await wait();
229
- expect(field.setValue).toHaveBeenCalled();
230
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
231
- expect(sdk.space.getEntries).toHaveBeenCalled();
232
- expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
233
- expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
228
+ await waitFor(()=>{
229
+ expect(field.setValue).toHaveBeenCalled();
230
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
231
+ expect(sdk.space.getEntries).toHaveBeenCalled();
232
+ expect(sdk.entry.fields['title-id'].getValue).toHaveBeenCalledTimes(1);
233
+ expect(sdk.entry.getSys).toHaveBeenCalledTimes(2);
234
+ });
234
235
  });
235
236
  it('should generate unique value with date if title is empty', async ()=>{
236
237
  const { field , titleField , sdk } = createMocks({
@@ -242,20 +243,23 @@ describe('SlugEditor', ()=>{
242
243
  baseSdk: sdk,
243
244
  isInitiallyDisabled: false
244
245
  }));
245
- await wait();
246
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
247
- expect(field.setValue).toHaveBeenCalledTimes(1);
248
- expect(field.setValue).toHaveBeenLastCalledWith('untitled-entry-2020-01-24-at-15-33-47');
246
+ await waitFor(()=>{
247
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
248
+ expect(field.setValue).toHaveBeenCalledTimes(1);
249
+ expect(field.setValue).toHaveBeenLastCalledWith('untitled-entry-2020-01-24-at-15-33-47');
250
+ });
249
251
  await sdk.entry.fields['title-id'].setValue('Hello world!');
250
- await wait();
251
- expect(field.setValue).toHaveBeenCalledTimes(2);
252
- expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
253
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
252
+ await waitFor(()=>{
253
+ expect(field.setValue).toHaveBeenCalledTimes(2);
254
+ expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
255
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
256
+ });
254
257
  await sdk.entry.fields['title-id'].setValue('фраза написанная по русски');
255
- await wait();
256
- expect(field.setValue).toHaveBeenCalledTimes(3);
257
- expect(field.setValue).toHaveBeenLastCalledWith('fraza-napisannaya-po-russki');
258
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(3);
258
+ await waitFor(()=>{
259
+ expect(field.setValue).toHaveBeenCalledTimes(3);
260
+ expect(field.setValue).toHaveBeenLastCalledWith('fraza-napisannaya-po-russki');
261
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(3);
262
+ });
259
263
  });
260
264
  it('should generate value from title if it is not empty', async ()=>{
261
265
  const { field , titleField , sdk } = createMocks({
@@ -267,15 +271,17 @@ describe('SlugEditor', ()=>{
267
271
  baseSdk: sdk,
268
272
  isInitiallyDisabled: false
269
273
  }));
270
- await wait();
271
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
272
- expect(field.setValue).toHaveBeenCalledTimes(1);
273
- expect(field.setValue).toHaveBeenLastCalledWith('this-is-initial-title-value');
274
+ await waitFor(()=>{
275
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
276
+ expect(field.setValue).toHaveBeenCalledTimes(1);
277
+ expect(field.setValue).toHaveBeenLastCalledWith('this-is-initial-title-value');
278
+ });
274
279
  await sdk.entry.fields['title-id'].setValue('Hello world!');
275
- await wait();
276
- expect(field.setValue).toHaveBeenCalledTimes(2);
277
- expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
278
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
280
+ await waitFor(()=>{
281
+ expect(field.setValue).toHaveBeenCalledTimes(2);
282
+ expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
283
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
284
+ });
279
285
  });
280
286
  it('should stop tracking value after user intentionally changes slug value', async ()=>{
281
287
  const { field , titleField , sdk } = createMocks({
@@ -287,28 +293,33 @@ describe('SlugEditor', ()=>{
287
293
  baseSdk: sdk,
288
294
  isInitiallyDisabled: false
289
295
  }));
290
- await wait();
291
- await sdk.entry.fields['title-id'].setValue('Hello world!');
292
- await wait();
293
- expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
294
- expect(field.setValue).toHaveBeenCalledTimes(2);
295
- expect(field.setValue).toHaveBeenCalledWith('untitled-entry-2020-01-24-at-15-33-47');
296
- expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
297
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
296
+ await waitFor(async ()=>{
297
+ await sdk.entry.fields['title-id'].setValue('Hello world!');
298
+ });
299
+ await waitFor(()=>{
300
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
301
+ expect(field.setValue).toHaveBeenCalledTimes(2);
302
+ expect(field.setValue).toHaveBeenCalledWith('untitled-entry-2020-01-24-at-15-33-47');
303
+ expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
304
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
305
+ });
298
306
  fireEvent.change(getByTestId('cf-ui-text-input'), {
299
307
  target: {
300
308
  value: 'new-custom-slug'
301
309
  }
302
310
  });
303
- await wait();
304
- expect(field.setValue).toHaveBeenCalledTimes(3);
305
- expect(field.setValue).toHaveBeenLastCalledWith('new-custom-slug');
311
+ await waitFor(()=>{
312
+ expect(field.setValue).toHaveBeenCalledTimes(3);
313
+ expect(field.setValue).toHaveBeenLastCalledWith('new-custom-slug');
314
+ });
306
315
  await sdk.entry.fields['title-id'].setValue('I decided to update my title');
307
- await wait();
308
- expect(field.setValue).toHaveBeenCalledTimes(3);
316
+ await waitFor(()=>{
317
+ expect(field.setValue).toHaveBeenCalledTimes(3);
318
+ });
309
319
  await sdk.entry.fields['title-id'].setValue('I decided to update my title again');
310
- await wait();
311
- expect(field.setValue).toHaveBeenCalledTimes(3);
320
+ await waitFor(()=>{
321
+ expect(field.setValue).toHaveBeenCalledTimes(3);
322
+ });
312
323
  });
313
324
  it('should start tracking again after potential slug equals real one', async ()=>{
314
325
  const { field , sdk } = createMocks({
@@ -320,26 +331,31 @@ describe('SlugEditor', ()=>{
320
331
  baseSdk: sdk,
321
332
  isInitiallyDisabled: false
322
333
  }));
323
- await wait();
324
- await sdk.entry.fields['title-id'].setValue('ABC DEF');
325
- await wait();
326
- expect(field.setValue).toHaveBeenLastCalledWith('abc-def');
327
- expect(field.setValue).toHaveBeenCalledTimes(2);
334
+ await waitFor(async ()=>{
335
+ await sdk.entry.fields['title-id'].setValue('ABC DEF');
336
+ });
337
+ await waitFor(()=>{
338
+ expect(field.setValue).toHaveBeenLastCalledWith('abc-def');
339
+ expect(field.setValue).toHaveBeenCalledTimes(2);
340
+ });
328
341
  fireEvent.change(getByTestId('cf-ui-text-input'), {
329
342
  target: {
330
343
  value: 'abc'
331
344
  }
332
345
  });
333
346
  await sdk.entry.fields['title-id'].setValue('ABC D');
334
- await wait();
335
- expect(field.setValue).toHaveBeenLastCalledWith('abc');
336
- expect(field.setValue).toHaveBeenCalledTimes(3);
337
- await sdk.entry.fields['title-id'].setValue('ABC');
338
- await sdk.entry.fields['title-id'].setValue('ABC ABC');
339
- await wait();
340
- expect(field.setValue).toHaveBeenLastCalledWith('abc-abc');
341
- expect(field.setValue).toHaveBeenCalledTimes(4);
342
- await wait();
347
+ await waitFor(()=>{
348
+ expect(field.setValue).toHaveBeenLastCalledWith('abc');
349
+ expect(field.setValue).toHaveBeenCalledTimes(3);
350
+ });
351
+ await waitFor(async ()=>{
352
+ await sdk.entry.fields['title-id'].setValue('ABC');
353
+ await sdk.entry.fields['title-id'].setValue('ABC ABC');
354
+ });
355
+ await waitFor(()=>{
356
+ expect(field.setValue).toHaveBeenLastCalledWith('abc-abc');
357
+ expect(field.setValue).toHaveBeenCalledTimes(4);
358
+ });
343
359
  });
344
360
  });
345
361
  describe('for non default locales', ()=>{
@@ -365,10 +381,11 @@ describe('SlugEditor', ()=>{
365
381
  baseSdk: sdk,
366
382
  isInitiallyDisabled: false
367
383
  }));
368
- await wait();
369
- expect(field.setValue).toHaveBeenCalledWith('untitled-entry-2020-01-24-at-15-33-47');
370
- expect(titleField.onValueChanged).toHaveBeenCalledWith('ru-RU', expect.any(Function));
371
- expect(titleField.onValueChanged).toHaveBeenCalledWith('de-DE', expect.any(Function));
384
+ await waitFor(()=>{
385
+ expect(field.setValue).toHaveBeenCalledWith('untitled-entry-2020-01-24-at-15-33-47');
386
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('ru-RU', expect.any(Function));
387
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('de-DE', expect.any(Function));
388
+ });
372
389
  });
373
390
  it('locale is optional and has a fallback then it should track only current locale changes', async ()=>{
374
391
  const { sdk , field , titleField } = createMocks();
@@ -392,10 +409,11 @@ describe('SlugEditor', ()=>{
392
409
  baseSdk: sdk,
393
410
  isInitiallyDisabled: false
394
411
  }));
395
- await wait();
396
- expect(field.setValue).not.toHaveBeenCalled();
397
- expect(titleField.onValueChanged).toHaveBeenCalledWith('ru-RU', expect.any(Function));
398
- expect(titleField.onValueChanged).not.toHaveBeenCalledWith('de-DE', expect.any(Function));
412
+ await waitFor(()=>{
413
+ expect(field.setValue).not.toHaveBeenCalled();
414
+ expect(titleField.onValueChanged).toHaveBeenCalledWith('ru-RU', expect.any(Function));
415
+ expect(titleField.onValueChanged).not.toHaveBeenCalledWith('de-DE', expect.any(Function));
416
+ });
399
417
  });
400
418
  });
401
419
  it('slug suggestion is limited to 75 symbols', async ()=>{
@@ -408,11 +426,13 @@ describe('SlugEditor', ()=>{
408
426
  baseSdk: sdk,
409
427
  isInitiallyDisabled: false
410
428
  }));
411
- await wait();
412
- await sdk.entry.fields['title-id'].setValue('a'.repeat(80));
413
- await wait();
414
- const expectedSlug = 'a'.repeat(75);
415
- expect(field.setValue).toHaveBeenLastCalledWith(expectedSlug);
429
+ await waitFor(async ()=>{
430
+ await sdk.entry.fields['title-id'].setValue('a'.repeat(80));
431
+ });
432
+ await waitFor(()=>{
433
+ const expectedSlug = 'a'.repeat(75);
434
+ expect(field.setValue).toHaveBeenLastCalledWith(expectedSlug);
435
+ });
416
436
  });
417
437
  it('slug suggestion does not contain cut-off words', async ()=>{
418
438
  const { field , sdk } = createMocks({
@@ -424,11 +444,13 @@ describe('SlugEditor', ()=>{
424
444
  baseSdk: sdk,
425
445
  isInitiallyDisabled: false
426
446
  }));
427
- await wait();
428
- await sdk.entry.fields['title-id'].setValue(`one two three ${'a'.repeat(80)}`);
429
- await wait();
430
- const expectedSlug = 'one-two-three';
431
- expect(field.setValue).toHaveBeenLastCalledWith(expectedSlug);
447
+ await waitFor(async ()=>{
448
+ await sdk.entry.fields['title-id'].setValue(`one two three ${'a'.repeat(80)}`);
449
+ });
450
+ await waitFor(()=>{
451
+ const expectedSlug = 'one-two-three';
452
+ expect(field.setValue).toHaveBeenLastCalledWith(expectedSlug);
453
+ });
432
454
  });
433
455
  it('should subscribe for changes in custom field id', async ()=>{
434
456
  const { field , titleField , descriptionField , sdk } = createMocks({
@@ -446,15 +468,17 @@ describe('SlugEditor', ()=>{
446
468
  }
447
469
  }
448
470
  }));
449
- await wait();
450
- expect(titleField.onValueChanged).not.toHaveBeenCalled();
451
- expect(descriptionField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
452
- expect(field.setValue).toHaveBeenCalledTimes(1);
453
- expect(field.setValue).toHaveBeenLastCalledWith('this-is-initial-description-value');
471
+ await waitFor(()=>{
472
+ expect(titleField.onValueChanged).not.toHaveBeenCalled();
473
+ expect(descriptionField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
474
+ expect(field.setValue).toHaveBeenCalledTimes(1);
475
+ expect(field.setValue).toHaveBeenLastCalledWith('this-is-initial-description-value');
476
+ });
454
477
  await sdk.entry.fields['description-id'].setValue('Hello world!');
455
- await wait();
456
- expect(field.setValue).toHaveBeenCalledTimes(2);
457
- expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
458
- expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
478
+ await waitFor(()=>{
479
+ expect(field.setValue).toHaveBeenCalledTimes(2);
480
+ expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
481
+ expect(sdk.space.getEntries).toHaveBeenCalledTimes(2);
482
+ });
459
483
  });
460
484
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-slug",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -38,21 +38,20 @@
38
38
  "@contentful/f36-components": "^4.0.27",
39
39
  "@contentful/f36-icons": "^4.1.0",
40
40
  "@contentful/f36-tokens": "^4.0.0",
41
- "@contentful/field-editor-shared": "^1.3.0",
41
+ "@contentful/field-editor-shared": "^1.3.1",
42
42
  "@types/speakingurl": "^13.0.2",
43
43
  "emotion": "^10.0.17",
44
44
  "lodash": "^4.17.15",
45
- "lodash-es": "^4.17.15",
46
45
  "speakingurl": "^13.0.0",
47
46
  "use-debounce": "^7.0.0"
48
47
  },
49
48
  "devDependencies": {
50
49
  "@contentful/app-sdk": "^4.2.0",
51
- "@contentful/field-editor-test-utils": "^1.4.0"
50
+ "@contentful/field-editor-test-utils": "^1.4.1"
52
51
  },
53
52
  "peerDependencies": {
54
53
  "@contentful/app-sdk": "^4.2.0",
55
54
  "react": ">=16.8.0"
56
55
  },
57
- "gitHead": "543e02672a8dd4edc810f9f3568d6b69c454e1f9"
56
+ "gitHead": "ca904b19ca794a2c40d82e1f7ede9e0be3560f22"
58
57
  }