cozy-sharing 32.3.1 → 32.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/components/FederatedFolder/FederatedFolderModal.js +56 -19
  3. package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +101 -254
  4. package/dist/components/Recipient/RecipientList.js +0 -15
  5. package/dist/components/ShareModal/ShareModal.js +8 -8
  6. package/dist/state.js +6 -1
  7. package/package.json +2 -2
  8. package/src/components/FederatedFolder/FederatedFolderModal.jsx +65 -19
  9. package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +28 -150
  10. package/src/components/Recipient/RecipientList.jsx +0 -18
  11. package/src/components/ShareModal/ShareModal.jsx +5 -5
  12. package/src/state.js +5 -1
  13. package/.claude/settings.local.json +0 -27
  14. package/AGENTS.md +0 -7
  15. package/dist/RefreshableSharings.spec.js +0 -40
  16. package/dist/assets/illustrations/illustration-shared-drives.svg +0 -1
  17. package/dist/components/EditLinkPermissionDialog.js +0 -72
  18. package/dist/components/EditLinkPermissionDialog.spec.js +0 -48
  19. package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +0 -65
  20. package/dist/components/FederatedFolder/DumbFederatedFolderModal.spec.js +0 -107
  21. package/dist/components/FederatedFolder/FederatedFolderModal.jsx.tmp.179197.1773939270471 +0 -172
  22. package/dist/components/Recipient/actions/revokeGroup.js +0 -42
  23. package/dist/components/Recipient/actions/revokeMember.js +0 -42
  24. package/dist/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
  25. package/dist/components/ShareModal/ShareModal copy.js +0 -43
  26. package/dist/components/ShareModal/ShareModal.spec.js +0 -197
  27. package/dist/components/ShareModal/ShareModalBatchContainer.js +0 -276
  28. package/dist/components/ShareModal/ShareModalBatchContainer.spec.js +0 -131
  29. package/dist/components/ShareModal/SharedDriveEditModal.js +0 -59
  30. package/dist/components/SharedDrive/DumbSharedDriveModal.js +0 -78
  31. package/dist/components/SharedDrive/DumbSharedDriveModal.spec.js +0 -126
  32. package/dist/components/SharedDrive/SharedDriveEditModal.js +0 -110
  33. package/dist/components/SharedDrive/SharedDriveModal copy.js +0 -356
  34. package/dist/components/SharedDrive/SharedDriveRecipient.js +0 -61
  35. package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +0 -109
  36. package/dist/components/SharedDrive/SharedDriveRecipientStatus.js +0 -22
  37. package/dist/components/SharedDrive/helpers.js +0 -102
  38. package/dist/components/SharedDrive/helpers.spec.js +0 -208
  39. package/dist/components/SharedDriveEditModal.js +0 -43
  40. package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +0 -145
  41. package/dist/components/SharedFolder/DumbBatchSharedFolderModal.spec.js +0 -321
  42. package/dist/components/SharedStatus.js +0 -61
  43. package/dist/components/SharedStatus.spec.js +0 -44
  44. package/dist/components/Sharesubmit.js +0 -28
  45. package/dist/components/__snapshots__/SharedStatus.spec.js.snap +0 -94
  46. package/dist/helpers/owner.js +0 -14
  47. package/dist/helpers/owner.spec.js +0 -34
  48. package/dist/hooks/useConfirmDiscardChanges.js +0 -33
  49. package/dist/hooks/useContactsAndGroups.js +0 -65
  50. package/dist/hooks/useSharedDrive.js +0 -130
  51. package/dist/hooks/useSharedDriveContactsAndGroups.js +0 -65
  52. package/dist/propTypes.js +0 -26
  53. package/dist/styles/shareddrive.styl +0 -8
  54. package/src/components/SharedDrive/SharedDriveRecipient.jsx +0 -62
  55. package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +0 -78
  56. package/src/components/SharedDrive/SharedDriveRecipientStatus.jsx +0 -23
  57. package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +0 -161
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [32.3.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@32.3.1...cozy-sharing@32.3.2) (2026-05-26)
7
+
8
+ ### Bug Fixes
9
+
10
+ - Show readonly modal when shared drive is read only ([e935b38](https://github.com/cozy/cozy-libs/commit/e935b38aa443d68b7d17dc8c82e8a9e1e23e2460))
11
+
6
12
  ## [32.3.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@32.3.0...cozy-sharing@32.3.1) (2026-05-22)
7
13
 
8
14
  ### Bug Fixes
@@ -5,6 +5,8 @@ import PropTypes from 'prop-types';
5
5
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
6
6
  import { useClient } from 'cozy-client';
7
7
  import Button from 'cozy-ui/transpiled/react/Buttons';
8
+ import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
9
+ import Typography from 'cozy-ui/transpiled/react/Typography';
8
10
  import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert';
9
11
  import ConfirmDialogProvider, { useConfirmDialog } from 'cozy-ui/transpiled/react/providers/ConfirmDialog';
10
12
  import { useI18n } from 'twake-i18n';
@@ -12,7 +14,10 @@ import { getOrCreateFromArray } from '../../helpers/contacts';
12
14
  import withLocales from '../../hoc/withLocales';
13
15
  import { usePendingRecipients } from '../../hooks/usePendingRecipients';
14
16
  import { useSharingContext } from '../../hooks/useSharingContext';
15
- import { DumbBatchSharedFolderModal } from '../SharedFolder/DumbBatchSharedFolderModal';
17
+ import AntivirusAlert from '../AntivirusAlert';
18
+ import { default as DumbShareByEmail } from '../ShareByEmail';
19
+ import ShareByLink from '../ShareByLink';
20
+ import WhoHasAccess from '../WhoHasAccess';
16
21
 
17
22
  var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
18
23
  var onClose = _ref.onClose,
@@ -154,7 +159,7 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
154
159
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
155
160
  while (1) switch (_context2.prev = _context2.next) {
156
161
  case 0:
157
- if (!(pendingRecipients.length === 0)) {
162
+ if (!(isSending || pendingRecipients.length === 0)) {
158
163
  _context2.next = 3;
159
164
  break;
160
165
  }
@@ -226,24 +231,56 @@ var FederatedFolderModalContent = function FederatedFolderModalContent(_ref) {
226
231
  var modalTitle = t('FederatedFolder.shareTitle', {
227
232
  name: folderName
228
233
  });
229
- var isSharedDrive = Boolean(existingDocument === null || existingDocument === void 0 ? void 0 : existingDocument.driveId);
230
- return /*#__PURE__*/React.createElement(DumbBatchSharedFolderModal, {
231
- title: modalTitle,
232
- document: isSending ? frozenDoc : existingDocument,
233
- recipients: isSending ? frozenRecipients : existingRecipients,
234
- currentRecipients: isSending ? frozenRecipients : existingRecipients,
235
- onRevoke: revoke,
236
- onSend: onSend,
234
+ return /*#__PURE__*/React.createElement(FixedDialog, {
235
+ open: true,
236
+ disableGutters: true,
237
237
  onClose: handleCloseRequest,
238
- sharingLink: sharingLink,
239
- shareLabel: t('FederatedFolder.share'),
240
- showShareByEmail: !isSharedDrive,
241
- autoOpenShareRestriction: autoOpenShareRestriction,
242
- showGenerateLinkButton: showGenerateLinkButton,
243
- pendingRecipients: pendingRecipients,
244
- onPendingRecipientsChange: setPendingRecipients,
245
- selectedOption: selectedOption,
246
- onSelectedOptionChange: setSelectedOption
238
+ title: modalTitle,
239
+ classes: {
240
+ paper: 'u-ov-visible'
241
+ },
242
+ componentsProps: {
243
+ dialogContent: {
244
+ className: 'u-ov-visible'
245
+ }
246
+ },
247
+ content: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
248
+ className: "u-ph-2"
249
+ }, /*#__PURE__*/React.createElement(AntivirusAlert, {
250
+ document: isSending ? frozenDoc : existingDocument
251
+ }), /*#__PURE__*/React.createElement(Typography, {
252
+ variant: "h6",
253
+ className: "u-mt-1-half u-mb-half"
254
+ }, t('Share.contacts.addUsers')), /*#__PURE__*/React.createElement(DumbShareByEmail, {
255
+ currentRecipients: isSending ? frozenRecipients : existingRecipients,
256
+ document: isSending ? frozenDoc : existingDocument,
257
+ documentType: "Files",
258
+ pendingRecipients: pendingRecipients,
259
+ onPendingRecipientsChange: setPendingRecipients,
260
+ selectedOption: selectedOption,
261
+ onSelectedOptionChange: setSelectedOption
262
+ })), /*#__PURE__*/React.createElement(WhoHasAccess, {
263
+ isOwner: true,
264
+ isSharedDrive: true,
265
+ recipients: isSending ? frozenRecipients : existingRecipients,
266
+ document: isSending ? frozenDoc : existingDocument,
267
+ documentType: "Files",
268
+ className: "u-w-100",
269
+ onRevoke: revoke,
270
+ link: sharingLink
271
+ })),
272
+ actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ShareByLink, {
273
+ link: sharingLink,
274
+ document: isSending ? frozenDoc : existingDocument,
275
+ documentType: "Files",
276
+ showGenerateLinkButton: showGenerateLinkButton,
277
+ autoOpenShareRestriction: autoOpenShareRestriction
278
+ }), /*#__PURE__*/React.createElement(Button, {
279
+ variant: "primary",
280
+ label: t('FederatedFolder.share'),
281
+ disabled: isSending,
282
+ onClick: onSend
283
+ }))
247
284
  });
248
285
  };
249
286
 
@@ -51,46 +51,6 @@ jest.mock('../../hooks/usePendingRecipients', function () {
51
51
  usePendingRecipients: jest.fn()
52
52
  };
53
53
  });
54
- jest.mock('../SharedFolder/DumbBatchSharedFolderModal', function () {
55
- return {
56
- DumbBatchSharedFolderModal: function DumbBatchSharedFolderModal(_ref) {
57
- var title = _ref.title,
58
- recipients = _ref.recipients,
59
- onRevoke = _ref.onRevoke,
60
- onSend = _ref.onSend,
61
- onClose = _ref.onClose,
62
- sharingLink = _ref.sharingLink,
63
- pendingRecipients = _ref.pendingRecipients,
64
- selectedOption = _ref.selectedOption;
65
- return /*#__PURE__*/React.createElement("div", {
66
- "data-testid": "dumb-modal"
67
- }, /*#__PURE__*/React.createElement("span", {
68
- "data-testid": "title"
69
- }, title), /*#__PURE__*/React.createElement("span", {
70
- "data-testid": "sharing-link"
71
- }, sharingLink), /*#__PURE__*/React.createElement("span", {
72
- "data-testid": "recipients-count"
73
- }, recipients.length), /*#__PURE__*/React.createElement("span", {
74
- "data-testid": "pending-recipients-count"
75
- }, pendingRecipients.length), /*#__PURE__*/React.createElement("span", {
76
- "data-testid": "selected-option"
77
- }, selectedOption), /*#__PURE__*/React.createElement("button", {
78
- "data-testid": "btn-send",
79
- onClick: onSend
80
- }, "Send"), /*#__PURE__*/React.createElement("button", {
81
- "data-testid": "btn-revoke",
82
- onClick: function onClick() {
83
- return onRevoke({
84
- _id: 'folder-123'
85
- }, 'abc', 1);
86
- }
87
- }, "Revoke"), /*#__PURE__*/React.createElement("button", {
88
- "data-testid": "btn-close",
89
- onClick: onClose
90
- }, "Close"));
91
- }
92
- };
93
- });
94
54
  var mockDocument = {
95
55
  _id: 'folder-123',
96
56
  name: 'My Test Folder',
@@ -162,16 +122,14 @@ describe('FederatedFolderModal', function () {
162
122
 
163
123
  describe('initialization', function () {
164
124
  it('should pass document name as title', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
165
- var _setup, getByTestId;
125
+ var _setup, findByText;
166
126
 
167
127
  return _regeneratorRuntime.wrap(function _callee$(_context) {
168
128
  while (1) switch (_context.prev = _context.next) {
169
129
  case 0:
170
- _setup = setup(), getByTestId = _setup.getByTestId;
130
+ _setup = setup(), findByText = _setup.findByText;
171
131
  _context.next = 3;
172
- return waitFor(function () {
173
- expect(getByTestId('title').textContent).toBe('Share "My Test Folder"');
174
- });
132
+ return findByText('Share "My Test Folder"');
175
133
 
176
134
  case 3:
177
135
  case "end":
@@ -180,7 +138,7 @@ describe('FederatedFolderModal', function () {
180
138
  }, _callee);
181
139
  })));
182
140
  it('should pass default title when document has no name', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
183
- var documentWithoutName, _setup2, getByTestId;
141
+ var documentWithoutName, _setup2, findByText;
184
142
 
185
143
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
186
144
  while (1) switch (_context2.prev = _context2.next) {
@@ -191,11 +149,9 @@ describe('FederatedFolderModal', function () {
191
149
  };
192
150
  _setup2 = setup({
193
151
  document: documentWithoutName
194
- }), getByTestId = _setup2.getByTestId;
152
+ }), findByText = _setup2.findByText;
195
153
  _context2.next = 4;
196
- return waitFor(function () {
197
- expect(getByTestId('title').textContent).toBe('Share ""');
198
- });
154
+ return findByText('Share ""');
199
155
 
200
156
  case 4:
201
157
  case "end":
@@ -203,17 +159,15 @@ describe('FederatedFolderModal', function () {
203
159
  }
204
160
  }, _callee2);
205
161
  })));
206
- it('should pass sharing link to DumbBatchSharedFolderModal', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
207
- var _setup3, getByTestId;
162
+ it('should show Copy link', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
163
+ var _setup3, findByText;
208
164
 
209
165
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
210
166
  while (1) switch (_context3.prev = _context3.next) {
211
167
  case 0:
212
- _setup3 = setup(), getByTestId = _setup3.getByTestId;
168
+ _setup3 = setup(), findByText = _setup3.findByText;
213
169
  _context3.next = 3;
214
- return waitFor(function () {
215
- expect(getByTestId('sharing-link').textContent).toBe('https://example.com/share/abc123');
216
- });
170
+ return findByText('Copy link');
217
171
 
218
172
  case 3:
219
173
  case "end":
@@ -221,82 +175,43 @@ describe('FederatedFolderModal', function () {
221
175
  }
222
176
  }, _callee3);
223
177
  })));
224
- it('should pass null sharing link when document is undefined', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
225
- var _setup4, getByTestId;
226
-
227
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
228
- while (1) switch (_context4.prev = _context4.next) {
229
- case 0:
230
- _setup4 = setup({
231
- document: undefined
232
- }), getByTestId = _setup4.getByTestId;
233
- _context4.next = 3;
234
- return waitFor(function () {
235
- expect(getByTestId('sharing-link').textContent).toBe('');
236
- });
237
-
238
- case 3:
239
- case "end":
240
- return _context4.stop();
241
- }
242
- }, _callee4);
243
- })));
244
- it('should pass selectedOption from usePendingRecipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
245
- var _setup5, getByTestId;
246
-
247
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
248
- while (1) switch (_context5.prev = _context5.next) {
249
- case 0:
250
- _setup5 = setup(), getByTestId = _setup5.getByTestId;
251
- _context5.next = 3;
252
- return waitFor(function () {
253
- expect(getByTestId('selected-option').textContent).toBe('readWrite');
254
- });
255
-
256
- case 3:
257
- case "end":
258
- return _context5.stop();
259
- }
260
- }, _callee5);
261
- })));
262
178
  });
263
179
  describe('onSend callback', function () {
264
180
  var pendingRecipient = {
265
181
  name: 'Alice',
266
182
  email: 'alice@example.com'
267
183
  };
268
- it('should call onClose and skip share when there are no pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
269
- var _setup6, getByTestId;
184
+ it('should call onClose and skip share when there are no pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
185
+ var _setup4, findByText, sendButton;
270
186
 
271
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
272
- while (1) switch (_context6.prev = _context6.next) {
187
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
188
+ while (1) switch (_context4.prev = _context4.next) {
273
189
  case 0:
274
190
  // pendingRecipients defaults to [] via beforeEach
275
- _setup6 = setup(), getByTestId = _setup6.getByTestId;
276
- _context6.next = 3;
277
- return waitFor(function () {
278
- expect(getByTestId('btn-send')).toBeTruthy();
279
- });
191
+ _setup4 = setup(), findByText = _setup4.findByText;
192
+ _context4.next = 3;
193
+ return findByText('Done');
280
194
 
281
195
  case 3:
282
- fireEvent.click(getByTestId('btn-send'));
283
- _context6.next = 6;
196
+ sendButton = _context4.sent;
197
+ fireEvent.click(sendButton);
198
+ _context4.next = 7;
284
199
  return waitFor(function () {
285
200
  expect(mockOnClose).toHaveBeenCalled();
286
201
  expect(mockShare).not.toHaveBeenCalled();
287
202
  });
288
203
 
289
- case 6:
204
+ case 7:
290
205
  case "end":
291
- return _context6.stop();
206
+ return _context4.stop();
292
207
  }
293
- }, _callee6);
208
+ }, _callee4);
294
209
  })));
295
- it('should call share with correct parameters', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
296
- var _setup7, getByTestId;
210
+ it('should call share with correct parameters', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
211
+ var _setup5, findByText, sendButton;
297
212
 
298
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
299
- while (1) switch (_context7.prev = _context7.next) {
213
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
214
+ while (1) switch (_context5.prev = _context5.next) {
300
215
  case 0:
301
216
  usePendingRecipients.mockReturnValue({
302
217
  pendingRecipients: [pendingRecipient],
@@ -306,15 +221,14 @@ describe('FederatedFolderModal', function () {
306
221
  });
307
222
  getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
308
223
  mockShare.mockResolvedValueOnce({});
309
- _setup7 = setup(), getByTestId = _setup7.getByTestId;
310
- _context7.next = 6;
311
- return waitFor(function () {
312
- expect(getByTestId('btn-send')).toBeTruthy();
313
- });
224
+ _setup5 = setup(), findByText = _setup5.findByText;
225
+ _context5.next = 6;
226
+ return findByText('Done');
314
227
 
315
228
  case 6:
316
- fireEvent.click(getByTestId('btn-send'));
317
- _context7.next = 9;
229
+ sendButton = _context5.sent;
230
+ fireEvent.click(sendButton);
231
+ _context5.next = 10;
318
232
  return waitFor(function () {
319
233
  expect(mockShare).toHaveBeenCalledWith({
320
234
  description: 'My Test Folder',
@@ -326,17 +240,17 @@ describe('FederatedFolderModal', function () {
326
240
  });
327
241
  });
328
242
 
329
- case 9:
243
+ case 10:
330
244
  case "end":
331
- return _context7.stop();
245
+ return _context5.stop();
332
246
  }
333
- }, _callee7);
247
+ }, _callee5);
334
248
  })));
335
- it('should show success alert and close modal on successful share', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
336
- var _setup8, getByTestId;
249
+ it('should show success alert and close modal on successful share', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
250
+ var _setup6, findByText, sendButton;
337
251
 
338
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
339
- while (1) switch (_context8.prev = _context8.next) {
252
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
253
+ while (1) switch (_context6.prev = _context6.next) {
340
254
  case 0:
341
255
  usePendingRecipients.mockReturnValue({
342
256
  pendingRecipients: [pendingRecipient],
@@ -346,15 +260,14 @@ describe('FederatedFolderModal', function () {
346
260
  });
347
261
  getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
348
262
  mockShare.mockResolvedValueOnce({});
349
- _setup8 = setup(), getByTestId = _setup8.getByTestId;
350
- _context8.next = 6;
351
- return waitFor(function () {
352
- expect(getByTestId('btn-send')).toBeTruthy();
353
- });
263
+ _setup6 = setup(), findByText = _setup6.findByText;
264
+ _context6.next = 6;
265
+ return findByText('Done');
354
266
 
355
267
  case 6:
356
- fireEvent.click(getByTestId('btn-send'));
357
- _context8.next = 9;
268
+ sendButton = _context6.sent;
269
+ fireEvent.click(sendButton);
270
+ _context6.next = 10;
358
271
  return waitFor(function () {
359
272
  expect(mockShowAlert).toHaveBeenCalledWith({
360
273
  message: 'Folder has been shared',
@@ -364,17 +277,17 @@ describe('FederatedFolderModal', function () {
364
277
  expect(mockOnClose).toHaveBeenCalled();
365
278
  });
366
279
 
367
- case 9:
280
+ case 10:
368
281
  case "end":
369
- return _context8.stop();
282
+ return _context6.stop();
370
283
  }
371
- }, _callee8);
284
+ }, _callee6);
372
285
  })));
373
- it('should show error alert when share fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
374
- var _setup9, getByTestId;
286
+ it('should show error alert when share fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
287
+ var _setup7, findByText, sendButton;
375
288
 
376
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
377
- while (1) switch (_context9.prev = _context9.next) {
289
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
290
+ while (1) switch (_context7.prev = _context7.next) {
378
291
  case 0:
379
292
  usePendingRecipients.mockReturnValue({
380
293
  pendingRecipients: [pendingRecipient],
@@ -384,15 +297,14 @@ describe('FederatedFolderModal', function () {
384
297
  });
385
298
  getOrCreateFromArray.mockResolvedValue([pendingRecipient]);
386
299
  mockShare.mockRejectedValueOnce(new Error('Share failed'));
387
- _setup9 = setup(), getByTestId = _setup9.getByTestId;
388
- _context9.next = 6;
389
- return waitFor(function () {
390
- expect(getByTestId('btn-send')).toBeTruthy();
391
- });
300
+ _setup7 = setup(), findByText = _setup7.findByText;
301
+ _context7.next = 6;
302
+ return findByText('Done');
392
303
 
393
304
  case 6:
394
- fireEvent.click(getByTestId('btn-send'));
395
- _context9.next = 9;
305
+ sendButton = _context7.sent;
306
+ fireEvent.click(sendButton);
307
+ _context7.next = 10;
396
308
  return waitFor(function () {
397
309
  expect(mockShowAlert).toHaveBeenCalledWith({
398
310
  message: 'Error while sharing folder',
@@ -402,71 +314,42 @@ describe('FederatedFolderModal', function () {
402
314
  expect(mockOnClose).not.toHaveBeenCalled();
403
315
  });
404
316
 
405
- case 9:
317
+ case 10:
406
318
  case "end":
407
- return _context9.stop();
408
- }
409
- }, _callee9);
410
- })));
411
- });
412
- describe('onRevoke callback', function () {
413
- it('should call revoke from sharing context for existing members', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
414
- var _setup10, getByTestId;
415
-
416
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
417
- while (1) switch (_context10.prev = _context10.next) {
418
- case 0:
419
- mockRevoke.mockResolvedValueOnce({});
420
- _setup10 = setup(), getByTestId = _setup10.getByTestId;
421
- _context10.next = 4;
422
- return waitFor(function () {
423
- expect(getByTestId('dumb-modal')).toBeTruthy();
424
- });
425
-
426
- case 4:
427
- fireEvent.click(getByTestId('btn-revoke'));
428
- _context10.next = 7;
429
- return waitFor(function () {
430
- expect(mockRevoke).toHaveBeenCalledWith({
431
- _id: 'folder-123'
432
- }, 'abc', 1);
433
- });
434
-
435
- case 7:
436
- case "end":
437
- return _context10.stop();
319
+ return _context7.stop();
438
320
  }
439
- }, _callee10);
321
+ }, _callee7);
440
322
  })));
441
323
  });
442
324
  describe('onClose callback', function () {
443
- it('should call onClose when close button is clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
444
- var _setup11, getByTestId;
325
+ it('should call onClose when close button is clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
326
+ var _setup8, findByRole, closeButton;
445
327
 
446
- return _regeneratorRuntime.wrap(function _callee11$(_context11) {
447
- while (1) switch (_context11.prev = _context11.next) {
328
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
329
+ while (1) switch (_context8.prev = _context8.next) {
448
330
  case 0:
449
- _setup11 = setup(), getByTestId = _setup11.getByTestId;
450
- _context11.next = 3;
451
- return waitFor(function () {
452
- expect(getByTestId('btn-close')).toBeTruthy();
331
+ _setup8 = setup(), findByRole = _setup8.findByRole;
332
+ _context8.next = 3;
333
+ return findByRole('button', {
334
+ name: /close/i
453
335
  });
454
336
 
455
337
  case 3:
456
- fireEvent.click(getByTestId('btn-close'));
338
+ closeButton = _context8.sent;
339
+ fireEvent.click(closeButton);
457
340
  expect(mockOnClose).toHaveBeenCalled();
458
341
 
459
- case 5:
342
+ case 6:
460
343
  case "end":
461
- return _context11.stop();
344
+ return _context8.stop();
462
345
  }
463
- }, _callee11);
346
+ }, _callee8);
464
347
  })));
465
- it('should ask confirmation when close button is clicked with pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
466
- var _setup12, getByRole, getByTestId, getByText;
348
+ it('should ask confirmation when close button is clicked with pending recipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
349
+ var _setup9, getByRole, findByRole, getByText, closeButton;
467
350
 
468
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
469
- while (1) switch (_context12.prev = _context12.next) {
351
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
352
+ while (1) switch (_context9.prev = _context9.next) {
470
353
  case 0:
471
354
  usePendingRecipients.mockReturnValue({
472
355
  pendingRecipients: [{
@@ -477,14 +360,15 @@ describe('FederatedFolderModal', function () {
477
360
  selectedOption: 'readWrite',
478
361
  setSelectedOption: jest.fn()
479
362
  });
480
- _setup12 = setup(), getByRole = _setup12.getByRole, getByTestId = _setup12.getByTestId, getByText = _setup12.getByText;
481
- _context12.next = 4;
482
- return waitFor(function () {
483
- expect(getByTestId('btn-close')).toBeTruthy();
363
+ _setup9 = setup(), getByRole = _setup9.getByRole, findByRole = _setup9.findByRole, getByText = _setup9.getByText;
364
+ _context9.next = 4;
365
+ return findByRole('button', {
366
+ name: /close/i
484
367
  });
485
368
 
486
369
  case 4:
487
- fireEvent.click(getByTestId('btn-close'));
370
+ closeButton = _context9.sent;
371
+ fireEvent.click(closeButton);
488
372
  expect(getByText("Discard the changes you haven't saved?")).toBeTruthy();
489
373
  expect(mockOnClose).not.toHaveBeenCalled();
490
374
  fireEvent.click(getByRole('button', {
@@ -492,17 +376,17 @@ describe('FederatedFolderModal', function () {
492
376
  }));
493
377
  expect(mockOnClose).not.toHaveBeenCalled();
494
378
 
495
- case 9:
379
+ case 10:
496
380
  case "end":
497
- return _context12.stop();
381
+ return _context9.stop();
498
382
  }
499
- }, _callee12);
383
+ }, _callee9);
500
384
  })));
501
- it('should close after discard confirmation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
502
- var _setup13, getByRole, getByTestId, getByText;
385
+ it('should close after discard confirmation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
386
+ var _setup10, getByRole, findByRole, getByText, closeButton;
503
387
 
504
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
505
- while (1) switch (_context13.prev = _context13.next) {
388
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
389
+ while (1) switch (_context10.prev = _context10.next) {
506
390
  case 0:
507
391
  usePendingRecipients.mockReturnValue({
508
392
  pendingRecipients: [{
@@ -513,63 +397,26 @@ describe('FederatedFolderModal', function () {
513
397
  selectedOption: 'readWrite',
514
398
  setSelectedOption: jest.fn()
515
399
  });
516
- _setup13 = setup(), getByRole = _setup13.getByRole, getByTestId = _setup13.getByTestId, getByText = _setup13.getByText;
517
- _context13.next = 4;
518
- return waitFor(function () {
519
- expect(getByTestId('btn-close')).toBeTruthy();
400
+ _setup10 = setup(), getByRole = _setup10.getByRole, findByRole = _setup10.findByRole, getByText = _setup10.getByText;
401
+ _context10.next = 4;
402
+ return findByRole('button', {
403
+ name: /close/i
520
404
  });
521
405
 
522
406
  case 4:
523
- fireEvent.click(getByTestId('btn-close'));
407
+ closeButton = _context10.sent;
408
+ fireEvent.click(closeButton);
524
409
  expect(getByText("Discard the changes you haven't saved?")).toBeTruthy();
525
410
  fireEvent.click(getByRole('button', {
526
411
  name: 'Discard'
527
412
  }));
528
413
  expect(mockOnClose).toHaveBeenCalledTimes(1);
529
414
 
530
- case 8:
531
- case "end":
532
- return _context13.stop();
533
- }
534
- }, _callee13);
535
- })));
536
- });
537
- describe('existing recipients', function () {
538
- var existingRecipients = [{
539
- index: 'sharing-abc-member-0',
540
- name: 'Charlie',
541
- email: 'charlie@example.com',
542
- status: 'owner',
543
- type: 'two-way',
544
- sharingId: 'abc',
545
- memberIndex: 0
546
- }, {
547
- index: 'sharing-abc-member-1',
548
- name: 'Diana',
549
- email: 'diana@example.com',
550
- status: 'ready',
551
- type: 'one-way',
552
- sharingId: 'abc',
553
- memberIndex: 1
554
- }];
555
- it('should display existing recipients from getRecipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
556
- var _setup14, getByTestId;
557
-
558
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
559
- while (1) switch (_context14.prev = _context14.next) {
560
- case 0:
561
- mockGetRecipients.mockReturnValue(existingRecipients);
562
- _setup14 = setup(), getByTestId = _setup14.getByTestId;
563
- _context14.next = 4;
564
- return waitFor(function () {
565
- expect(getByTestId('recipients-count').textContent).toBe('2');
566
- });
567
-
568
- case 4:
415
+ case 9:
569
416
  case "end":
570
- return _context14.stop();
417
+ return _context10.stop();
571
418
  }
572
- }, _callee14);
419
+ }, _callee10);
573
420
  })));
574
421
  });
575
422
  });