passbolt-styleguide 5.14.2 → 5.14.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.
Files changed (90) hide show
  1. package/RELEASE_NOTES.md +6 -2
  2. package/build/css/help.min.css +2 -2
  3. package/build/css/public.min.css +2 -2
  4. package/build/css/themes/default/api_authentication.min.css +2 -2
  5. package/build/css/themes/default/api_cloud.min.css +2 -2
  6. package/build/css/themes/default/api_main.min.css +2 -2
  7. package/build/css/themes/default/api_reports.min.css +2 -2
  8. package/build/css/themes/default/api_webinstaller.min.css +2 -2
  9. package/build/css/themes/default/ext_app.min.css +3 -3
  10. package/build/css/themes/default/ext_authentication.min.css +2 -2
  11. package/build/css/themes/default/ext_external.min.css +2 -2
  12. package/build/css/themes/default/ext_in_form_cta.min.css +2 -2
  13. package/build/css/themes/default/ext_in_form_menu.min.css +2 -2
  14. package/build/css/themes/default/ext_quickaccess.min.css +2 -2
  15. package/build/css/themes/midgar/api_authentication.min.css +2 -2
  16. package/build/css/themes/midgar/api_main.min.css +2 -2
  17. package/build/css/themes/midgar/api_reports.min.css +2 -2
  18. package/build/css/themes/midgar/ext_app.min.css +3 -3
  19. package/build/css/themes/midgar/ext_authentication.min.css +2 -2
  20. package/build/css/themes/midgar/ext_in_form_cta.min.css +2 -2
  21. package/build/css/themes/midgar/ext_in_form_menu.min.css +2 -2
  22. package/build/css/themes/midgar/ext_quickaccess.min.css +2 -2
  23. package/build/css/themes/solarized_dark/api_authentication.min.css +2 -2
  24. package/build/css/themes/solarized_dark/api_main.min.css +2 -2
  25. package/build/css/themes/solarized_dark/api_reports.min.css +2 -2
  26. package/build/css/themes/solarized_dark/ext_app.min.css +3 -3
  27. package/build/css/themes/solarized_dark/ext_authentication.min.css +2 -2
  28. package/build/css/themes/solarized_dark/ext_in_form_cta.min.css +2 -2
  29. package/build/css/themes/solarized_dark/ext_in_form_menu.min.css +2 -2
  30. package/build/css/themes/solarized_dark/ext_quickaccess.min.css +2 -2
  31. package/build/css/themes/solarized_light/api_authentication.min.css +2 -2
  32. package/build/css/themes/solarized_light/api_main.min.css +2 -2
  33. package/build/css/themes/solarized_light/api_reports.min.css +2 -2
  34. package/build/css/themes/solarized_light/ext_app.min.css +3 -3
  35. package/build/css/themes/solarized_light/ext_authentication.min.css +2 -2
  36. package/build/css/themes/solarized_light/ext_in_form_cta.min.css +2 -2
  37. package/build/css/themes/solarized_light/ext_in_form_menu.min.css +2 -2
  38. package/build/css/themes/solarized_light/ext_quickaccess.min.css +2 -2
  39. package/build/js/dist/api-app.js +1 -1
  40. package/build/locales/cs-CZ/common.json +1 -1
  41. package/build/locales/de-DE/common.json +1 -1
  42. package/build/locales/en-UK/common.json +1 -1
  43. package/build/locales/es-ES/common.json +1 -1
  44. package/build/locales/fr-FR/common.json +1 -1
  45. package/build/locales/it-IT/common.json +1 -1
  46. package/build/locales/ja-JP/common.json +1 -1
  47. package/build/locales/ko-KR/common.json +1 -1
  48. package/build/locales/lt-LT/common.json +1 -1
  49. package/build/locales/nl-NL/common.json +1 -1
  50. package/build/locales/pl-PL/common.json +1 -1
  51. package/build/locales/pt-BR/common.json +1 -1
  52. package/build/locales/ro-RO/common.json +1 -1
  53. package/build/locales/ru-RU/common.json +1 -1
  54. package/build/locales/sl-SI/common.json +1 -1
  55. package/build/locales/sv-SE/common.json +1 -1
  56. package/build/locales/uk-UA/common.json +1 -1
  57. package/package.json +1 -1
  58. package/src/locales/cs-CZ/common.json +1 -1
  59. package/src/locales/de-DE/common.json +1 -1
  60. package/src/locales/en-UK/common.json +1 -1
  61. package/src/locales/es-ES/common.json +1 -1
  62. package/src/locales/fr-FR/common.json +1 -1
  63. package/src/locales/it-IT/common.json +1 -1
  64. package/src/locales/ja-JP/common.json +1 -1
  65. package/src/locales/ko-KR/common.json +1 -1
  66. package/src/locales/lt-LT/common.json +1 -1
  67. package/src/locales/nl-NL/common.json +1 -1
  68. package/src/locales/pl-PL/common.json +1 -1
  69. package/src/locales/pt-BR/common.json +1 -1
  70. package/src/locales/ro-RO/common.json +1 -1
  71. package/src/locales/ru-RU/common.json +1 -1
  72. package/src/locales/sl-SI/common.json +1 -1
  73. package/src/locales/sv-SE/common.json +1 -1
  74. package/src/locales/uk-UA/common.json +1 -1
  75. package/src/react-extension/components/Administration/DisplaySubscriptionKey/DisplaySubscriptionKey.js +6 -11
  76. package/src/react-extension/components/Administration/DisplaySubscriptionKey/DisplaySubscriptionKey.test.js +0 -28
  77. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/FolderShareFlow.js +7 -7
  78. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/FolderShareFlow.test.js +2 -2
  79. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceCreationFlow.js +5 -6
  80. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceEditFlow.js +13 -3
  81. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceShareFlow.js +4 -5
  82. package/src/react-extension/components/Share/GroupPermissionItem.js +12 -19
  83. package/src/react-extension/components/Share/GroupPermissionItem.test.data.js +0 -1
  84. package/src/react-extension/components/Share/GroupPermissionItem.test.js +6 -14
  85. package/src/react-extension/components/Share/GroupPermissionItem.test.stories.js +0 -4
  86. package/src/react-extension/components/Share/ShareDialog.js +166 -152
  87. package/src/react-extension/components/Share/ShareDialog.test.data.js +185 -0
  88. package/src/react-extension/components/Share/ShareDialog.test.js +94 -501
  89. package/src/react-extension/components/Share/ShareDialog.test.stories.js +0 -3
  90. package/src/react-extension/contexts/ExtAppContext.js +0 -6
@@ -18,25 +18,20 @@
18
18
  import ShareDialogPage from "./ShareDialog.test.page";
19
19
  import {
20
20
  addedGroupWithMembersFixture,
21
+ controlledModeProps,
21
22
  controlledModeWithGroupProps,
22
23
  defaultAppContext,
23
- defaultProps,
24
- mockResultsFolders,
25
- mockResultsResources,
26
- mockResultsResourcesAndFolders,
24
+ folderShareProps,
25
+ resourcesShareProps,
26
+ twoResourcesShareProps,
27
27
  } from "./ShareDialog.test.data";
28
- import { ActionFeedbackContext } from "../../contexts/ActionFeedbackContext";
29
28
  import PassboltApiFetchError from "../../../shared/lib/Error/PassboltApiFetchError";
30
- import { screen, waitFor } from "@testing-library/react";
29
+ import { waitFor } from "@testing-library/react";
31
30
  import NotifyError from "../Common/Error/NotifyError/NotifyError";
32
31
  import { waitForTrue } from "../../../../test/utils/waitFor";
33
- import UserAbortsOperationError from "../../lib/Error/UserAbortsOperationError";
34
32
  import { act } from "react";
35
- import PermissionsCollection from "../../../shared/models/entity/permission/permissionsCollection";
36
- import GroupsCollection from "../../../shared/models/entity/group/groupsCollection";
37
- import UsersCollection from "../../../shared/models/entity/user/usersCollection";
38
- import { defaultPermissionDto } from "../../../shared/models/entity/permission/permissionEntity.test.data";
39
33
  import { defaultUserDto } from "../../../shared/models/entity/user/userEntity.test.data";
34
+ import { defaultProfileDto } from "../../../shared/models/entity/profile/ProfileEntity.test.data";
40
35
  import { v4 as uuidv4 } from "uuid";
41
36
 
42
37
  beforeAll(() => {
@@ -54,155 +49,77 @@ describe("As Lu I should see the share dialog", () => {
54
49
 
55
50
  const mockContextRequest = (implementation) => jest.spyOn(context.port, "request").mockImplementation(implementation);
56
51
 
57
- describe("As LU I can start sharing resources", () => {
58
- const shareDialogProps = {
59
- resourcesIds: [
60
- "8e3874ae-4b40-590b-968a-418f704b9d9a",
61
- "daaf057e-7fc3-5537-a8a9-e8c151890878",
62
- "c8b93000-56b3-5a16-8048-c579d1babbd7",
63
- ],
52
+ /**
53
+ * Wire the port so the autocomplete search returns the given user (matched by keyword) and the
54
+ * fingerprint hover request resolves.
55
+ * @param {object} user The user DTO the search should return
56
+ */
57
+ function mockSearchReturns(user) {
58
+ const requestBextMockImpl = (request, option) => {
59
+ switch (request) {
60
+ case "passbolt.keyring.get-public-key-info-by-user":
61
+ return { fingerprint: "079D6F4FDA3BFDC2D8E562D8AA44B1DA4BFB36B6" };
62
+ case "passbolt.share.search-aros":
63
+ return [user].filter((candidate) => candidate.username.indexOf(option) !== -1);
64
+ }
64
65
  };
65
- /**
66
- * I should see the share dialog
67
- */
66
+ mockContextRequest(requestBextMockImpl);
67
+ }
68
+
69
+ describe("Sharing multiple resources", () => {
68
70
  beforeEach(async () => {
69
- const requestResourcesMockImpl = (path) => mockResultsResources[path];
70
- mockContextRequest(requestResourcesMockImpl);
71
- context.setContext({ shareDialogProps });
72
- props = defaultProps({ isPermissionConfirmationMode: false });
71
+ mockContextRequest(jest.fn());
72
+ props = resourcesShareProps(["apache", "cakephp", "nginx"]);
73
73
  await act(() => (page = new ShareDialogPage(context, props)));
74
74
  });
75
75
 
76
- it("As LU I see a success toaster message after sharing resources to users and groups with success", async () => {
77
- expect.assertions(18);
78
- expect(context.port.request).toHaveBeenCalledWith(
79
- "passbolt.resources.find-all-by-ids-for-display-permissions",
80
- shareDialogProps.resourcesIds,
81
- );
82
- expect(page.exists()).toBeTruthy();
76
+ it("As LU I see the dialog title and the recipients aggregated across the resources", () => {
77
+ expect.assertions(2);
83
78
  expect(page.title).toBe("Share 3 resources");
84
- expect(page.count).toBe(11);
85
-
86
- const requestBextMockImpl = (request, option) => {
87
- switch (request) {
88
- case "passbolt.keyring.get-public-key-info-by-user":
89
- return { fingerprint: "079D6F4FDA3BFDC2D8E562D8AA44B1DA4BFB36B6" };
90
- case "passbolt.share.search-aros":
91
- return context.users.filter((user) => user.username.indexOf(option) !== -1);
92
- }
93
- };
79
+ // Operator (owner) + reader, aggregated across the three resources.
80
+ expect(page.count).toBe(2);
81
+ });
94
82
 
95
- mockContextRequest(requestBextMockImpl);
96
- await page.searchName("adm");
83
+ it("As LU adding a recipient I see onConfirm called with the new permission deltas and the dialog closed", async () => {
84
+ expect.assertions(5);
85
+ const newUser = defaultUserDto({
86
+ username: "admin@passbolt.com",
87
+ profile: defaultProfileDto({ first_name: "Admin", last_name: "User" }),
88
+ });
89
+ mockSearchReturns(newUser);
90
+ await page.searchName("admin");
97
91
  await waitForTrue(() => Boolean(page.userOrGroupAutocomplete(1)));
98
92
  await page.selectUserOrGroup(1);
99
93
 
100
94
  expect(page.warningMessage).toBe("Click save to apply your pending changes.");
95
+ expect(page.count).toBe(3);
101
96
 
102
- expect(page.count).toBe(12);
103
- expect(page.aroName(1)).toBe("Ada Lovelace");
104
- expect(page.aroDetails(1)).toBe("ada@passbolt.com");
105
- expect(page.aroName(2)).toBe("Betty Holberton");
106
- expect(page.aroDetails(2)).toBe("betty@passbolt.com");
107
- expect(page.aroName(3)).toBe("Board");
108
- expect(page.aroDetails(3)).toBe("Group");
109
- expect(page.aroName(12)).toBe("Admin User");
110
- expect(page.aroDetails(12)).toBe("admin@passbolt.com");
111
- expect(page.selectRights(12).textContent).toBe("can read");
112
-
113
- const requestMockImpl = jest.fn();
114
- mockContextRequest(requestMockImpl);
115
- jest.spyOn(ActionFeedbackContext._currentValue, "displaySuccess").mockImplementation(() => {});
116
-
97
+ mockContextRequest(jest.fn());
117
98
  await page.savePermissions();
118
99
 
119
- const permissionDto = [
120
- {
121
- aco: "Resource",
122
- aco_foreign_key: shareDialogProps.resourcesIds[0],
123
- aro: "User",
124
- aro_foreign_key: "d57c10f5-639d-5160-9c81-8a0c6c4ec856",
125
- is_new: true,
126
- type: 1,
127
- },
128
- {
129
- aco: "Resource",
130
- aco_foreign_key: shareDialogProps.resourcesIds[1],
131
- aro: "User",
132
- aro_foreign_key: "d57c10f5-639d-5160-9c81-8a0c6c4ec856",
133
- is_new: true,
134
- type: 1,
135
- },
136
- {
137
- aco: "Resource",
138
- aco_foreign_key: "690b6e40-f371-579c-b0c6-86e8ef383adc",
139
- aro: "User",
140
- aro_foreign_key: "d57c10f5-639d-5160-9c81-8a0c6c4ec856",
141
- is_new: true,
142
- type: 1,
143
- },
144
- {
145
- aco: "Resource",
146
- aco_foreign_key: "ecf0ed85-3bfc-5f45-b11d-74e9a86aa313",
147
- aro: "User",
148
- aro_foreign_key: "d57c10f5-639d-5160-9c81-8a0c6c4ec856",
149
- is_new: true,
150
- type: 1,
151
- },
152
- ];
153
-
154
- expect(context.port.request).toHaveBeenCalledWith(
155
- "passbolt.share.resources.save",
156
- shareDialogProps.resourcesIds,
157
- permissionDto,
158
- );
159
- expect(ActionFeedbackContext._currentValue.displaySuccess).toHaveBeenCalledWith(
160
- "The permissions have been changed successfully.",
161
- );
100
+ expect(props.onConfirm).toHaveBeenCalledTimes(1);
101
+ const changes = props.onConfirm.mock.calls[0][0];
102
+ // One new read permission per shared resource.
103
+ expect(changes).toEqual([
104
+ expect.objectContaining({ is_new: true, aco: "Resource", aro: "User", aro_foreign_key: newUser.id, type: 1 }),
105
+ expect.objectContaining({ is_new: true, aco: "Resource", aro: "User", aro_foreign_key: newUser.id, type: 1 }),
106
+ expect.objectContaining({ is_new: true, aco: "Resource", aro: "User", aro_foreign_key: newUser.id, type: 1 }),
107
+ ]);
162
108
  expect(props.onClose).toHaveBeenCalled();
163
109
  });
164
110
 
165
111
  it("As LU I can remove a permission", async () => {
166
112
  expect.assertions(2);
167
- await waitForTrue(() => page.count !== 3);
168
- expect(page.count).toBe(11);
169
- await page.selectRemovePermission(1);
170
- expect(page.count).toBe(10);
171
- });
172
-
173
- it("As LU in legacy mode I should not see any group members toggle", async () => {
174
- expect.assertions(2);
175
- await waitForTrue(() => page.count !== 3);
176
- // The fixture contains group permissions, but the members toggle is a controlled-mode feature.
177
- expect(page.count).toBe(11);
178
- expect(page.groupToggleCount).toBe(0);
113
+ expect(page.count).toBe(2);
114
+ await page.selectRemovePermission(2);
115
+ expect(page.count).toBe(1);
179
116
  });
180
117
 
181
118
  it("As LU I should see a processing feedback while submitting the form", async () => {
182
- const requestBextMockImpl = (request, option) => {
183
- switch (request) {
184
- case "passbolt.share.search-aros":
185
- return context.users.filter((user) => user.username.indexOf(option) !== -1);
186
- }
187
- };
188
- mockContextRequest(requestBextMockImpl);
189
- await page.searchName("adm");
190
- await waitForTrue(() => Boolean(page.userOrGroupAutocomplete(1)));
191
- await page.selectUserOrGroup(1);
192
-
193
- // Mock the request function to make it the expected result
194
- let updateResolve;
195
- const requestMockImpl = jest.fn(
196
- () =>
197
- new Promise((resolve) => {
198
- updateResolve = resolve;
199
- }),
200
- );
201
-
202
- // Mock the request function to make it the expected result
203
- mockContextRequest(requestMockImpl);
119
+ let resolveConfirm;
120
+ props.onConfirm.mockImplementation(() => new Promise((resolve) => (resolveConfirm = resolve)));
204
121
  await page.savePermissionsWithoutWait();
205
- // API calls are made on submit, wait they are resolved.
122
+ // onConfirm is pending, the dialog is in its processing state: every input is disabled.
206
123
  await waitFor(() => {
207
124
  expect(page.shareNameInput.getAttribute("disabled")).not.toBeNull();
208
125
  expect(page.selectRights(1).className).toBe("selected-value disabled");
@@ -211,12 +128,13 @@ describe("As Lu I should see the share dialog", () => {
211
128
  expect(page.cancelButton.hasAttribute("disabled")).toBeTruthy();
212
129
  expect(page.saveButton.hasAttribute("disabled")).toBeTruthy();
213
130
  expect(page.saveButton.className).toBe("button primary form disabled processing");
214
- updateResolve();
131
+ resolveConfirm();
215
132
  });
216
133
  });
217
134
 
218
135
  it("As LU I shouldn’t be able to submit the form if there is no owner", async () => {
219
136
  expect.assertions(2);
137
+ // Demote the sole owner (row 1, Ada) to read: no resource keeps an owner anymore.
220
138
  await page.selectFirstItemRights(1);
221
139
  expect(page.errorMessage).toBe("Please make sure there is at least one owner.");
222
140
  expect(page.saveButton.getAttribute("disabled")).not.toBeNull();
@@ -243,276 +161,66 @@ describe("As Lu I should see the share dialog", () => {
243
161
  expect(props.onClose).toHaveBeenCalled();
244
162
  });
245
163
 
246
- it("displays an error dialog if the resource details cannot be loaded due to an unexpected error", async () => {
247
- expect.assertions(2);
248
- const error = new Error("Unexpected error");
249
- const requestBextMockImpl = (request) => {
250
- switch (request) {
251
- case "passbolt.resources.find-all-by-ids-for-display-permissions":
252
- throw error;
253
- }
254
- };
255
- mockContextRequest(requestBextMockImpl);
256
- page = new ShareDialogPage(context, props);
257
-
258
- // Throw general error message
259
- expect(props.onClose).toHaveBeenCalled();
260
- expect(props.dialogContext.open).toHaveBeenCalledWith(NotifyError, { error: error });
261
- });
262
-
263
- it("closes the share dialogs if the resource details cannot be loaded due to users not entering their passphrase when requested. This happens when the metadata need to be decrypted.", async () => {
264
- expect.assertions(2);
265
- const error = new UserAbortsOperationError();
266
- const requestBextMockImpl = (request) => {
267
- switch (request) {
268
- case "passbolt.resources.find-all-by-ids-for-display-permissions":
269
- throw error;
270
- }
271
- };
272
- mockContextRequest(requestBextMockImpl);
273
- page = new ShareDialogPage(context, props);
274
-
275
- // Throw general error message
276
- expect(props.onClose).toHaveBeenCalled();
277
- expect(props.dialogContext.open).not.toHaveBeenCalled();
278
- });
279
-
280
- it("As LU I should see an error dialog if the submit operation fails for an unexpected reason", async () => {
164
+ it("As LU I should see an error dialog if the confirm operation fails for an unexpected reason", async () => {
281
165
  expect.assertions(1);
282
- const requestBextMockImpl = (request, option) => {
283
- switch (request) {
284
- case "passbolt.share.search-aros":
285
- return context.users.filter((user) => user.username.indexOf(option) !== -1);
286
- }
287
- };
288
- mockContextRequest(requestBextMockImpl);
289
- await page.searchName("adm");
290
- await waitForTrue(() => Boolean(page.userOrGroupAutocomplete(1)));
291
- await page.selectUserOrGroup(1);
292
-
293
- // Mock the request function to make it return an error.
294
166
  const error = new PassboltApiFetchError("Jest simulate API error.");
295
- jest.spyOn(context.port, "request").mockImplementationOnce(() => {
167
+ props.onConfirm.mockImplementation(() => {
296
168
  throw error;
297
169
  });
298
170
 
299
171
  await page.savePermissions();
300
172
 
301
- // Throw general error message
302
173
  expect(props.dialogContext.open).toHaveBeenCalledWith(NotifyError, { error: error });
303
174
  });
304
175
  });
305
176
 
306
- describe("As LU I can start sharing one resources", () => {
307
- const shareDialogProps = {
308
- resourcesIds: ["8e3874ae-4b40-590b-968a-418f704b9d9a"],
309
- };
310
- /**
311
- * I should see the share dialog
312
- */
313
- beforeEach(async () => {
314
- const requestResourcesMockImpl = (path) => mockResultsResources[path];
315
- mockContextRequest(requestResourcesMockImpl);
316
- context.setContext({ shareDialogProps });
317
- props = defaultProps({ isPermissionConfirmationMode: false });
177
+ describe("Sharing a single resource", () => {
178
+ it("As LU I see the single-resource title and subtitle and confirm the permission deltas", async () => {
179
+ expect.assertions(4);
180
+ props = resourcesShareProps(["apache"]);
181
+ mockContextRequest(jest.fn());
318
182
  await act(() => (page = new ShareDialogPage(context, props)));
319
- });
320
183
 
321
- it("As LU I see a success toaster message after sharing one resource to users and groups with success", async () => {
322
- expect.assertions(12);
323
- expect(context.port.request).toHaveBeenCalledWith(
324
- "passbolt.resources.find-all-by-ids-for-display-permissions",
325
- shareDialogProps.resourcesIds,
326
- );
327
- expect(page.exists()).toBeTruthy();
328
184
  expect(page.title).toBe("Share resource");
329
185
  expect(page.subtitle).toBe("apache");
330
- expect(page.count).toBe(11);
331
186
 
332
- const requestBextMockImpl = (request, option) => {
333
- switch (request) {
334
- case "passbolt.share.search-aros":
335
- return context.users.filter((user) => user.username.indexOf(option) !== -1);
336
- }
337
- };
338
- mockContextRequest(requestBextMockImpl);
339
- await page.searchName("adm");
187
+ const newUser = defaultUserDto({ username: "admin@passbolt.com" });
188
+ mockSearchReturns(newUser);
189
+ await page.searchName("admin");
340
190
  await waitForTrue(() => Boolean(page.userOrGroupAutocomplete(1)));
341
191
  await page.selectUserOrGroup(1);
342
192
 
343
- expect(page.count).toBe(12);
344
- expect(page.aroName(12)).toBe("Admin User");
345
- expect(page.aroDetails(12)).toBe("admin@passbolt.com");
346
- expect(page.selectRights(12).textContent).toBe("can read");
347
-
348
- const requestMockImpl = jest.fn();
349
- mockContextRequest(requestMockImpl);
350
- jest.spyOn(ActionFeedbackContext._currentValue, "displaySuccess").mockImplementation(() => {});
351
-
193
+ mockContextRequest(jest.fn());
352
194
  await page.savePermissions();
353
195
 
354
- const permissionDto = [
355
- {
356
- aco: "Resource",
357
- aco_foreign_key: shareDialogProps.resourcesIds[0],
358
- aro: "User",
359
- aro_foreign_key: "d57c10f5-639d-5160-9c81-8a0c6c4ec856",
360
- is_new: true,
361
- type: 1,
362
- },
363
- {
364
- aco: "Resource",
365
- aco_foreign_key: "daaf057e-7fc3-5537-a8a9-e8c151890878",
366
- aro: "User",
367
- aro_foreign_key: "d57c10f5-639d-5160-9c81-8a0c6c4ec856",
368
- is_new: true,
369
- type: 1,
370
- },
371
- {
372
- aco: "Resource",
373
- aco_foreign_key: "690b6e40-f371-579c-b0c6-86e8ef383adc",
374
- aro: "User",
375
- aro_foreign_key: "d57c10f5-639d-5160-9c81-8a0c6c4ec856",
376
- is_new: true,
377
- type: 1,
378
- },
379
- {
380
- aco: "Resource",
381
- aco_foreign_key: "ecf0ed85-3bfc-5f45-b11d-74e9a86aa313",
382
- aro: "User",
383
- aro_foreign_key: "d57c10f5-639d-5160-9c81-8a0c6c4ec856",
384
- is_new: true,
385
- type: 1,
386
- },
387
- ];
388
-
389
- expect(context.port.request).toHaveBeenCalledWith(
390
- "passbolt.share.resources.save",
391
- shareDialogProps.resourcesIds,
392
- permissionDto,
393
- );
394
- expect(ActionFeedbackContext._currentValue.displaySuccess).toHaveBeenCalledWith(
395
- "The permissions have been changed successfully.",
396
- );
397
- expect(props.onClose).toHaveBeenCalled();
196
+ const changes = props.onConfirm.mock.calls[0][0];
197
+ expect(changes).toHaveLength(1);
198
+ expect(changes[0]).toMatchObject({ is_new: true, aco: "Resource", aro_foreign_key: newUser.id, type: 1 });
398
199
  });
399
200
  });
400
201
 
401
- describe("As LU I can start sharing one folder", () => {
402
- const shareDialogProps = {
403
- foldersIds: ["8e3874ae-4b40-590b-968a-418f704b9d9a"],
404
- };
405
- /**
406
- * I should see the share dialog
407
- */
408
- beforeEach(async () => {
409
- const requestResourcesMockImpl = (path) => mockResultsFolders[path];
410
- mockContextRequest(requestResourcesMockImpl);
411
- context.setContext({ shareDialogProps });
412
- props = defaultProps({ isPermissionConfirmationMode: false });
202
+ describe("Sharing a single folder", () => {
203
+ it("As LU I see the folder title and subtitle and confirm the folder deltas", async () => {
204
+ expect.assertions(4);
205
+ props = folderShareProps("apache");
206
+ mockContextRequest(jest.fn());
413
207
  await act(() => (page = new ShareDialogPage(context, props)));
414
- });
415
208
 
416
- it("As LU I see a success toaster message after sharing one folder to users and groups with success", async () => {
417
- expect.assertions(12);
418
- expect(context.port.request).toHaveBeenCalledWith("passbolt.share.get-folders", shareDialogProps.foldersIds);
419
- expect(page.exists()).toBeTruthy();
420
- // Wait until the text is found (This will ensure the state has been updated)
421
- await screen.findByText("Share folder");
422
209
  expect(page.title).toBe("Share folder");
423
210
  expect(page.subtitle).toBe("apache");
424
- expect(page.count).toBe(2);
425
-
426
- const requestKeyInfoMockImpl = () => ({
427
- fingerprint: "079D6F4FDA3BFDC2D8E562D8AA44B1DA4BFB36B6",
428
- });
429
- mockContextRequest(requestKeyInfoMockImpl);
430
211
 
431
- const requestBextMockImpl = (request, option) => {
432
- switch (request) {
433
- case "passbolt.keyring.get-public-key-info-by-user":
434
- return { fingerprint: "079D6F4FDA3BFDC2D8E562D8AA44B1DA4BFB36B6" };
435
- case "passbolt.share.search-aros":
436
- return context.users.filter((user) => user.username.indexOf(option) !== -1);
437
- }
438
- };
439
- mockContextRequest(requestBextMockImpl);
440
-
441
- await page.searchName("ad");
442
- await waitForTrue(() => Boolean(page.userOrGroupAutocomplete(1)));
443
- await page.selectUserOrGroup(2);
444
-
445
- expect(page.count).toBe(3);
446
- expect(page.aroName(3)).toBe("Adele Goldstine");
447
- expect(page.aroDetails(3)).toBe("adele@passbolt.com");
448
- expect(page.selectRights(3).textContent).toBe("can read");
449
-
450
- const requestMockImpl = jest.fn();
451
- mockContextRequest(requestMockImpl);
452
- jest.spyOn(ActionFeedbackContext._currentValue, "displaySuccess").mockImplementation(() => {});
453
-
454
- await page.savePermissions();
455
-
456
- const permissionDto = [
457
- {
458
- aco: "Folder",
459
- aco_foreign_key: shareDialogProps.foldersIds[0],
460
- aro: "User",
461
- aro_foreign_key: "af5e1f70-a0ee-5b76-935b-c846f8a6a190",
462
- is_new: true,
463
- type: 1,
464
- },
465
- ];
466
-
467
- expect(context.port.request).toHaveBeenCalledWith(
468
- "passbolt.share.folders.save",
469
- shareDialogProps.foldersIds[0],
470
- permissionDto,
471
- );
472
- expect(ActionFeedbackContext._currentValue.displaySuccess).toHaveBeenCalledWith(
473
- "The permissions have been changed successfully.",
474
- );
475
- expect(props.onClose).toHaveBeenCalled();
476
- });
477
- });
478
-
479
- //@todo: skipped as not supported for the moment. We can share only 1 folder at a time or multiple resources but not multiple folders or folders and resources at the same time
480
- describe.skip("As LU I can't start sharing folders and resources at the same time", () => {
481
- const shareDialogProps = {
482
- resourcesIds: ["8e3874ae-4b40-590b-968a-418f704b9d9a"],
483
- foldersIds: ["8e3874ae-4b40-590b-968a-418f704b9d9a"],
484
- };
485
- /**
486
- * I should see the share dialog
487
- */
488
- beforeEach(async () => {
489
- const requestResourcesMockImpl = (path) => mockResultsResourcesAndFolders[path];
490
- mockContextRequest(requestResourcesMockImpl);
491
- context.setContext({ shareDialogProps });
492
- page = new ShareDialogPage(context, props);
493
- });
494
-
495
- it("As LU I see a error dialog message after try to sharing folders and resources at the same time", async () => {
496
- expect.assertions(3);
497
- expect(page.exists()).toBeTruthy();
498
- expect(page.title).toBe("Share 2 items");
499
-
500
- const requestBextMockImpl = (request, option) => {
501
- switch (request) {
502
- case "passbolt.share.search-aros":
503
- return context.users.filter((user) => user.username.indexOf(option) !== -1);
504
- }
505
- };
506
- mockContextRequest(requestBextMockImpl);
507
- await page.searchName("adm");
212
+ const newUser = defaultUserDto({ username: "adele@passbolt.com" });
213
+ mockSearchReturns(newUser);
214
+ await page.searchName("adele");
508
215
  await waitForTrue(() => Boolean(page.userOrGroupAutocomplete(1)));
509
216
  await page.selectUserOrGroup(1);
510
217
 
218
+ mockContextRequest(jest.fn());
511
219
  await page.savePermissions();
512
- // Throw general error message
513
- expect(props.dialogContext.open).toHaveBeenCalledWith(NotifyError, {
514
- error: new Error("Multi resource and folder share is not implemented."),
515
- });
220
+
221
+ const changes = props.onConfirm.mock.calls[0][0];
222
+ expect(changes).toHaveLength(1);
223
+ expect(changes[0]).toMatchObject({ is_new: true, aco: "Folder", aro_foreign_key: newUser.id, type: 1 });
516
224
  });
517
225
  });
518
226
  });
@@ -522,56 +230,9 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
522
230
  const context = defaultAppContext();
523
231
  const mockContextRequest = (implementation) => jest.spyOn(context.port, "request").mockImplementation(implementation);
524
232
 
525
- /**
526
- * Build a self-consistent triplet of {permissions, groups, users} simulating a snapshot captured
527
- * from a shared parent folder. The operator is the logged-in user (so the controlled-mode submit
528
- * logic exercises its operator-skip path); a second user has read access.
529
- */
530
- function buildControlledModeProps(data = {}) {
531
- // Local defaultAppContext for these tests doesn't seed `loggedInUser`; set it to the snapshot's
532
- // owner so the controlled-mode submit logic exercises its operator-skip path.
533
- const operatorId = context.userSettings.id;
534
- context.loggedInUser = { id: operatorId };
535
- const operatorUser = defaultUserDto({ id: operatorId, username: "operator@passbolt.com" });
536
- const readerId = uuidv4();
537
- const readerUser = defaultUserDto({ id: readerId, username: "reader@passbolt.com" });
538
- const folderId = uuidv4();
539
- const permissionsDto = [
540
- defaultPermissionDto({
541
- aco: "Folder",
542
- aco_foreign_key: folderId,
543
- aro: "User",
544
- aro_foreign_key: operatorId,
545
- type: 15,
546
- }),
547
- defaultPermissionDto({
548
- aco: "Folder",
549
- aco_foreign_key: folderId,
550
- aro: "User",
551
- aro_foreign_key: readerId,
552
- type: 1,
553
- }),
554
- ];
555
- return {
556
- ...defaultProps(),
557
- initialResources: [
558
- {
559
- id: null,
560
- metadata: { name: "" },
561
- permission: { type: 15 },
562
- permissions: new PermissionsCollection(permissionsDto, { assertAtLeastOneOwner: false }),
563
- },
564
- ],
565
- initialGroups: new GroupsCollection([]),
566
- initialUsers: new UsersCollection([operatorUser, readerUser]),
567
- onConfirm: jest.fn(),
568
- ...data,
569
- };
570
- }
571
-
572
233
  it("As LU I should not see the dialog fetch resource permissions when controlled-mode props are provided", async () => {
573
234
  expect.assertions(2);
574
- const props = buildControlledModeProps();
235
+ const props = controlledModeProps();
575
236
  mockContextRequest(jest.fn());
576
237
 
577
238
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -585,7 +246,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
585
246
 
586
247
  it("As LU I should see the snapshot's permissions rendered in the order they were captured", async () => {
587
248
  expect.assertions(2);
588
- const props = buildControlledModeProps();
249
+ const props = controlledModeProps();
589
250
  mockContextRequest(jest.fn());
590
251
 
591
252
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -597,7 +258,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
597
258
 
598
259
  it("As LU I should see the Save button enabled as soon as the dialog opens so I can confirm the snapshot as-is", async () => {
599
260
  expect.assertions(1);
600
- const props = buildControlledModeProps();
261
+ const props = controlledModeProps();
601
262
  mockContextRequest(jest.fn());
602
263
 
603
264
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -607,7 +268,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
607
268
 
608
269
  it("As LU confirming the dialog as-is I should see onConfirm called with an empty delta (backend already inherits parent perms)", async () => {
609
270
  expect.assertions(3);
610
- const props = buildControlledModeProps();
271
+ const props = controlledModeProps();
611
272
  mockContextRequest(jest.fn());
612
273
 
613
274
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -627,7 +288,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
627
288
 
628
289
  it("As LU removing a row before confirming I should see a delete delta emitted for that row", async () => {
629
290
  expect.assertions(3);
630
- const props = buildControlledModeProps();
291
+ const props = controlledModeProps();
631
292
  mockContextRequest(jest.fn());
632
293
 
633
294
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -646,7 +307,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
646
307
  expect.assertions(2);
647
308
  // Folder mode: the seeded entry is the folder itself; its edits must be emitted as Folder deltas
648
309
  // so the workflow saves them via the folder-share path.
649
- const props = { ...buildControlledModeProps(), acoType: "Folder" };
310
+ const props = controlledModeProps({ acoType: "Folder" });
650
311
  mockContextRequest(jest.fn());
651
312
 
652
313
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -664,7 +325,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
664
325
  // (ShareChanges tags new permissions from the ACO bucket type). The folder-share save then
665
326
  // received an empty delta and silently did nothing. The seeded folder must live in the folder
666
327
  // bucket so additions are emitted as Folder deltas.
667
- const props = { ...buildControlledModeProps(), acoType: "Folder" };
328
+ const props = controlledModeProps({ acoType: "Folder" });
668
329
  const newUserId = uuidv4();
669
330
  const newUser = defaultUserDto({ id: newUserId, username: "newcomer@passbolt.com" });
670
331
  mockContextRequest((request) => {
@@ -688,55 +349,9 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
688
349
  });
689
350
 
690
351
  describe("Seeded with initialResources (share)", () => {
691
- /**
692
- * Build controlled-mode props seeded with two resources (share mode). The operator owns both;
693
- * a reader has read access to both. Each resource carries its own single-ACO permission set.
694
- */
695
- function buildInitialResourcesProps() {
696
- const operatorId = context.userSettings.id;
697
- context.loggedInUser = { id: operatorId };
698
- const operatorUser = defaultUserDto({ id: operatorId, username: "operator@passbolt.com" });
699
- const readerId = uuidv4();
700
- const readerUser = defaultUserDto({ id: readerId, username: "reader@passbolt.com" });
701
- const buildResource = (name) => {
702
- const resourceId = uuidv4();
703
- return {
704
- id: resourceId,
705
- metadata: { name },
706
- permission: { type: 15 },
707
- permissions: new PermissionsCollection(
708
- [
709
- defaultPermissionDto({
710
- aco: "Resource",
711
- aco_foreign_key: resourceId,
712
- aro: "User",
713
- aro_foreign_key: operatorId,
714
- type: 15,
715
- }),
716
- defaultPermissionDto({
717
- aco: "Resource",
718
- aco_foreign_key: resourceId,
719
- aro: "User",
720
- aro_foreign_key: readerId,
721
- type: 1,
722
- }),
723
- ],
724
- { assertAtLeastOneOwner: false },
725
- ),
726
- };
727
- };
728
- return {
729
- ...defaultProps(),
730
- initialResources: [buildResource("RA"), buildResource("RB")],
731
- initialGroups: new GroupsCollection([]),
732
- initialUsers: new UsersCollection([operatorUser, readerUser]),
733
- onConfirm: jest.fn(),
734
- };
735
- }
736
-
737
352
  it("As LU I should see the recipients aggregated across the resources without fetching from the API", async () => {
738
353
  expect.assertions(2);
739
- const props = buildInitialResourcesProps();
354
+ const props = twoResourcesShareProps();
740
355
  mockContextRequest(jest.fn());
741
356
 
742
357
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -751,7 +366,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
751
366
 
752
367
  it("As LU sharing several resources I should see their names listed in the title tooltip", async () => {
753
368
  expect.assertions(1);
754
- const props = buildInitialResourcesProps();
369
+ const props = twoResourcesShareProps();
755
370
  mockContextRequest(jest.fn());
756
371
 
757
372
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -765,7 +380,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
765
380
  describe("Read-only mode", () => {
766
381
  it("As LU with update-but-not-owner access I should not see the autocomplete to add people or groups", async () => {
767
382
  expect.assertions(2);
768
- const props = { ...buildControlledModeProps(), readOnly: true };
383
+ const props = { ...controlledModeProps(), readOnly: true };
769
384
  mockContextRequest(jest.fn());
770
385
 
771
386
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -777,7 +392,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
777
392
 
778
393
  it("As LU in read-only mode I should still be able to confirm the set as-is (empty delta)", async () => {
779
394
  expect.assertions(3);
780
- const props = { ...buildControlledModeProps(), readOnly: true };
395
+ const props = { ...controlledModeProps(), readOnly: true };
781
396
  mockContextRequest(jest.fn());
782
397
 
783
398
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -790,28 +405,6 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
790
405
  });
791
406
  });
792
407
 
793
- it("As LU I should open the dialog without crashing even when a stale single-folder share selection lingers in the context", async () => {
794
- // Regression: controlled mode never populates `this.folders`, but a leftover
795
- // `shareDialogProps.foldersIds` of length 1 from a previous folder share used to make
796
- // `getSubtitle()` dereference the empty `this.folders[0]` and throw. The controlled-mode guard
797
- // skips the subtitle entirely.
798
- expect.assertions(2);
799
- const props = buildControlledModeProps();
800
- props.isPermissionConfirmationMode = false;
801
- const previousShareDialogProps = context.shareDialogProps;
802
- context.shareDialogProps = { foldersIds: [uuidv4()] };
803
- mockContextRequest(jest.fn());
804
-
805
- try {
806
- await act(() => (page = new ShareDialogPage(context, props)));
807
-
808
- expect(page.title).toBe("Share");
809
- expect(page.count).toBe(2);
810
- } finally {
811
- context.shareDialogProps = previousShareDialogProps;
812
- }
813
- });
814
-
815
408
  describe("Group members expansion", () => {
816
409
  // Permissions are sorted by aro name: user "Ada Lovelace" (row 1), group "Developer" (row 2).
817
410
  it("As LU I should see a members toggle on group rows but not on user rows", async () => {