cozy-sharing 40.1.2 → 40.1.4

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.
@@ -876,6 +876,124 @@ describe('shared drive recipient revocation', function () {
876
876
  }, _callee17);
877
877
  })));
878
878
  });
879
+ describe('revokeSelf', function () {
880
+ var document = {
881
+ id: 'received-folder',
882
+ _id: 'received-folder'
883
+ };
884
+ var sharing = {
885
+ id: 'received-sharing',
886
+ type: 'io.cozy.sharings',
887
+ attributes: {
888
+ owner: false,
889
+ drive: true,
890
+ rules: [{
891
+ values: [document.id]
892
+ }],
893
+ members: []
894
+ }
895
+ };
896
+ var recipients = [{
897
+ sharingId: sharing.id,
898
+ memberIndex: 1
899
+ }];
900
+ var forbidden = Object.assign(new Error('Forbidden'), {
901
+ status: 403
902
+ });
903
+ var provider;
904
+ var sharingCol;
905
+ beforeEach(function () {
906
+ var client = createMockClient({});
907
+ sharingCol = {
908
+ revokeSelf: jest.fn().mockResolvedValue({}),
909
+ fetchEffectiveRecipients: jest.fn().mockRejectedValue(forbidden)
910
+ };
911
+
912
+ client.collection = function () {
913
+ return sharingCol;
914
+ };
915
+
916
+ provider = setupProvider(client, {}, reducer(undefined, receiveSharings({
917
+ sharings: [sharing]
918
+ })));
919
+ provider.dispatch(receiveEffectiveRecipients(document.id, recipients));
920
+ provider.dispatch(receiveEffectiveRecipients('other-folder', recipients));
921
+ });
922
+ it.each([true, false])('forgets the sharing and clears its recipients without reloading lost access (drive: %s)', /*#__PURE__*/function () {
923
+ var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(drive) {
924
+ return _regeneratorRuntime.wrap(function _callee18$(_context18) {
925
+ while (1) switch (_context18.prev = _context18.next) {
926
+ case 0:
927
+ provider.state.sharings = [_objectSpread(_objectSpread({}, sharing), {}, {
928
+ attributes: _objectSpread(_objectSpread({}, sharing.attributes), {}, {
929
+ drive: drive
930
+ })
931
+ })];
932
+ _context18.next = 3;
933
+ return provider.revokeSelf(document);
934
+
935
+ case 3:
936
+ expect(getDocumentSharing(provider.state, document.id)).toBeNull();
937
+ expect(getEffectiveRecipients(provider.state, document.id)).toEqual([]);
938
+ expect(getEffectiveRecipients(provider.state, 'other-folder')).toEqual(recipients);
939
+ expect(sharingCol.fetchEffectiveRecipients).not.toHaveBeenCalled();
940
+
941
+ case 7:
942
+ case "end":
943
+ return _context18.stop();
944
+ }
945
+ }, _callee18);
946
+ }));
947
+
948
+ return function (_x) {
949
+ return _ref20.apply(this, arguments);
950
+ };
951
+ }());
952
+ it.each([403, 500])('preserves sharing state and rejects when self-revocation fails (%s)', /*#__PURE__*/function () {
953
+ var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(status) {
954
+ var error;
955
+ return _regeneratorRuntime.wrap(function _callee19$(_context19) {
956
+ while (1) switch (_context19.prev = _context19.next) {
957
+ case 0:
958
+ error = Object.assign(new Error('Revocation failed'), {
959
+ status: status
960
+ });
961
+ sharingCol.revokeSelf.mockRejectedValue(error);
962
+ _context19.next = 4;
963
+ return expect(provider.revokeSelf(document)).rejects.toBe(error);
964
+
965
+ case 4:
966
+ expect(getDocumentSharing(provider.state, document.id)).toEqual(sharing);
967
+ expect(getEffectiveRecipients(provider.state, document.id)).toEqual(recipients);
968
+
969
+ case 6:
970
+ case "end":
971
+ return _context19.stop();
972
+ }
973
+ }, _callee19);
974
+ }));
975
+
976
+ return function (_x2) {
977
+ return _ref21.apply(this, arguments);
978
+ };
979
+ }());
980
+ it('still rejects forbidden recipient refreshes outside self-revocation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
981
+ return _regeneratorRuntime.wrap(function _callee20$(_context20) {
982
+ while (1) switch (_context20.prev = _context20.next) {
983
+ case 0:
984
+ _context20.next = 2;
985
+ return expect(provider.fetchEffectiveRecipients(document.id)).rejects.toBe(forbidden);
986
+
987
+ case 2:
988
+ expect(getEffectiveRecipients(provider.state, document.id)).toEqual(recipients);
989
+
990
+ case 3:
991
+ case "end":
992
+ return _context20.stop();
993
+ }
994
+ }, _callee20);
995
+ })));
996
+ });
879
997
  describe('share flow reused by PermissionTypeMenu upgrade', function () {
880
998
  var PARENT_SHARING = {
881
999
  _id: 'parent_sharing',
@@ -988,13 +1106,13 @@ describe('share flow reused by PermissionTypeMenu upgrade', function () {
988
1106
  return provider;
989
1107
  };
990
1108
 
991
- it('creates a child sharing when the child has no direct sharing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
1109
+ it('creates a child sharing when the child has no direct sharing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
992
1110
  var provider;
993
- return _regeneratorRuntime.wrap(function _callee18$(_context18) {
994
- while (1) switch (_context18.prev = _context18.next) {
1111
+ return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1112
+ while (1) switch (_context21.prev = _context21.next) {
995
1113
  case 0:
996
1114
  provider = setupWithParent();
997
- _context18.next = 3;
1115
+ _context21.next = 3;
998
1116
  return provider.share({
999
1117
  document: childDocument,
1000
1118
  recipients: [bobContact],
@@ -1020,17 +1138,17 @@ describe('share flow reused by PermissionTypeMenu upgrade', function () {
1020
1138
 
1021
1139
  case 7:
1022
1140
  case "end":
1023
- return _context18.stop();
1141
+ return _context21.stop();
1024
1142
  }
1025
- }, _callee18);
1143
+ }, _callee21);
1026
1144
  })));
1027
- it('refreshes the child effective recipients as two-way and leaves the parent unchanged', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
1145
+ it('refreshes the child effective recipients as two-way and leaves the parent unchanged', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
1028
1146
  var provider, effectiveRecipients, parentSharing;
1029
- return _regeneratorRuntime.wrap(function _callee19$(_context19) {
1030
- while (1) switch (_context19.prev = _context19.next) {
1147
+ return _regeneratorRuntime.wrap(function _callee22$(_context22) {
1148
+ while (1) switch (_context22.prev = _context22.next) {
1031
1149
  case 0:
1032
1150
  provider = setupWithParent();
1033
- _context19.next = 3;
1151
+ _context22.next = 3;
1034
1152
  return provider.share({
1035
1153
  document: childDocument,
1036
1154
  recipients: [bobContact],
@@ -1058,14 +1176,14 @@ describe('share flow reused by PermissionTypeMenu upgrade', function () {
1058
1176
 
1059
1177
  case 15:
1060
1178
  case "end":
1061
- return _context19.stop();
1179
+ return _context22.stop();
1062
1180
  }
1063
- }, _callee19);
1181
+ }, _callee22);
1064
1182
  })));
1065
- it('adds the recipient to an existing child sharing and preserves the other member', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
1183
+ it('adds the recipient to an existing child sharing and preserves the other member', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
1066
1184
  var otherMember, childSharing, updatedSharing, provider, childSharingInState, parentSharing;
1067
- return _regeneratorRuntime.wrap(function _callee20$(_context20) {
1068
- while (1) switch (_context20.prev = _context20.next) {
1185
+ return _regeneratorRuntime.wrap(function _callee23$(_context23) {
1186
+ while (1) switch (_context23.prev = _context23.next) {
1069
1187
  case 0:
1070
1188
  otherMember = {
1071
1189
  status: 'ready',
@@ -1092,7 +1210,7 @@ describe('share flow reused by PermissionTypeMenu upgrade', function () {
1092
1210
  provider.sharingCol.addRecipients = jest.fn().mockResolvedValue({
1093
1211
  data: updatedSharing
1094
1212
  });
1095
- _context20.next = 7;
1213
+ _context23.next = 7;
1096
1214
  return provider.share({
1097
1215
  document: childDocument,
1098
1216
  recipients: [bobContact],
@@ -1123,18 +1241,18 @@ describe('share flow reused by PermissionTypeMenu upgrade', function () {
1123
1241
 
1124
1242
  case 16:
1125
1243
  case "end":
1126
- return _context20.stop();
1244
+ return _context23.stop();
1127
1245
  }
1128
- }, _callee20);
1246
+ }, _callee23);
1129
1247
  })));
1130
- it('leaves the parent unchanged and does not refresh when the child sharing creation fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
1248
+ it('leaves the parent unchanged and does not refresh when the child sharing creation fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {
1131
1249
  var provider, parentSharing;
1132
- return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1133
- while (1) switch (_context21.prev = _context21.next) {
1250
+ return _regeneratorRuntime.wrap(function _callee24$(_context24) {
1251
+ while (1) switch (_context24.prev = _context24.next) {
1134
1252
  case 0:
1135
1253
  provider = setupWithParent();
1136
1254
  provider.sharingCol.create = jest.fn().mockRejectedValue(new Error('Network error'));
1137
- _context21.next = 4;
1255
+ _context24.next = 4;
1138
1256
  return expect(provider.share({
1139
1257
  document: childDocument,
1140
1258
  recipients: [bobContact],
@@ -1155,9 +1273,9 @@ describe('share flow reused by PermissionTypeMenu upgrade', function () {
1155
1273
 
1156
1274
  case 11:
1157
1275
  case "end":
1158
- return _context21.stop();
1276
+ return _context24.stop();
1159
1277
  }
1160
- }, _callee21);
1278
+ }, _callee24);
1161
1279
  })));
1162
1280
  });
1163
1281
  describe('fetchSharedDriveSharingLinks', function () {
@@ -1183,10 +1301,10 @@ describe('fetchSharedDriveSharingLinks', function () {
1183
1301
  id: 'file_in_drive',
1184
1302
  driveId: 'drive_123'
1185
1303
  };
1186
- it('fetches shared drive sharing links by file id', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
1304
+ it('fetches shared drive sharing links by file id', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
1187
1305
  var mockFindLinksByIds, mockClient, provider, result, permissions;
1188
- return _regeneratorRuntime.wrap(function _callee22$(_context22) {
1189
- while (1) switch (_context22.prev = _context22.next) {
1306
+ return _regeneratorRuntime.wrap(function _callee25$(_context25) {
1307
+ while (1) switch (_context25.prev = _context25.next) {
1190
1308
  case 0:
1191
1309
  mockFindLinksByIds = jest.fn().mockResolvedValue({
1192
1310
  data: [PERM_DRIVE_FILE]
@@ -1196,11 +1314,11 @@ describe('fetchSharedDriveSharingLinks', function () {
1196
1314
  findLinksByIds: mockFindLinksByIds
1197
1315
  });
1198
1316
  provider = setupProvider(mockClient);
1199
- _context22.next = 6;
1317
+ _context25.next = 6;
1200
1318
  return provider.fetchSharedDriveSharingLinks(driveFile);
1201
1319
 
1202
1320
  case 6:
1203
- result = _context22.sent;
1321
+ result = _context25.sent;
1204
1322
  expect(mockClient.collection).toHaveBeenCalledWith('io.cozy.permissions', {
1205
1323
  driveId: 'drive_123'
1206
1324
  });
@@ -1213,14 +1331,14 @@ describe('fetchSharedDriveSharingLinks', function () {
1213
1331
 
1214
1332
  case 14:
1215
1333
  case "end":
1216
- return _context22.stop();
1334
+ return _context25.stop();
1217
1335
  }
1218
- }, _callee22);
1336
+ }, _callee25);
1219
1337
  })));
1220
- it('returns an empty array and skips the API call for non-shared-drive documents', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
1338
+ it('returns an empty array and skips the API call for non-shared-drive documents', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
1221
1339
  var mockClient, findLinksByIds, provider, result;
1222
- return _regeneratorRuntime.wrap(function _callee23$(_context23) {
1223
- while (1) switch (_context23.prev = _context23.next) {
1340
+ return _regeneratorRuntime.wrap(function _callee26$(_context26) {
1341
+ while (1) switch (_context26.prev = _context26.next) {
1224
1342
  case 0:
1225
1343
  mockClient = createMockClient({});
1226
1344
  findLinksByIds = jest.fn();
@@ -1229,27 +1347,27 @@ describe('fetchSharedDriveSharingLinks', function () {
1229
1347
  });
1230
1348
  provider = setupProvider(mockClient);
1231
1349
  provider.dispatch = jest.fn();
1232
- _context23.next = 7;
1350
+ _context26.next = 7;
1233
1351
  return provider.fetchSharedDriveSharingLinks({
1234
1352
  _id: 'regular_file'
1235
1353
  });
1236
1354
 
1237
1355
  case 7:
1238
- result = _context23.sent;
1356
+ result = _context26.sent;
1239
1357
  expect(result).toEqual([]);
1240
1358
  expect(findLinksByIds).not.toHaveBeenCalled();
1241
1359
  expect(provider.dispatch).not.toHaveBeenCalled();
1242
1360
 
1243
1361
  case 11:
1244
1362
  case "end":
1245
- return _context23.stop();
1363
+ return _context26.stop();
1246
1364
  }
1247
- }, _callee23);
1365
+ }, _callee26);
1248
1366
  })));
1249
- it('uses document.id as a fallback when _id is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {
1367
+ it('uses document.id as a fallback when _id is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
1250
1368
  var mockFindLinksByIds, mockClient, provider;
1251
- return _regeneratorRuntime.wrap(function _callee24$(_context24) {
1252
- while (1) switch (_context24.prev = _context24.next) {
1369
+ return _regeneratorRuntime.wrap(function _callee27$(_context27) {
1370
+ while (1) switch (_context27.prev = _context27.next) {
1253
1371
  case 0:
1254
1372
  mockFindLinksByIds = jest.fn().mockResolvedValue({
1255
1373
  data: [PERM_DRIVE_FILE]
@@ -1259,7 +1377,7 @@ describe('fetchSharedDriveSharingLinks', function () {
1259
1377
  findLinksByIds: mockFindLinksByIds
1260
1378
  });
1261
1379
  provider = setupProvider(mockClient);
1262
- _context24.next = 6;
1380
+ _context27.next = 6;
1263
1381
  return provider.fetchSharedDriveSharingLinks({
1264
1382
  id: 'file_in_drive',
1265
1383
  driveId: 'drive_123'
@@ -1270,14 +1388,14 @@ describe('fetchSharedDriveSharingLinks', function () {
1270
1388
 
1271
1389
  case 7:
1272
1390
  case "end":
1273
- return _context24.stop();
1391
+ return _context27.stop();
1274
1392
  }
1275
- }, _callee24);
1393
+ }, _callee27);
1276
1394
  })));
1277
- it('does not dispatch when the response has no data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
1395
+ it('does not dispatch when the response has no data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
1278
1396
  var mockFindLinksByIds, mockClient, provider, result;
1279
- return _regeneratorRuntime.wrap(function _callee25$(_context25) {
1280
- while (1) switch (_context25.prev = _context25.next) {
1397
+ return _regeneratorRuntime.wrap(function _callee28$(_context28) {
1398
+ while (1) switch (_context28.prev = _context28.next) {
1281
1399
  case 0:
1282
1400
  mockFindLinksByIds = jest.fn().mockResolvedValue({
1283
1401
  data: []
@@ -1288,19 +1406,19 @@ describe('fetchSharedDriveSharingLinks', function () {
1288
1406
  });
1289
1407
  provider = setupProvider(mockClient);
1290
1408
  provider.dispatch = jest.fn();
1291
- _context25.next = 7;
1409
+ _context28.next = 7;
1292
1410
  return provider.fetchSharedDriveSharingLinks(driveFile);
1293
1411
 
1294
1412
  case 7:
1295
- result = _context25.sent;
1413
+ result = _context28.sent;
1296
1414
  expect(result).toEqual([]);
1297
1415
  expect(provider.dispatch).not.toHaveBeenCalled();
1298
1416
 
1299
1417
  case 10:
1300
1418
  case "end":
1301
- return _context25.stop();
1419
+ return _context28.stop();
1302
1420
  }
1303
- }, _callee25);
1421
+ }, _callee28);
1304
1422
  })));
1305
1423
  });
1306
1424
  describe('shareByLink shared drive 409 recovery', function () {
@@ -1326,10 +1444,10 @@ describe('shareByLink shared drive 409 recovery', function () {
1326
1444
  id: 'file_in_drive',
1327
1445
  driveId: 'drive_123'
1328
1446
  };
1329
- it('falls back to fetching existing links when create returns 409', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
1447
+ it('falls back to fetching existing links when create returns 409', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
1330
1448
  var conflict, mockCreateSharingLink, mockFindLinksByIds, mockClient, provider, resp;
1331
- return _regeneratorRuntime.wrap(function _callee26$(_context26) {
1332
- while (1) switch (_context26.prev = _context26.next) {
1449
+ return _regeneratorRuntime.wrap(function _callee29$(_context29) {
1450
+ while (1) switch (_context29.prev = _context29.next) {
1333
1451
  case 0:
1334
1452
  conflict = Object.assign(new Error('Conflict'), {
1335
1453
  status: 409
@@ -1344,27 +1462,27 @@ describe('shareByLink shared drive 409 recovery', function () {
1344
1462
  findLinksByIds: mockFindLinksByIds
1345
1463
  });
1346
1464
  provider = setupProvider(mockClient);
1347
- _context26.next = 8;
1465
+ _context29.next = 8;
1348
1466
  return provider.shareByLink(driveFile, {
1349
1467
  verbs: ['GET']
1350
1468
  });
1351
1469
 
1352
1470
  case 8:
1353
- resp = _context26.sent;
1471
+ resp = _context29.sent;
1354
1472
  expect(mockCreateSharingLink).toHaveBeenCalled();
1355
1473
  expect(mockFindLinksByIds).toHaveBeenCalledWith(['file_in_drive']);
1356
1474
  expect(resp.data.id).toBe(PERM_DRIVE_FILE.id);
1357
1475
 
1358
1476
  case 12:
1359
1477
  case "end":
1360
- return _context26.stop();
1478
+ return _context29.stop();
1361
1479
  }
1362
- }, _callee26);
1480
+ }, _callee29);
1363
1481
  })));
1364
- it('does not duplicate existing links when 409 recovery refetches them', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
1482
+ it('does not duplicate existing links when 409 recovery refetches them', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
1365
1483
  var conflict, mockCreateSharingLink, mockFindLinksByIds, mockClient, provider, resp, permissions;
1366
- return _regeneratorRuntime.wrap(function _callee27$(_context27) {
1367
- while (1) switch (_context27.prev = _context27.next) {
1484
+ return _regeneratorRuntime.wrap(function _callee30$(_context30) {
1485
+ while (1) switch (_context30.prev = _context30.next) {
1368
1486
  case 0:
1369
1487
  conflict = Object.assign(new Error('Conflict'), {
1370
1488
  status: 409
@@ -1379,13 +1497,13 @@ describe('shareByLink shared drive 409 recovery', function () {
1379
1497
  findLinksByIds: mockFindLinksByIds
1380
1498
  });
1381
1499
  provider = setupProvider(mockClient, {}, reducer(undefined, addSharingLink(PERM_DRIVE_FILE)));
1382
- _context27.next = 8;
1500
+ _context30.next = 8;
1383
1501
  return provider.shareByLink(driveFile, {
1384
1502
  verbs: ['GET']
1385
1503
  });
1386
1504
 
1387
1505
  case 8:
1388
- resp = _context27.sent;
1506
+ resp = _context30.sent;
1389
1507
  permissions = getDocumentPermissions(provider.state, 'file_in_drive');
1390
1508
  expect(resp.data.id).toBe(PERM_DRIVE_FILE.id);
1391
1509
  expect(provider.dispatch).not.toHaveBeenCalled();
@@ -1393,14 +1511,14 @@ describe('shareByLink shared drive 409 recovery', function () {
1393
1511
 
1394
1512
  case 13:
1395
1513
  case "end":
1396
- return _context27.stop();
1514
+ return _context30.stop();
1397
1515
  }
1398
- }, _callee27);
1516
+ }, _callee30);
1399
1517
  })));
1400
- it('rethrows the original error when 409 happens and no link is found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
1518
+ it('rethrows the original error when 409 happens and no link is found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
1401
1519
  var conflict, mockCreateSharingLink, mockFindLinksByIds, mockClient, provider;
1402
- return _regeneratorRuntime.wrap(function _callee28$(_context28) {
1403
- while (1) switch (_context28.prev = _context28.next) {
1520
+ return _regeneratorRuntime.wrap(function _callee31$(_context31) {
1521
+ while (1) switch (_context31.prev = _context31.next) {
1404
1522
  case 0:
1405
1523
  conflict = Object.assign(new Error('Conflict'), {
1406
1524
  status: 409
@@ -1416,16 +1534,16 @@ describe('shareByLink shared drive 409 recovery', function () {
1416
1534
  });
1417
1535
  provider = setupProvider(mockClient);
1418
1536
  provider.dispatch = jest.fn();
1419
- _context28.next = 9;
1537
+ _context31.next = 9;
1420
1538
  return expect(provider.shareByLink(driveFile, {
1421
1539
  verbs: ['GET']
1422
1540
  })).rejects.toBe(conflict);
1423
1541
 
1424
1542
  case 9:
1425
1543
  case "end":
1426
- return _context28.stop();
1544
+ return _context31.stop();
1427
1545
  }
1428
- }, _callee28);
1546
+ }, _callee31);
1429
1547
  })));
1430
1548
  });
1431
1549
  describe('updateSharingMemberType', function () {
@@ -1468,37 +1586,37 @@ describe('updateSharingMemberType', function () {
1468
1586
  })
1469
1587
  };
1470
1588
  });
1471
- it('should throw when sharing is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
1472
- return _regeneratorRuntime.wrap(function _callee29$(_context29) {
1473
- while (1) switch (_context29.prev = _context29.next) {
1589
+ it('should throw when sharing is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32() {
1590
+ return _regeneratorRuntime.wrap(function _callee32$(_context32) {
1591
+ while (1) switch (_context32.prev = _context32.next) {
1474
1592
  case 0:
1475
- _context29.next = 2;
1593
+ _context32.next = 2;
1476
1594
  return expect(instance.updateSharingMemberType('unknown-id', 1, 'one-way')).rejects.toThrow('Sharing not found');
1477
1595
 
1478
1596
  case 2:
1479
1597
  case "end":
1480
- return _context29.stop();
1598
+ return _context32.stop();
1481
1599
  }
1482
- }, _callee29);
1600
+ }, _callee32);
1483
1601
  })));
1484
- it('should throw when member is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
1485
- return _regeneratorRuntime.wrap(function _callee30$(_context30) {
1486
- while (1) switch (_context30.prev = _context30.next) {
1602
+ it('should throw when member is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33() {
1603
+ return _regeneratorRuntime.wrap(function _callee33$(_context33) {
1604
+ while (1) switch (_context33.prev = _context33.next) {
1487
1605
  case 0:
1488
- _context30.next = 2;
1606
+ _context33.next = 2;
1489
1607
  return expect(instance.updateSharingMemberType('sharing-123', 99, 'one-way')).rejects.toThrow('Member not found');
1490
1608
 
1491
1609
  case 2:
1492
1610
  case "end":
1493
- return _context30.stop();
1611
+ return _context33.stop();
1494
1612
  }
1495
- }, _callee30);
1613
+ }, _callee33);
1496
1614
  })));
1497
- it('should call setReadOnly when switching to one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
1498
- return _regeneratorRuntime.wrap(function _callee31$(_context31) {
1499
- while (1) switch (_context31.prev = _context31.next) {
1615
+ it('should call setReadOnly when switching to one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34() {
1616
+ return _regeneratorRuntime.wrap(function _callee34$(_context34) {
1617
+ while (1) switch (_context34.prev = _context34.next) {
1500
1618
  case 0:
1501
- _context31.next = 2;
1619
+ _context34.next = 2;
1502
1620
  return instance.updateSharingMemberType('sharing-123', 1, 'one-way');
1503
1621
 
1504
1622
  case 2:
@@ -1507,15 +1625,15 @@ describe('updateSharingMemberType', function () {
1507
1625
 
1508
1626
  case 4:
1509
1627
  case "end":
1510
- return _context31.stop();
1628
+ return _context34.stop();
1511
1629
  }
1512
- }, _callee31);
1630
+ }, _callee34);
1513
1631
  })));
1514
- it('should call setReadWrite when switching to two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32() {
1515
- return _regeneratorRuntime.wrap(function _callee32$(_context32) {
1516
- while (1) switch (_context32.prev = _context32.next) {
1632
+ it('should call setReadWrite when switching to two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35() {
1633
+ return _regeneratorRuntime.wrap(function _callee35$(_context35) {
1634
+ while (1) switch (_context35.prev = _context35.next) {
1517
1635
  case 0:
1518
- _context32.next = 2;
1636
+ _context35.next = 2;
1519
1637
  return instance.updateSharingMemberType('sharing-123', 1, 'two-way');
1520
1638
 
1521
1639
  case 2:
@@ -1524,15 +1642,15 @@ describe('updateSharingMemberType', function () {
1524
1642
 
1525
1643
  case 4:
1526
1644
  case "end":
1527
- return _context32.stop();
1645
+ return _context35.stop();
1528
1646
  }
1529
- }, _callee32);
1647
+ }, _callee35);
1530
1648
  })));
1531
- it('should optimistically dispatch a state update when switching to one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33() {
1532
- return _regeneratorRuntime.wrap(function _callee33$(_context33) {
1533
- while (1) switch (_context33.prev = _context33.next) {
1649
+ it('should optimistically dispatch a state update when switching to one-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36() {
1650
+ return _regeneratorRuntime.wrap(function _callee36$(_context36) {
1651
+ while (1) switch (_context36.prev = _context36.next) {
1534
1652
  case 0:
1535
- _context33.next = 2;
1653
+ _context36.next = 2;
1536
1654
  return instance.updateSharingMemberType('sharing-123', 1, 'one-way');
1537
1655
 
1538
1656
  case 2:
@@ -1549,15 +1667,15 @@ describe('updateSharingMemberType', function () {
1549
1667
 
1550
1668
  case 3:
1551
1669
  case "end":
1552
- return _context33.stop();
1670
+ return _context36.stop();
1553
1671
  }
1554
- }, _callee33);
1672
+ }, _callee36);
1555
1673
  })));
1556
- it('should optimistically dispatch a state update when switching to two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34() {
1557
- return _regeneratorRuntime.wrap(function _callee34$(_context34) {
1558
- while (1) switch (_context34.prev = _context34.next) {
1674
+ it('should optimistically dispatch a state update when switching to two-way', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee37() {
1675
+ return _regeneratorRuntime.wrap(function _callee37$(_context37) {
1676
+ while (1) switch (_context37.prev = _context37.next) {
1559
1677
  case 0:
1560
- _context34.next = 2;
1678
+ _context37.next = 2;
1561
1679
  return instance.updateSharingMemberType('sharing-123', 1, 'two-way');
1562
1680
 
1563
1681
  case 2:
@@ -1574,44 +1692,44 @@ describe('updateSharingMemberType', function () {
1574
1692
 
1575
1693
  case 3:
1576
1694
  case "end":
1577
- return _context34.stop();
1695
+ return _context37.stop();
1578
1696
  }
1579
- }, _callee34);
1697
+ }, _callee37);
1580
1698
  })));
1581
- it('should rethrow error if setReadOnly fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35() {
1582
- return _regeneratorRuntime.wrap(function _callee35$(_context35) {
1583
- while (1) switch (_context35.prev = _context35.next) {
1699
+ it('should rethrow error if setReadOnly fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38() {
1700
+ return _regeneratorRuntime.wrap(function _callee38$(_context38) {
1701
+ while (1) switch (_context38.prev = _context38.next) {
1584
1702
  case 0:
1585
1703
  instance.sharingCol.setReadOnly.mockRejectedValue(new Error('Network error'));
1586
- _context35.next = 3;
1704
+ _context38.next = 3;
1587
1705
  return expect(instance.updateSharingMemberType('sharing-123', 1, 'one-way')).rejects.toThrow('Network error');
1588
1706
 
1589
1707
  case 3:
1590
1708
  case "end":
1591
- return _context35.stop();
1709
+ return _context38.stop();
1592
1710
  }
1593
- }, _callee35);
1711
+ }, _callee38);
1594
1712
  })));
1595
- it('should rethrow error if setReadWrite fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36() {
1596
- return _regeneratorRuntime.wrap(function _callee36$(_context36) {
1597
- while (1) switch (_context36.prev = _context36.next) {
1713
+ it('should rethrow error if setReadWrite fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39() {
1714
+ return _regeneratorRuntime.wrap(function _callee39$(_context39) {
1715
+ while (1) switch (_context39.prev = _context39.next) {
1598
1716
  case 0:
1599
1717
  instance.sharingCol.setReadWrite.mockRejectedValue(new Error('Network error'));
1600
- _context36.next = 3;
1718
+ _context39.next = 3;
1601
1719
  return expect(instance.updateSharingMemberType('sharing-123', 1, 'two-way')).rejects.toThrow('Network error');
1602
1720
 
1603
1721
  case 3:
1604
1722
  case "end":
1605
- return _context36.stop();
1723
+ return _context39.stop();
1606
1724
  }
1607
- }, _callee36);
1725
+ }, _callee39);
1608
1726
  })));
1609
- it('should rollback optimistic state update if API call fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee37() {
1610
- return _regeneratorRuntime.wrap(function _callee37$(_context37) {
1611
- while (1) switch (_context37.prev = _context37.next) {
1727
+ it('should rollback optimistic state update if API call fails', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40() {
1728
+ return _regeneratorRuntime.wrap(function _callee40$(_context40) {
1729
+ while (1) switch (_context40.prev = _context40.next) {
1612
1730
  case 0:
1613
1731
  instance.sharingCol.setReadOnly.mockRejectedValue(new Error('Network error'));
1614
- _context37.next = 3;
1732
+ _context40.next = 3;
1615
1733
  return expect(instance.updateSharingMemberType('sharing-123', 1, 'one-way')).rejects.toThrow('Network error');
1616
1734
 
1617
1735
  case 3:
@@ -1650,14 +1768,14 @@ describe('updateSharingMemberType', function () {
1650
1768
 
1651
1769
  case 7:
1652
1770
  case "end":
1653
- return _context37.stop();
1771
+ return _context40.stop();
1654
1772
  }
1655
- }, _callee37);
1773
+ }, _callee40);
1656
1774
  })));
1657
- it('should preserve realtime changes when rolling back an API failure', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39() {
1775
+ it('should preserve realtime changes when rolling back an API failure', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42() {
1658
1776
  var realtimeSharing;
1659
- return _regeneratorRuntime.wrap(function _callee39$(_context39) {
1660
- while (1) switch (_context39.prev = _context39.next) {
1777
+ return _regeneratorRuntime.wrap(function _callee42$(_context42) {
1778
+ while (1) switch (_context42.prev = _context42.next) {
1661
1779
  case 0:
1662
1780
  realtimeSharing = _objectSpread(_objectSpread({}, mockSharing), {}, {
1663
1781
  attributes: _objectSpread(_objectSpread({}, mockSharing.attributes), {}, {
@@ -1669,9 +1787,9 @@ describe('updateSharingMemberType', function () {
1669
1787
  })]
1670
1788
  })
1671
1789
  });
1672
- instance.sharingCol.setReadOnly.mockImplementation( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38() {
1673
- return _regeneratorRuntime.wrap(function _callee38$(_context38) {
1674
- while (1) switch (_context38.prev = _context38.next) {
1790
+ instance.sharingCol.setReadOnly.mockImplementation( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41() {
1791
+ return _regeneratorRuntime.wrap(function _callee41$(_context41) {
1792
+ while (1) switch (_context41.prev = _context41.next) {
1675
1793
  case 0:
1676
1794
  instance.state = _objectSpread(_objectSpread({}, instance.state), {}, {
1677
1795
  sharings: instance.state.sharings.map(function (sharing) {
@@ -1682,11 +1800,11 @@ describe('updateSharingMemberType', function () {
1682
1800
 
1683
1801
  case 2:
1684
1802
  case "end":
1685
- return _context38.stop();
1803
+ return _context41.stop();
1686
1804
  }
1687
- }, _callee38);
1805
+ }, _callee41);
1688
1806
  })));
1689
- _context39.next = 4;
1807
+ _context42.next = 4;
1690
1808
  return expect(instance.updateSharingMemberType('sharing-123', 1, 'one-way')).rejects.toThrow('Network error');
1691
1809
 
1692
1810
  case 4:
@@ -1715,15 +1833,15 @@ describe('updateSharingMemberType', function () {
1715
1833
 
1716
1834
  case 7:
1717
1835
  case "end":
1718
- return _context39.stop();
1836
+ return _context42.stop();
1719
1837
  }
1720
- }, _callee39);
1838
+ }, _callee42);
1721
1839
  })));
1722
- it('should refetch effective recipients of the given document through its drive', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40() {
1723
- return _regeneratorRuntime.wrap(function _callee40$(_context40) {
1724
- while (1) switch (_context40.prev = _context40.next) {
1840
+ it('should refetch effective recipients of the given document through its drive', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43() {
1841
+ return _regeneratorRuntime.wrap(function _callee43$(_context43) {
1842
+ while (1) switch (_context43.prev = _context43.next) {
1725
1843
  case 0:
1726
- _context40.next = 2;
1844
+ _context43.next = 2;
1727
1845
  return instance.updateSharingMemberType('sharing-123', 1, 'one-way', {
1728
1846
  _id: 'nested-folder',
1729
1847
  driveId: 'drive-sharing'
@@ -1736,15 +1854,15 @@ describe('updateSharingMemberType', function () {
1736
1854
 
1737
1855
  case 3:
1738
1856
  case "end":
1739
- return _context40.stop();
1857
+ return _context43.stop();
1740
1858
  }
1741
- }, _callee40);
1859
+ }, _callee43);
1742
1860
  })));
1743
- it('should refetch effective recipients of an owned document locally', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41() {
1744
- return _regeneratorRuntime.wrap(function _callee41$(_context41) {
1745
- while (1) switch (_context41.prev = _context41.next) {
1861
+ it('should refetch effective recipients of an owned document locally', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44() {
1862
+ return _regeneratorRuntime.wrap(function _callee44$(_context44) {
1863
+ while (1) switch (_context44.prev = _context44.next) {
1746
1864
  case 0:
1747
- _context41.next = 2;
1865
+ _context44.next = 2;
1748
1866
  return instance.updateSharingMemberType('sharing-123', 1, 'one-way', {
1749
1867
  _id: 'owned-folder'
1750
1868
  });
@@ -1756,13 +1874,13 @@ describe('updateSharingMemberType', function () {
1756
1874
 
1757
1875
  case 3:
1758
1876
  case "end":
1759
- return _context41.stop();
1877
+ return _context44.stop();
1760
1878
  }
1761
- }, _callee41);
1879
+ }, _callee44);
1762
1880
  })));
1763
- it('should not refetch effective recipients without a document', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42() {
1764
- return _regeneratorRuntime.wrap(function _callee42$(_context42) {
1765
- while (1) switch (_context42.prev = _context42.next) {
1881
+ it('should not refetch effective recipients without a document', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45() {
1882
+ return _regeneratorRuntime.wrap(function _callee45$(_context45) {
1883
+ while (1) switch (_context45.prev = _context45.next) {
1766
1884
  case 0:
1767
1885
  instance.state = _objectSpread(_objectSpread({}, instance.state), {}, {
1768
1886
  byDocId: {
@@ -1772,7 +1890,7 @@ describe('updateSharingMemberType', function () {
1772
1890
  }
1773
1891
  }
1774
1892
  });
1775
- _context42.next = 3;
1893
+ _context45.next = 3;
1776
1894
  return instance.updateSharingMemberType('sharing-123', 1, 'one-way');
1777
1895
 
1778
1896
  case 3:
@@ -1780,9 +1898,9 @@ describe('updateSharingMemberType', function () {
1780
1898
 
1781
1899
  case 4:
1782
1900
  case "end":
1783
- return _context42.stop();
1901
+ return _context45.stop();
1784
1902
  }
1785
- }, _callee42);
1903
+ }, _callee45);
1786
1904
  })));
1787
1905
  });
1788
1906
  describe('hasWriteAccess', function () {