cozy-sharing 32.1.2 → 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.
- package/CHANGELOG.md +24 -0
- package/dist/components/FederatedFolder/FederatedFolderModal.js +96 -22
- package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +137 -219
- package/dist/components/Recipient/RecipientList.js +0 -15
- package/dist/components/ShareAutosuggest.js +1 -0
- package/dist/components/ShareAutosuggest.spec.js +12 -4
- package/dist/components/ShareDialogCozyToCozy.spec.js +55 -8
- package/dist/components/ShareDiscardChangesModal.js +35 -0
- package/dist/components/ShareModal/ShareModal.js +8 -8
- package/dist/components/ShareRecipientsInput.js +13 -3
- package/dist/components/ShareRecipientsInput.spec.js +63 -4
- package/dist/state.js +6 -1
- package/locales/en.json +10 -5
- package/locales/fr.json +10 -5
- package/locales/ru.json +10 -5
- package/locales/vi.json +10 -5
- package/package.json +2 -2
- package/src/components/FederatedFolder/FederatedFolderModal.jsx +230 -138
- package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +59 -134
- package/src/components/Recipient/RecipientList.jsx +0 -18
- package/src/components/ShareAutosuggest.jsx +1 -0
- package/src/components/ShareAutosuggest.spec.jsx +10 -5
- package/src/components/ShareDialogCozyToCozy.spec.jsx +50 -4
- package/src/components/ShareDiscardChangesModal.jsx +40 -0
- package/src/components/ShareModal/ShareModal.jsx +5 -5
- package/src/components/ShareRecipientsInput.jsx +11 -6
- package/src/components/ShareRecipientsInput.spec.jsx +59 -0
- package/src/state.js +5 -1
- package/dist/components/SharedDrive/SharedDriveRecipient.js +0 -61
- package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +0 -109
- package/dist/components/SharedDrive/SharedDriveRecipientStatus.js +0 -22
- package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +0 -145
- package/src/components/SharedDrive/SharedDriveRecipient.jsx +0 -62
- package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +0 -78
- package/src/components/SharedDrive/SharedDriveRecipientStatus.jsx +0 -23
- package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +0 -161
|
@@ -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,
|
|
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(),
|
|
130
|
+
_setup = setup(), findByText = _setup.findByText;
|
|
171
131
|
_context.next = 3;
|
|
172
|
-
return
|
|
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,
|
|
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
|
-
}),
|
|
152
|
+
}), findByText = _setup2.findByText;
|
|
195
153
|
_context2.next = 4;
|
|
196
|
-
return
|
|
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
|
|
207
|
-
var _setup3,
|
|
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(),
|
|
168
|
+
_setup3 = setup(), findByText = _setup3.findByText;
|
|
213
169
|
_context3.next = 3;
|
|
214
|
-
return
|
|
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
|
|
269
|
-
var
|
|
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
|
|
272
|
-
while (1) switch (
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
return
|
|
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
|
-
|
|
283
|
-
|
|
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
|
|
204
|
+
case 7:
|
|
290
205
|
case "end":
|
|
291
|
-
return
|
|
206
|
+
return _context4.stop();
|
|
292
207
|
}
|
|
293
|
-
},
|
|
208
|
+
}, _callee4);
|
|
294
209
|
})));
|
|
295
|
-
it('should call share with correct parameters', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
296
|
-
var
|
|
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
|
|
299
|
-
while (1) switch (
|
|
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
|
-
|
|
310
|
-
|
|
311
|
-
return
|
|
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
|
-
|
|
317
|
-
|
|
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
|
|
243
|
+
case 10:
|
|
330
244
|
case "end":
|
|
331
|
-
return
|
|
245
|
+
return _context5.stop();
|
|
332
246
|
}
|
|
333
|
-
},
|
|
247
|
+
}, _callee5);
|
|
334
248
|
})));
|
|
335
|
-
it('should show success alert and close modal on successful share', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
336
|
-
var
|
|
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
|
|
339
|
-
while (1) switch (
|
|
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
|
-
|
|
350
|
-
|
|
351
|
-
return
|
|
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
|
-
|
|
357
|
-
|
|
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
|
|
280
|
+
case 10:
|
|
368
281
|
case "end":
|
|
369
|
-
return
|
|
282
|
+
return _context6.stop();
|
|
370
283
|
}
|
|
371
|
-
},
|
|
284
|
+
}, _callee6);
|
|
372
285
|
})));
|
|
373
|
-
it('should show error alert when share fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
374
|
-
var
|
|
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
|
|
377
|
-
while (1) switch (
|
|
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
|
-
|
|
388
|
-
|
|
389
|
-
return
|
|
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
|
-
|
|
395
|
-
|
|
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,103 +314,109 @@ describe('FederatedFolderModal', function () {
|
|
|
402
314
|
expect(mockOnClose).not.toHaveBeenCalled();
|
|
403
315
|
});
|
|
404
316
|
|
|
405
|
-
case
|
|
317
|
+
case 10:
|
|
406
318
|
case "end":
|
|
407
|
-
return
|
|
319
|
+
return _context7.stop();
|
|
408
320
|
}
|
|
409
|
-
},
|
|
321
|
+
}, _callee7);
|
|
410
322
|
})));
|
|
411
323
|
});
|
|
412
|
-
describe('
|
|
413
|
-
it('should call
|
|
414
|
-
var
|
|
324
|
+
describe('onClose callback', function () {
|
|
325
|
+
it('should call onClose when close button is clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
326
|
+
var _setup8, findByRole, closeButton;
|
|
415
327
|
|
|
416
|
-
return _regeneratorRuntime.wrap(function
|
|
417
|
-
while (1) switch (
|
|
328
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
329
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
418
330
|
case 0:
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
expect(getByTestId('dumb-modal')).toBeTruthy();
|
|
331
|
+
_setup8 = setup(), findByRole = _setup8.findByRole;
|
|
332
|
+
_context8.next = 3;
|
|
333
|
+
return findByRole('button', {
|
|
334
|
+
name: /close/i
|
|
424
335
|
});
|
|
425
336
|
|
|
426
|
-
case
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
expect(mockRevoke).toHaveBeenCalledWith({
|
|
431
|
-
_id: 'folder-123'
|
|
432
|
-
}, 'abc', 1);
|
|
433
|
-
});
|
|
337
|
+
case 3:
|
|
338
|
+
closeButton = _context8.sent;
|
|
339
|
+
fireEvent.click(closeButton);
|
|
340
|
+
expect(mockOnClose).toHaveBeenCalled();
|
|
434
341
|
|
|
435
|
-
case
|
|
342
|
+
case 6:
|
|
436
343
|
case "end":
|
|
437
|
-
return
|
|
344
|
+
return _context8.stop();
|
|
438
345
|
}
|
|
439
|
-
},
|
|
346
|
+
}, _callee8);
|
|
440
347
|
})));
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
it('should call onClose when close button is clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
444
|
-
var _setup11, getByTestId;
|
|
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;
|
|
445
350
|
|
|
446
|
-
return _regeneratorRuntime.wrap(function
|
|
447
|
-
while (1) switch (
|
|
351
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
352
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
448
353
|
case 0:
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
354
|
+
usePendingRecipients.mockReturnValue({
|
|
355
|
+
pendingRecipients: [{
|
|
356
|
+
name: 'Alice',
|
|
357
|
+
email: 'alice@example.com'
|
|
358
|
+
}],
|
|
359
|
+
setPendingRecipients: jest.fn(),
|
|
360
|
+
selectedOption: 'readWrite',
|
|
361
|
+
setSelectedOption: jest.fn()
|
|
362
|
+
});
|
|
363
|
+
_setup9 = setup(), getByRole = _setup9.getByRole, findByRole = _setup9.findByRole, getByText = _setup9.getByText;
|
|
364
|
+
_context9.next = 4;
|
|
365
|
+
return findByRole('button', {
|
|
366
|
+
name: /close/i
|
|
453
367
|
});
|
|
454
368
|
|
|
455
|
-
case
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
369
|
+
case 4:
|
|
370
|
+
closeButton = _context9.sent;
|
|
371
|
+
fireEvent.click(closeButton);
|
|
372
|
+
expect(getByText("Discard the changes you haven't saved?")).toBeTruthy();
|
|
373
|
+
expect(mockOnClose).not.toHaveBeenCalled();
|
|
374
|
+
fireEvent.click(getByRole('button', {
|
|
375
|
+
name: 'Cancel'
|
|
376
|
+
}));
|
|
377
|
+
expect(mockOnClose).not.toHaveBeenCalled();
|
|
378
|
+
|
|
379
|
+
case 10:
|
|
460
380
|
case "end":
|
|
461
|
-
return
|
|
381
|
+
return _context9.stop();
|
|
462
382
|
}
|
|
463
|
-
},
|
|
383
|
+
}, _callee9);
|
|
464
384
|
})));
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
email: 'charlie@example.com',
|
|
471
|
-
status: 'owner',
|
|
472
|
-
type: 'two-way',
|
|
473
|
-
sharingId: 'abc',
|
|
474
|
-
memberIndex: 0
|
|
475
|
-
}, {
|
|
476
|
-
index: 'sharing-abc-member-1',
|
|
477
|
-
name: 'Diana',
|
|
478
|
-
email: 'diana@example.com',
|
|
479
|
-
status: 'ready',
|
|
480
|
-
type: 'one-way',
|
|
481
|
-
sharingId: 'abc',
|
|
482
|
-
memberIndex: 1
|
|
483
|
-
}];
|
|
484
|
-
it('should display existing recipients from getRecipients', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
485
|
-
var _setup12, getByTestId;
|
|
486
|
-
|
|
487
|
-
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
488
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
385
|
+
it('should close after discard confirmation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
386
|
+
var _setup10, getByRole, findByRole, getByText, closeButton;
|
|
387
|
+
|
|
388
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
389
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
489
390
|
case 0:
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
391
|
+
usePendingRecipients.mockReturnValue({
|
|
392
|
+
pendingRecipients: [{
|
|
393
|
+
name: 'Alice',
|
|
394
|
+
email: 'alice@example.com'
|
|
395
|
+
}],
|
|
396
|
+
setPendingRecipients: jest.fn(),
|
|
397
|
+
selectedOption: 'readWrite',
|
|
398
|
+
setSelectedOption: jest.fn()
|
|
399
|
+
});
|
|
400
|
+
_setup10 = setup(), getByRole = _setup10.getByRole, findByRole = _setup10.findByRole, getByText = _setup10.getByText;
|
|
401
|
+
_context10.next = 4;
|
|
402
|
+
return findByRole('button', {
|
|
403
|
+
name: /close/i
|
|
495
404
|
});
|
|
496
405
|
|
|
497
406
|
case 4:
|
|
407
|
+
closeButton = _context10.sent;
|
|
408
|
+
fireEvent.click(closeButton);
|
|
409
|
+
expect(getByText("Discard the changes you haven't saved?")).toBeTruthy();
|
|
410
|
+
fireEvent.click(getByRole('button', {
|
|
411
|
+
name: 'Discard'
|
|
412
|
+
}));
|
|
413
|
+
expect(mockOnClose).toHaveBeenCalledTimes(1);
|
|
414
|
+
|
|
415
|
+
case 9:
|
|
498
416
|
case "end":
|
|
499
|
-
return
|
|
417
|
+
return _context10.stop();
|
|
500
418
|
}
|
|
501
|
-
},
|
|
419
|
+
}, _callee10);
|
|
502
420
|
})));
|
|
503
421
|
});
|
|
504
422
|
});
|
|
@@ -4,7 +4,6 @@ import { GroupRecipient } from './GroupRecipient';
|
|
|
4
4
|
import MemberRecipient from './MemberRecipient';
|
|
5
5
|
import { usePrevious } from '../../helpers/hooks';
|
|
6
6
|
import { filterAndReworkRecipients } from '../../helpers/recipients';
|
|
7
|
-
import SharedDriveRecipient from '../SharedDrive/SharedDriveRecipient';
|
|
8
7
|
|
|
9
8
|
var RecipientList = function RecipientList(_ref) {
|
|
10
9
|
var recipients = _ref.recipients,
|
|
@@ -15,27 +14,13 @@ var RecipientList = function RecipientList(_ref) {
|
|
|
15
14
|
documentType = _ref.documentType,
|
|
16
15
|
onRevoke = _ref.onRevoke,
|
|
17
16
|
onRevokeSelf = _ref.onRevokeSelf,
|
|
18
|
-
onSetType = _ref.onSetType,
|
|
19
17
|
verifyRecipient = _ref.verifyRecipient;
|
|
20
18
|
var previousRecipients = usePrevious(recipients);
|
|
21
19
|
var recipientsToDisplay = filterAndReworkRecipients(recipients, previousRecipients);
|
|
22
20
|
return recipientsToDisplay.map(function (recipient) {
|
|
23
|
-
var _recipient$index;
|
|
24
|
-
|
|
25
21
|
var recipientConfirmationData = recipientsToBeConfirmed.find(function (user) {
|
|
26
22
|
return user.email === recipient.email;
|
|
27
23
|
});
|
|
28
|
-
var isSharedDriveRecipient = recipient === null || recipient === void 0 || (_recipient$index = recipient.index) === null || _recipient$index === void 0 ? void 0 : _recipient$index.toString().startsWith('virtual-shared-drive');
|
|
29
|
-
|
|
30
|
-
if (isSharedDriveRecipient) {
|
|
31
|
-
return /*#__PURE__*/React.createElement(SharedDriveRecipient, _extends({}, recipient, {
|
|
32
|
-
key: recipient.index,
|
|
33
|
-
onRevoke: onRevoke,
|
|
34
|
-
onSetType: onSetType,
|
|
35
|
-
fadeIn: recipient.hasBeenJustAdded
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
24
|
var isGroupRecipient = recipient.members;
|
|
40
25
|
|
|
41
26
|
if (isGroupRecipient) {
|
|
@@ -220,6 +220,7 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
220
220
|
renderInputComponent: renderInput,
|
|
221
221
|
highlightFirstSuggestion: true,
|
|
222
222
|
inputProps: {
|
|
223
|
+
autoFocus: true,
|
|
223
224
|
onFocus: onAutosuggestFocus,
|
|
224
225
|
onChange: onAutosuggestChange,
|
|
225
226
|
onPaste: onAutosuggestPaste,
|
|
@@ -78,17 +78,25 @@ describe('ShareAutosuggest', function () {
|
|
|
78
78
|
email: 'quentin.valmori@cozycloud.cc'
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
|
-
it('should show loading
|
|
81
|
+
it('should show loading indicator when loading prop is true (autoFocus triggers onFocus on mount)', function () {
|
|
82
82
|
var onPick = jest.fn();
|
|
83
83
|
var onRemove = jest.fn();
|
|
84
84
|
setup({
|
|
85
85
|
onPick: onPick,
|
|
86
86
|
onRemove: onRemove,
|
|
87
87
|
loading: true
|
|
88
|
+
}); // autoFocus triggers onFocus on mount, which sets isLoadingDisplayed
|
|
89
|
+
|
|
90
|
+
expect(screen.getByText('loading')).toBeInTheDocument();
|
|
91
|
+
});
|
|
92
|
+
it('should not show loading indicator when loading prop is false', function () {
|
|
93
|
+
var onPick = jest.fn();
|
|
94
|
+
var onRemove = jest.fn();
|
|
95
|
+
setup({
|
|
96
|
+
onPick: onPick,
|
|
97
|
+
onRemove: onRemove,
|
|
98
|
+
loading: false
|
|
88
99
|
});
|
|
89
|
-
var inputNode = screen.getByPlaceholderText('myPlaceHolder');
|
|
90
100
|
expect(screen.queryByText('loading')).toBeNull();
|
|
91
|
-
fireEvent.focus(inputNode);
|
|
92
|
-
expect(screen.getByText('loading')).toBeInTheDocument();
|
|
93
101
|
});
|
|
94
102
|
});
|