cozy-sharing 33.2.0 → 33.2.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.
@@ -15,10 +15,12 @@ import { getOrCreateFromArray } from '../../helpers/contacts';
15
15
  import { usePendingRecipients } from '../../hooks/usePendingRecipients';
16
16
  import AppLike from '../SharingBanner/test/AppLike';
17
17
  var mockShare = jest.fn();
18
+ var mockShareByLink = jest.fn();
18
19
  var mockRevoke = jest.fn();
19
20
  var mockGetSharingLink = jest.fn();
20
21
  var mockGetFederatedShareLink = jest.fn();
21
22
  var mockGetRecipients = jest.fn().mockReturnValue([]);
23
+ var mockGetSharingById = jest.fn();
22
24
  var mockHasSharedChild = jest.fn();
23
25
  var mockHasSharedParent = jest.fn();
24
26
  var mockShowAlert = jest.fn();
@@ -28,11 +30,14 @@ jest.mock('../../hooks/useSharingContext', function () {
28
30
  useSharingContext: function useSharingContext() {
29
31
  return {
30
32
  share: mockShare,
33
+ shareByLink: mockShareByLink,
31
34
  revoke: mockRevoke,
32
35
  getSharingLink: mockGetSharingLink,
33
36
  getFederatedShareLink: mockGetFederatedShareLink,
34
37
  getDocumentPermissions: jest.fn().mockReturnValue([]),
38
+ getOwner: jest.fn(),
35
39
  getRecipients: mockGetRecipients,
40
+ getSharingById: mockGetSharingById,
36
41
  hasSharedChild: mockHasSharedChild,
37
42
  hasSharedParent: mockHasSharedParent
38
43
  };
@@ -63,6 +68,11 @@ jest.mock('../../hooks/usePendingRecipients', function () {
63
68
  usePendingRecipients: jest.fn()
64
69
  };
65
70
  });
71
+ jest.mock('../ShareByLink', function () {
72
+ return function () {
73
+ return /*#__PURE__*/React.createElement("button", null, "Copy link");
74
+ };
75
+ });
66
76
  var mockDocument = {
67
77
  _id: 'folder-123',
68
78
  name: 'My Test Folder',
@@ -109,10 +119,26 @@ describe('FederatedFolderModal', function () {
109
119
  beforeEach(function () {
110
120
  jest.clearAllMocks();
111
121
  mockGetSharingLink.mockReturnValue('https://example.com/share/abc123');
112
- mockGetFederatedShareLink.mockResolvedValue('https://example.com/share/federated-abc123');
122
+ mockGetFederatedShareLink.mockReturnValue('https://example.com/share/federated-abc123');
113
123
  mockGetRecipients.mockReturnValue([]);
124
+ mockGetSharingById.mockReturnValue(null);
114
125
  mockHasSharedChild.mockReturnValue(false);
115
126
  mockHasSharedParent.mockReturnValue(false);
127
+ mockShareByLink.mockResolvedValue({
128
+ data: {
129
+ _id: 'permission-id',
130
+ attributes: {
131
+ shortcodes: {
132
+ code: 'abc123'
133
+ }
134
+ }
135
+ }
136
+ });
137
+ Object.assign(navigator, {
138
+ clipboard: {
139
+ writeText: jest.fn()
140
+ }
141
+ });
116
142
  client = createTestClient();
117
143
  sharingContextValue = createSharingContextValue();
118
144
  usePendingRecipients.mockReturnValue({
@@ -190,18 +216,44 @@ describe('FederatedFolderModal', function () {
190
216
  }
191
217
  }, _callee3);
192
218
  })));
193
- it('should hide share by email when document is in federated shared folder received by current user', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
194
- var _setup4, findByText, queryByText;
219
+ it('should show link access as soon as a link is generated', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
220
+ var _setup4, findByText, queryByText, rerender;
195
221
 
196
222
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
197
223
  while (1) switch (_context4.prev = _context4.next) {
198
224
  case 0:
199
- _setup4 = setup({
225
+ mockGetSharingLink.mockReturnValue(null);
226
+ _setup4 = setup(), findByText = _setup4.findByText, queryByText = _setup4.queryByText, rerender = _setup4.rerender;
227
+ expect(queryByText('Anyone with the link')).toBe(null);
228
+ mockGetSharingLink.mockReturnValue('https://example.com/share/abc123');
229
+ rerender( /*#__PURE__*/React.createElement(AppLike, {
230
+ client: client,
231
+ sharingContextValue: sharingContextValue
232
+ }, /*#__PURE__*/React.createElement(FederatedFolderModal, {
233
+ document: mockDocument,
234
+ onClose: mockOnClose
235
+ })));
236
+ _context4.next = 7;
237
+ return findByText('Anyone with the link');
238
+
239
+ case 7:
240
+ case "end":
241
+ return _context4.stop();
242
+ }
243
+ }, _callee4);
244
+ })));
245
+ it('should hide share by email when document is in federated shared folder received by current user', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
246
+ var _setup5, findByText, queryByText;
247
+
248
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
249
+ while (1) switch (_context5.prev = _context5.next) {
250
+ case 0:
251
+ _setup5 = setup({
200
252
  document: _objectSpread(_objectSpread({}, mockDocument), {}, {
201
253
  driveId: 'federated-folder-id'
202
254
  })
203
- }), findByText = _setup4.findByText, queryByText = _setup4.queryByText;
204
- _context4.next = 3;
255
+ }), findByText = _setup5.findByText, queryByText = _setup5.queryByText;
256
+ _context5.next = 3;
205
257
  return findByText('Copy link');
206
258
 
207
259
  case 3:
@@ -210,34 +262,68 @@ describe('FederatedFolderModal', function () {
210
262
 
211
263
  case 5:
212
264
  case "end":
213
- return _context4.stop();
265
+ return _context5.stop();
214
266
  }
215
- }, _callee4);
267
+ }, _callee5);
216
268
  })));
217
- it('should show only by link message when document is in federated shared folder received by current user', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
218
- var _setup5, findByText;
269
+ it('should show only by link message when document is in federated shared folder received by current user', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
270
+ var _setup6, findByText;
219
271
 
220
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
221
- while (1) switch (_context5.prev = _context5.next) {
272
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
273
+ while (1) switch (_context6.prev = _context6.next) {
222
274
  case 0:
223
- _setup5 = setup({
275
+ _setup6 = setup({
224
276
  document: _objectSpread(_objectSpread({}, mockDocument), {}, {
225
277
  driveId: 'federated-folder-id',
226
278
  type: 'directory'
227
279
  })
228
- }), findByText = _setup5.findByText;
229
- _context5.next = 3;
280
+ }), findByText = _setup6.findByText;
281
+ _context6.next = 3;
230
282
  return findByText('This folder can only be shared by link, because');
231
283
 
232
284
  case 3:
233
- _context5.next = 5;
285
+ _context6.next = 5;
234
286
  return findByText('it has a shared parent');
235
287
 
236
288
  case 5:
237
289
  case "end":
238
- return _context5.stop();
290
+ return _context6.stop();
239
291
  }
240
- }, _callee5);
292
+ }, _callee6);
293
+ })));
294
+ it('should allow share by email when document is the federated shared folder root', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
295
+ var _setup7, findByText, queryByText;
296
+
297
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
298
+ while (1) switch (_context7.prev = _context7.next) {
299
+ case 0:
300
+ mockGetSharingById.mockReturnValue({
301
+ attributes: {
302
+ rules: [{
303
+ values: ['another-folder-id']
304
+ }, {
305
+ values: ['yet-another-folder-id', mockDocument._id]
306
+ }]
307
+ }
308
+ });
309
+ _setup7 = setup({
310
+ document: _objectSpread(_objectSpread({}, mockDocument), {}, {
311
+ driveId: 'federated-folder-id',
312
+ type: 'directory'
313
+ })
314
+ }), findByText = _setup7.findByText, queryByText = _setup7.queryByText;
315
+ _context7.next = 4;
316
+ return findByText('Add users');
317
+
318
+ case 4:
319
+ expect(queryByText('This folder can only be shared by link, because')).toBe(null);
320
+ expect(queryByText('it has a shared parent')).toBe(null);
321
+
322
+ case 6:
323
+ case "end":
324
+ return _context7.stop();
325
+ }
326
+ }, _callee7);
241
327
  })));
242
328
  });
243
329
  describe('onSend callback', function () {
@@ -245,21 +331,21 @@ describe('FederatedFolderModal', function () {
245
331
  name: 'Alice',
246
332
  email: 'alice@example.com'
247
333
  };
248
- it('should call onClose and skip share when there are no pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
249
- var _setup6, findByText, sendButton;
334
+ it('should call onClose and skip share when there are no pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
335
+ var _setup8, findByText, sendButton;
250
336
 
251
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
252
- while (1) switch (_context6.prev = _context6.next) {
337
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
338
+ while (1) switch (_context8.prev = _context8.next) {
253
339
  case 0:
254
340
  // pendingRecipients defaults to [] via beforeEach
255
- _setup6 = setup(), findByText = _setup6.findByText;
256
- _context6.next = 3;
341
+ _setup8 = setup(), findByText = _setup8.findByText;
342
+ _context8.next = 3;
257
343
  return findByText('Done');
258
344
 
259
345
  case 3:
260
- sendButton = _context6.sent;
346
+ sendButton = _context8.sent;
261
347
  fireEvent.click(sendButton);
262
- _context6.next = 7;
348
+ _context8.next = 7;
263
349
  return waitFor(function () {
264
350
  expect(mockOnClose).toHaveBeenCalled();
265
351
  expect(mockShare).not.toHaveBeenCalled();
@@ -267,15 +353,15 @@ describe('FederatedFolderModal', function () {
267
353
 
268
354
  case 7:
269
355
  case "end":
270
- return _context6.stop();
356
+ return _context8.stop();
271
357
  }
272
- }, _callee6);
358
+ }, _callee8);
273
359
  })));
274
- it('should call share with correct parameters', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
275
- var _setup7, findByText, sendButton;
360
+ it('should call share with correct parameters', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
361
+ var _setup9, findByText, sendButton;
276
362
 
277
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
278
- while (1) switch (_context7.prev = _context7.next) {
363
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
364
+ while (1) switch (_context9.prev = _context9.next) {
279
365
  case 0:
280
366
  usePendingRecipients.mockReturnValue({
281
367
  pendingRecipients: [pendingRecipient],
@@ -285,14 +371,14 @@ describe('FederatedFolderModal', function () {
285
371
  });
286
372
  getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
287
373
  mockShare.mockResolvedValueOnce({});
288
- _setup7 = setup(), findByText = _setup7.findByText;
289
- _context7.next = 6;
374
+ _setup9 = setup(), findByText = _setup9.findByText;
375
+ _context9.next = 6;
290
376
  return findByText('Done');
291
377
 
292
378
  case 6:
293
- sendButton = _context7.sent;
379
+ sendButton = _context9.sent;
294
380
  fireEvent.click(sendButton);
295
- _context7.next = 10;
381
+ _context9.next = 10;
296
382
  return waitFor(function () {
297
383
  expect(mockShare).toHaveBeenCalledWith({
298
384
  description: 'My Test Folder',
@@ -306,15 +392,15 @@ describe('FederatedFolderModal', function () {
306
392
 
307
393
  case 10:
308
394
  case "end":
309
- return _context7.stop();
395
+ return _context9.stop();
310
396
  }
311
- }, _callee7);
397
+ }, _callee9);
312
398
  })));
313
- it('should show success alert and close modal on successful share', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
314
- var _setup8, findByText, sendButton;
399
+ it('should show success alert and close modal on successful share', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
400
+ var _setup10, findByText, sendButton;
315
401
 
316
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
317
- while (1) switch (_context8.prev = _context8.next) {
402
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
403
+ while (1) switch (_context10.prev = _context10.next) {
318
404
  case 0:
319
405
  usePendingRecipients.mockReturnValue({
320
406
  pendingRecipients: [pendingRecipient],
@@ -324,14 +410,14 @@ describe('FederatedFolderModal', function () {
324
410
  });
325
411
  getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
326
412
  mockShare.mockResolvedValueOnce({});
327
- _setup8 = setup(), findByText = _setup8.findByText;
328
- _context8.next = 6;
413
+ _setup10 = setup(), findByText = _setup10.findByText;
414
+ _context10.next = 6;
329
415
  return findByText('Done');
330
416
 
331
417
  case 6:
332
- sendButton = _context8.sent;
418
+ sendButton = _context10.sent;
333
419
  fireEvent.click(sendButton);
334
- _context8.next = 10;
420
+ _context10.next = 10;
335
421
  return waitFor(function () {
336
422
  expect(mockShowAlert).toHaveBeenCalledWith({
337
423
  message: 'Folder has been shared',
@@ -343,15 +429,15 @@ describe('FederatedFolderModal', function () {
343
429
 
344
430
  case 10:
345
431
  case "end":
346
- return _context8.stop();
432
+ return _context10.stop();
347
433
  }
348
- }, _callee8);
434
+ }, _callee10);
349
435
  })));
350
- it('should show error alert when share fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
351
- var _setup9, findByText, sendButton;
436
+ it('should show error alert when share fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
437
+ var _setup11, findByText, sendButton;
352
438
 
353
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
354
- while (1) switch (_context9.prev = _context9.next) {
439
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
440
+ while (1) switch (_context11.prev = _context11.next) {
355
441
  case 0:
356
442
  usePendingRecipients.mockReturnValue({
357
443
  pendingRecipients: [pendingRecipient],
@@ -361,14 +447,14 @@ describe('FederatedFolderModal', function () {
361
447
  });
362
448
  getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
363
449
  mockShare.mockRejectedValueOnce(new Error('Share failed'));
364
- _setup9 = setup(), findByText = _setup9.findByText;
365
- _context9.next = 6;
450
+ _setup11 = setup(), findByText = _setup11.findByText;
451
+ _context11.next = 6;
366
452
  return findByText('Done');
367
453
 
368
454
  case 6:
369
- sendButton = _context9.sent;
455
+ sendButton = _context11.sent;
370
456
  fireEvent.click(sendButton);
371
- _context9.next = 10;
457
+ _context11.next = 10;
372
458
  return waitFor(function () {
373
459
  expect(mockShowAlert).toHaveBeenCalledWith({
374
460
  message: 'Error while sharing folder',
@@ -380,15 +466,15 @@ describe('FederatedFolderModal', function () {
380
466
 
381
467
  case 10:
382
468
  case "end":
383
- return _context9.stop();
469
+ return _context11.stop();
384
470
  }
385
- }, _callee9);
471
+ }, _callee11);
386
472
  })));
387
- it('should show progress icon on Done button while share is in progress', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
388
- var resolveShare, _setup10, findByText, getByRole, queryByRole, sendButton;
473
+ it('should show progress icon on Done button while share is in progress', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
474
+ var resolveShare, _setup12, findByText, getByRole, queryByRole, sendButton;
389
475
 
390
- return _regeneratorRuntime.wrap(function _callee11$(_context11) {
391
- while (1) switch (_context11.prev = _context11.next) {
476
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
477
+ while (1) switch (_context13.prev = _context13.next) {
392
478
  case 0:
393
479
  usePendingRecipients.mockReturnValue({
394
480
  pendingRecipients: [pendingRecipient],
@@ -400,14 +486,14 @@ describe('FederatedFolderModal', function () {
400
486
  mockShare.mockReturnValueOnce(new Promise(function (resolve) {
401
487
  resolveShare = resolve;
402
488
  }));
403
- _setup10 = setup(), findByText = _setup10.findByText, getByRole = _setup10.getByRole, queryByRole = _setup10.queryByRole;
404
- _context11.next = 6;
489
+ _setup12 = setup(), findByText = _setup12.findByText, getByRole = _setup12.getByRole, queryByRole = _setup12.queryByRole;
490
+ _context13.next = 6;
405
491
  return findByText('Done');
406
492
 
407
493
  case 6:
408
- sendButton = _context11.sent;
494
+ sendButton = _context13.sent;
409
495
  fireEvent.click(sendButton);
410
- _context11.next = 10;
496
+ _context13.next = 10;
411
497
  return waitFor(function () {
412
498
  expect(getByRole('button', {
413
499
  name: 'Done'
@@ -416,56 +502,56 @@ describe('FederatedFolderModal', function () {
416
502
  });
417
503
 
418
504
  case 10:
419
- _context11.next = 12;
420
- return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
421
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
422
- while (1) switch (_context10.prev = _context10.next) {
505
+ _context13.next = 12;
506
+ return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
507
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
508
+ while (1) switch (_context12.prev = _context12.next) {
423
509
  case 0:
424
510
  resolveShare({});
425
511
 
426
512
  case 1:
427
513
  case "end":
428
- return _context10.stop();
514
+ return _context12.stop();
429
515
  }
430
- }, _callee10);
516
+ }, _callee12);
431
517
  })));
432
518
 
433
519
  case 12:
434
520
  case "end":
435
- return _context11.stop();
521
+ return _context13.stop();
436
522
  }
437
- }, _callee11);
523
+ }, _callee13);
438
524
  })));
439
525
  });
440
526
  describe('onClose callback', function () {
441
- it('should call onClose when close button is clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
442
- var _setup11, findByRole, closeButton;
527
+ it('should call onClose when close button is clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
528
+ var _setup13, findByRole, closeButton;
443
529
 
444
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
445
- while (1) switch (_context12.prev = _context12.next) {
530
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
531
+ while (1) switch (_context14.prev = _context14.next) {
446
532
  case 0:
447
- _setup11 = setup(), findByRole = _setup11.findByRole;
448
- _context12.next = 3;
533
+ _setup13 = setup(), findByRole = _setup13.findByRole;
534
+ _context14.next = 3;
449
535
  return findByRole('button', {
450
536
  name: /close/i
451
537
  });
452
538
 
453
539
  case 3:
454
- closeButton = _context12.sent;
540
+ closeButton = _context14.sent;
455
541
  fireEvent.click(closeButton);
456
542
  expect(mockOnClose).toHaveBeenCalled();
457
543
 
458
544
  case 6:
459
545
  case "end":
460
- return _context12.stop();
546
+ return _context14.stop();
461
547
  }
462
- }, _callee12);
548
+ }, _callee14);
463
549
  })));
464
- it('should ask confirmation when close button is clicked with pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
465
- var _setup12, getByRole, findByRole, getByText, closeButton;
550
+ it('should ask confirmation when close button is clicked with pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
551
+ var _setup14, getByRole, findByRole, getByText, closeButton;
466
552
 
467
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
468
- while (1) switch (_context13.prev = _context13.next) {
553
+ return _regeneratorRuntime.wrap(function _callee15$(_context15) {
554
+ while (1) switch (_context15.prev = _context15.next) {
469
555
  case 0:
470
556
  usePendingRecipients.mockReturnValue({
471
557
  pendingRecipients: [{
@@ -476,14 +562,14 @@ describe('FederatedFolderModal', function () {
476
562
  selectedOption: 'readWrite',
477
563
  setSelectedOption: jest.fn()
478
564
  });
479
- _setup12 = setup(), getByRole = _setup12.getByRole, findByRole = _setup12.findByRole, getByText = _setup12.getByText;
480
- _context13.next = 4;
565
+ _setup14 = setup(), getByRole = _setup14.getByRole, findByRole = _setup14.findByRole, getByText = _setup14.getByText;
566
+ _context15.next = 4;
481
567
  return findByRole('button', {
482
568
  name: /close/i
483
569
  });
484
570
 
485
571
  case 4:
486
- closeButton = _context13.sent;
572
+ closeButton = _context15.sent;
487
573
  fireEvent.click(closeButton);
488
574
  expect(getByText("Discard the changes you haven't saved?")).toBeTruthy();
489
575
  expect(mockOnClose).not.toHaveBeenCalled();
@@ -494,15 +580,15 @@ describe('FederatedFolderModal', function () {
494
580
 
495
581
  case 10:
496
582
  case "end":
497
- return _context13.stop();
583
+ return _context15.stop();
498
584
  }
499
- }, _callee13);
585
+ }, _callee15);
500
586
  })));
501
- it('should close after discard confirmation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
502
- var _setup13, getByRole, findByRole, getByText, closeButton;
587
+ it('should close after discard confirmation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
588
+ var _setup15, getByRole, findByRole, getByText, closeButton;
503
589
 
504
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
505
- while (1) switch (_context14.prev = _context14.next) {
590
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
591
+ while (1) switch (_context16.prev = _context16.next) {
506
592
  case 0:
507
593
  usePendingRecipients.mockReturnValue({
508
594
  pendingRecipients: [{
@@ -513,14 +599,14 @@ describe('FederatedFolderModal', function () {
513
599
  selectedOption: 'readWrite',
514
600
  setSelectedOption: jest.fn()
515
601
  });
516
- _setup13 = setup(), getByRole = _setup13.getByRole, findByRole = _setup13.findByRole, getByText = _setup13.getByText;
517
- _context14.next = 4;
602
+ _setup15 = setup(), getByRole = _setup15.getByRole, findByRole = _setup15.findByRole, getByText = _setup15.getByText;
603
+ _context16.next = 4;
518
604
  return findByRole('button', {
519
605
  name: /close/i
520
606
  });
521
607
 
522
608
  case 4:
523
- closeButton = _context14.sent;
609
+ closeButton = _context16.sent;
524
610
  fireEvent.click(closeButton);
525
611
  expect(getByText("Discard the changes you haven't saved?")).toBeTruthy();
526
612
  fireEvent.click(getByRole('button', {
@@ -530,9 +616,9 @@ describe('FederatedFolderModal', function () {
530
616
 
531
617
  case 9:
532
618
  case "end":
533
- return _context14.stop();
619
+ return _context16.stop();
534
620
  }
535
- }, _callee14);
621
+ }, _callee16);
536
622
  })));
537
623
  });
538
624
  });
@@ -24,6 +24,7 @@ import { getOrCreateFromArray } from '../helpers/contacts';
24
24
  import { hasReachRecipientsLimit } from '../helpers/recipients';
25
25
  import { getErrorMessage, getSuccessMessage } from '../helpers/share';
26
26
  import { usePendingRecipients } from '../hooks/usePendingRecipients';
27
+ import { useSharingContext } from '../hooks/useSharingContext';
27
28
  var styles = {
28
29
  "share-modal-content": "share__share-modal-content___1iqEq",
29
30
  "coz-form": "share__coz-form___1ICST",
@@ -144,6 +145,9 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref3) {
144
145
  var _useAlert = useAlert(),
145
146
  showAlert = _useAlert.showAlert;
146
147
 
148
+ var _useSharingContext = useSharingContext(),
149
+ getSharingLink = _useSharingContext.getSharingLink;
150
+
147
151
  var _usePendingRecipients = usePendingRecipients(),
148
152
  pendingRecipients = _usePendingRecipients.pendingRecipients,
149
153
  setPendingRecipients = _usePendingRecipients.setPendingRecipients,
@@ -160,6 +164,7 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref3) {
160
164
  showRecipientsLimit = _useState4[0],
161
165
  setShowRecipientsLimit = _useState4[1];
162
166
 
167
+ var displayedLink = getSharingLink(document._id || document.id);
163
168
  var handleShare = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
164
169
  var contacts, readWriteRecipients, readOnlyRecipients;
165
170
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -254,6 +259,7 @@ var ShareDialogCozyToCozy = function ShareDialogCozyToCozy(_ref3) {
254
259
  return Actions;
255
260
  }, [handleShare, submitting, t, documentType, showShareByLink, showGenerateLinkButton, autoOpenShareRestriction]);
256
261
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShareDialogTwoStepsConfirmationContainer, _extends({}, props, {
262
+ link: displayedLink,
257
263
  documentType: documentType,
258
264
  document: document,
259
265
  recipients: recipients,
@@ -33,6 +33,9 @@ jest.mock('../hooks/useSharingContext', function () {
33
33
  return {
34
34
  useSharingContext: function useSharingContext() {
35
35
  return {
36
+ getSharingLink: jest.fn(function () {
37
+ return null;
38
+ }),
36
39
  updateSharingMemberType: jest.fn()
37
40
  };
38
41
  }
@@ -7,6 +7,7 @@ import { useI18n } from 'twake-i18n';
7
7
  import AntivirusAlert from './AntivirusAlert';
8
8
  import { default as DumbShareByLink } from './ShareByLink';
9
9
  import WhoHasAccess from './WhoHasAccess';
10
+ import { useSharingContext } from '../hooks/useSharingContext';
10
11
 
11
12
  var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
12
13
  var isOwner = _ref.isOwner,
@@ -15,7 +16,6 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
15
16
  recipients = _ref.recipients,
16
17
  document = _ref.document,
17
18
  documentType = _ref.documentType,
18
- link = _ref.link,
19
19
  onClose = _ref.onClose,
20
20
  permissions = _ref.permissions,
21
21
  showGenerateLinkButton = _ref.showGenerateLinkButton,
@@ -27,6 +27,10 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
27
27
  var _useBreakpoints = useBreakpoints(),
28
28
  isMobile = _useBreakpoints.isMobile;
29
29
 
30
+ var _useSharingContext = useSharingContext(),
31
+ getSharingLink = _useSharingContext.getSharingLink;
32
+
33
+ var displayedLink = getSharingLink(document._id || document.id);
30
34
  return /*#__PURE__*/React.createElement(Dialog, {
31
35
  disableGutters: true,
32
36
  disableEnforceFocus: true,
@@ -47,12 +51,12 @@ var ShareDialogOnlyByLink = function ShareDialogOnlyByLink(_ref) {
47
51
  onRevoke: onRevoke,
48
52
  onRevokeSelf: onRevokeSelf,
49
53
  recipients: recipients,
50
- link: link,
54
+ link: displayedLink,
51
55
  permissions: permissions
52
56
  }), /*#__PURE__*/React.createElement("div", {
53
57
  className: cx('u-mt-half', isMobile ? 'u-ph-1 u-mb-1' : 'u-ph-2 u-mb-1-half')
54
58
  }, /*#__PURE__*/React.createElement(DumbShareByLink, {
55
- link: link,
59
+ link: displayedLink,
56
60
  document: document,
57
61
  documentType: documentType,
58
62
  showGenerateLinkButton: showGenerateLinkButton,