passbolt-styleguide 5.14.2 → 5.14.5

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 (101) 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 +6 -9
  79. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceCreationFlow.js +17 -24
  80. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceCreationFlow.test.js +15 -17
  81. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceEditFlow.js +23 -17
  82. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceEditFlow.test.js +18 -31
  83. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceShareFlow.js +4 -5
  84. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceShareFlow.test.js +14 -22
  85. package/src/react-extension/components/Share/GroupPermissionItem.js +12 -19
  86. package/src/react-extension/components/Share/GroupPermissionItem.test.data.js +0 -1
  87. package/src/react-extension/components/Share/GroupPermissionItem.test.js +6 -14
  88. package/src/react-extension/components/Share/GroupPermissionItem.test.stories.js +0 -4
  89. package/src/react-extension/components/Share/ShareDialog.js +176 -159
  90. package/src/react-extension/components/Share/ShareDialog.test.data.js +241 -8
  91. package/src/react-extension/components/Share/ShareDialog.test.js +108 -505
  92. package/src/react-extension/components/Share/ShareDialog.test.stories.js +0 -3
  93. package/src/react-extension/contexts/ExtAppContext.js +0 -6
  94. package/src/react-extension/contexts/WorkflowContext.js +4 -0
  95. package/src/shared/models/entity/groupUser/groupUserEntity.js +52 -6
  96. package/src/shared/models/entity/groupUser/groupUserEntity.test.data.js +5 -0
  97. package/src/shared/models/entity/groupUser/groupUserEntity.test.js +54 -0
  98. package/src/shared/services/permission/permissionSnapshotService.js +20 -20
  99. package/src/shared/services/permission/permissionSnapshotService.test.js +77 -53
  100. package/src/shared/services/serviceWorker/group/groupServiceWorkerService.js +6 -18
  101. package/src/shared/services/serviceWorker/group/groupServiceWorkerService.test.js +13 -27
@@ -18,25 +18,21 @@
18
18
  import ShareDialogPage from "./ShareDialog.test.page";
19
19
  import {
20
20
  addedGroupWithMembersFixture,
21
+ controlledModeEmbeddedUsersProps,
22
+ controlledModeProps,
21
23
  controlledModeWithGroupProps,
22
24
  defaultAppContext,
23
- defaultProps,
24
- mockResultsFolders,
25
- mockResultsResources,
26
- mockResultsResourcesAndFolders,
25
+ folderShareProps,
26
+ resourcesShareProps,
27
+ twoResourcesShareProps,
27
28
  } from "./ShareDialog.test.data";
28
- import { ActionFeedbackContext } from "../../contexts/ActionFeedbackContext";
29
29
  import PassboltApiFetchError from "../../../shared/lib/Error/PassboltApiFetchError";
30
- import { screen, waitFor } from "@testing-library/react";
30
+ import { waitFor } from "@testing-library/react";
31
31
  import NotifyError from "../Common/Error/NotifyError/NotifyError";
32
32
  import { waitForTrue } from "../../../../test/utils/waitFor";
33
- import UserAbortsOperationError from "../../lib/Error/UserAbortsOperationError";
34
33
  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
34
  import { defaultUserDto } from "../../../shared/models/entity/user/userEntity.test.data";
35
+ import { defaultProfileDto } from "../../../shared/models/entity/profile/ProfileEntity.test.data";
40
36
  import { v4 as uuidv4 } from "uuid";
41
37
 
42
38
  beforeAll(() => {
@@ -54,155 +50,77 @@ describe("As Lu I should see the share dialog", () => {
54
50
 
55
51
  const mockContextRequest = (implementation) => jest.spyOn(context.port, "request").mockImplementation(implementation);
56
52
 
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
- ],
53
+ /**
54
+ * Wire the port so the autocomplete search returns the given user (matched by keyword) and the
55
+ * fingerprint hover request resolves.
56
+ * @param {object} user The user DTO the search should return
57
+ */
58
+ function mockSearchReturns(user) {
59
+ const requestBextMockImpl = (request, option) => {
60
+ switch (request) {
61
+ case "passbolt.keyring.get-public-key-info-by-user":
62
+ return { fingerprint: "079D6F4FDA3BFDC2D8E562D8AA44B1DA4BFB36B6" };
63
+ case "passbolt.share.search-aros":
64
+ return [user].filter((candidate) => candidate.username.indexOf(option) !== -1);
65
+ }
64
66
  };
65
- /**
66
- * I should see the share dialog
67
- */
67
+ mockContextRequest(requestBextMockImpl);
68
+ }
69
+
70
+ describe("Sharing multiple resources", () => {
68
71
  beforeEach(async () => {
69
- const requestResourcesMockImpl = (path) => mockResultsResources[path];
70
- mockContextRequest(requestResourcesMockImpl);
71
- context.setContext({ shareDialogProps });
72
- props = defaultProps({ isPermissionConfirmationMode: false });
72
+ mockContextRequest(jest.fn());
73
+ props = resourcesShareProps(["apache", "cakephp", "nginx"]);
73
74
  await act(() => (page = new ShareDialogPage(context, props)));
74
75
  });
75
76
 
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();
77
+ it("As LU I see the dialog title and the recipients aggregated across the resources", () => {
78
+ expect.assertions(2);
83
79
  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
- };
80
+ // Operator (owner) + reader, aggregated across the three resources.
81
+ expect(page.count).toBe(2);
82
+ });
94
83
 
95
- mockContextRequest(requestBextMockImpl);
96
- await page.searchName("adm");
84
+ it("As LU adding a recipient I see onConfirm called with the new permission deltas and the dialog closed", async () => {
85
+ expect.assertions(5);
86
+ const newUser = defaultUserDto({
87
+ username: "admin@passbolt.com",
88
+ profile: defaultProfileDto({ first_name: "Admin", last_name: "User" }),
89
+ });
90
+ mockSearchReturns(newUser);
91
+ await page.searchName("admin");
97
92
  await waitForTrue(() => Boolean(page.userOrGroupAutocomplete(1)));
98
93
  await page.selectUserOrGroup(1);
99
94
 
100
95
  expect(page.warningMessage).toBe("Click save to apply your pending changes.");
96
+ expect(page.count).toBe(3);
101
97
 
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
-
98
+ mockContextRequest(jest.fn());
117
99
  await page.savePermissions();
118
100
 
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
- );
101
+ expect(props.onConfirm).toHaveBeenCalledTimes(1);
102
+ const changes = props.onConfirm.mock.calls[0][0];
103
+ // One new read permission per shared resource.
104
+ expect(changes).toEqual([
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
+ expect.objectContaining({ is_new: true, aco: "Resource", aro: "User", aro_foreign_key: newUser.id, type: 1 }),
108
+ ]);
162
109
  expect(props.onClose).toHaveBeenCalled();
163
110
  });
164
111
 
165
112
  it("As LU I can remove a permission", async () => {
166
113
  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);
114
+ expect(page.count).toBe(2);
115
+ await page.selectRemovePermission(2);
116
+ expect(page.count).toBe(1);
179
117
  });
180
118
 
181
119
  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);
120
+ let resolveConfirm;
121
+ props.onConfirm.mockImplementation(() => new Promise((resolve) => (resolveConfirm = resolve)));
204
122
  await page.savePermissionsWithoutWait();
205
- // API calls are made on submit, wait they are resolved.
123
+ // onConfirm is pending, the dialog is in its processing state: every input is disabled.
206
124
  await waitFor(() => {
207
125
  expect(page.shareNameInput.getAttribute("disabled")).not.toBeNull();
208
126
  expect(page.selectRights(1).className).toBe("selected-value disabled");
@@ -211,12 +129,13 @@ describe("As Lu I should see the share dialog", () => {
211
129
  expect(page.cancelButton.hasAttribute("disabled")).toBeTruthy();
212
130
  expect(page.saveButton.hasAttribute("disabled")).toBeTruthy();
213
131
  expect(page.saveButton.className).toBe("button primary form disabled processing");
214
- updateResolve();
132
+ resolveConfirm();
215
133
  });
216
134
  });
217
135
 
218
136
  it("As LU I shouldn’t be able to submit the form if there is no owner", async () => {
219
137
  expect.assertions(2);
138
+ // Demote the sole owner (row 1, Ada) to read: no resource keeps an owner anymore.
220
139
  await page.selectFirstItemRights(1);
221
140
  expect(page.errorMessage).toBe("Please make sure there is at least one owner.");
222
141
  expect(page.saveButton.getAttribute("disabled")).not.toBeNull();
@@ -243,276 +162,66 @@ describe("As Lu I should see the share dialog", () => {
243
162
  expect(props.onClose).toHaveBeenCalled();
244
163
  });
245
164
 
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 () => {
165
+ it("As LU I should see an error dialog if the confirm operation fails for an unexpected reason", async () => {
281
166
  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
167
  const error = new PassboltApiFetchError("Jest simulate API error.");
295
- jest.spyOn(context.port, "request").mockImplementationOnce(() => {
168
+ props.onConfirm.mockImplementation(() => {
296
169
  throw error;
297
170
  });
298
171
 
299
172
  await page.savePermissions();
300
173
 
301
- // Throw general error message
302
174
  expect(props.dialogContext.open).toHaveBeenCalledWith(NotifyError, { error: error });
303
175
  });
304
176
  });
305
177
 
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 });
178
+ describe("Sharing a single resource", () => {
179
+ it("As LU I see the single-resource title and subtitle and confirm the permission deltas", async () => {
180
+ expect.assertions(4);
181
+ props = resourcesShareProps(["apache"]);
182
+ mockContextRequest(jest.fn());
318
183
  await act(() => (page = new ShareDialogPage(context, props)));
319
- });
320
184
 
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
185
  expect(page.title).toBe("Share resource");
329
186
  expect(page.subtitle).toBe("apache");
330
- expect(page.count).toBe(11);
331
187
 
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");
188
+ const newUser = defaultUserDto({ username: "admin@passbolt.com" });
189
+ mockSearchReturns(newUser);
190
+ await page.searchName("admin");
340
191
  await waitForTrue(() => Boolean(page.userOrGroupAutocomplete(1)));
341
192
  await page.selectUserOrGroup(1);
342
193
 
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
-
194
+ mockContextRequest(jest.fn());
352
195
  await page.savePermissions();
353
196
 
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();
197
+ const changes = props.onConfirm.mock.calls[0][0];
198
+ expect(changes).toHaveLength(1);
199
+ expect(changes[0]).toMatchObject({ is_new: true, aco: "Resource", aro_foreign_key: newUser.id, type: 1 });
398
200
  });
399
201
  });
400
202
 
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 });
203
+ describe("Sharing a single folder", () => {
204
+ it("As LU I see the folder title and subtitle and confirm the folder deltas", async () => {
205
+ expect.assertions(4);
206
+ props = folderShareProps("apache");
207
+ mockContextRequest(jest.fn());
413
208
  await act(() => (page = new ShareDialogPage(context, props)));
414
- });
415
209
 
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
210
  expect(page.title).toBe("Share folder");
423
211
  expect(page.subtitle).toBe("apache");
424
- expect(page.count).toBe(2);
425
-
426
- const requestKeyInfoMockImpl = () => ({
427
- fingerprint: "079D6F4FDA3BFDC2D8E562D8AA44B1DA4BFB36B6",
428
- });
429
- mockContextRequest(requestKeyInfoMockImpl);
430
212
 
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");
213
+ const newUser = defaultUserDto({ username: "adele@passbolt.com" });
214
+ mockSearchReturns(newUser);
215
+ await page.searchName("adele");
508
216
  await waitForTrue(() => Boolean(page.userOrGroupAutocomplete(1)));
509
217
  await page.selectUserOrGroup(1);
510
218
 
219
+ mockContextRequest(jest.fn());
511
220
  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
- });
221
+
222
+ const changes = props.onConfirm.mock.calls[0][0];
223
+ expect(changes).toHaveLength(1);
224
+ expect(changes[0]).toMatchObject({ is_new: true, aco: "Folder", aro_foreign_key: newUser.id, type: 1 });
516
225
  });
517
226
  });
518
227
  });
@@ -522,56 +231,9 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
522
231
  const context = defaultAppContext();
523
232
  const mockContextRequest = (implementation) => jest.spyOn(context.port, "request").mockImplementation(implementation);
524
233
 
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
234
  it("As LU I should not see the dialog fetch resource permissions when controlled-mode props are provided", async () => {
573
235
  expect.assertions(2);
574
- const props = buildControlledModeProps();
236
+ const props = controlledModeProps();
575
237
  mockContextRequest(jest.fn());
576
238
 
577
239
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -585,7 +247,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
585
247
 
586
248
  it("As LU I should see the snapshot's permissions rendered in the order they were captured", async () => {
587
249
  expect.assertions(2);
588
- const props = buildControlledModeProps();
250
+ const props = controlledModeProps();
589
251
  mockContextRequest(jest.fn());
590
252
 
591
253
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -595,9 +257,20 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
595
257
  expect(page.aroDetails(2)).toEqual(expect.stringContaining("@passbolt.com"));
596
258
  });
597
259
 
260
+ it("As LU I should see directly-permissioned users rendered from the permission-embedded user when absent from initialUsers", async () => {
261
+ expect.assertions(2);
262
+ const props = controlledModeEmbeddedUsersProps();
263
+ mockContextRequest(jest.fn());
264
+
265
+ await act(() => (page = new ShareDialogPage(context, props)));
266
+
267
+ expect(page.aroDetails(1)).toEqual(expect.stringContaining("@passbolt.com"));
268
+ expect(page.aroDetails(2)).toEqual(expect.stringContaining("@passbolt.com"));
269
+ });
270
+
598
271
  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
272
  expect.assertions(1);
600
- const props = buildControlledModeProps();
273
+ const props = controlledModeProps();
601
274
  mockContextRequest(jest.fn());
602
275
 
603
276
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -607,7 +280,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
607
280
 
608
281
  it("As LU confirming the dialog as-is I should see onConfirm called with an empty delta (backend already inherits parent perms)", async () => {
609
282
  expect.assertions(3);
610
- const props = buildControlledModeProps();
283
+ const props = controlledModeProps();
611
284
  mockContextRequest(jest.fn());
612
285
 
613
286
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -627,7 +300,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
627
300
 
628
301
  it("As LU removing a row before confirming I should see a delete delta emitted for that row", async () => {
629
302
  expect.assertions(3);
630
- const props = buildControlledModeProps();
303
+ const props = controlledModeProps();
631
304
  mockContextRequest(jest.fn());
632
305
 
633
306
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -646,7 +319,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
646
319
  expect.assertions(2);
647
320
  // Folder mode: the seeded entry is the folder itself; its edits must be emitted as Folder deltas
648
321
  // so the workflow saves them via the folder-share path.
649
- const props = { ...buildControlledModeProps(), acoType: "Folder" };
322
+ const props = controlledModeProps({ acoType: "Folder" });
650
323
  mockContextRequest(jest.fn());
651
324
 
652
325
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -664,7 +337,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
664
337
  // (ShareChanges tags new permissions from the ACO bucket type). The folder-share save then
665
338
  // received an empty delta and silently did nothing. The seeded folder must live in the folder
666
339
  // bucket so additions are emitted as Folder deltas.
667
- const props = { ...buildControlledModeProps(), acoType: "Folder" };
340
+ const props = controlledModeProps({ acoType: "Folder" });
668
341
  const newUserId = uuidv4();
669
342
  const newUser = defaultUserDto({ id: newUserId, username: "newcomer@passbolt.com" });
670
343
  mockContextRequest((request) => {
@@ -688,55 +361,9 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
688
361
  });
689
362
 
690
363
  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
364
  it("As LU I should see the recipients aggregated across the resources without fetching from the API", async () => {
738
365
  expect.assertions(2);
739
- const props = buildInitialResourcesProps();
366
+ const props = twoResourcesShareProps();
740
367
  mockContextRequest(jest.fn());
741
368
 
742
369
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -751,7 +378,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
751
378
 
752
379
  it("As LU sharing several resources I should see their names listed in the title tooltip", async () => {
753
380
  expect.assertions(1);
754
- const props = buildInitialResourcesProps();
381
+ const props = twoResourcesShareProps();
755
382
  mockContextRequest(jest.fn());
756
383
 
757
384
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -765,7 +392,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
765
392
  describe("Read-only mode", () => {
766
393
  it("As LU with update-but-not-owner access I should not see the autocomplete to add people or groups", async () => {
767
394
  expect.assertions(2);
768
- const props = { ...buildControlledModeProps(), readOnly: true };
395
+ const props = { ...controlledModeProps(), readOnly: true };
769
396
  mockContextRequest(jest.fn());
770
397
 
771
398
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -777,7 +404,7 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
777
404
 
778
405
  it("As LU in read-only mode I should still be able to confirm the set as-is (empty delta)", async () => {
779
406
  expect.assertions(3);
780
- const props = { ...buildControlledModeProps(), readOnly: true };
407
+ const props = { ...controlledModeProps(), readOnly: true };
781
408
  mockContextRequest(jest.fn());
782
409
 
783
410
  await act(() => (page = new ShareDialogPage(context, props)));
@@ -790,28 +417,6 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
790
417
  });
791
418
  });
792
419
 
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
420
  describe("Group members expansion", () => {
816
421
  // Permissions are sorted by aro name: user "Ada Lovelace" (row 1), group "Developer" (row 2).
817
422
  it("As LU I should see a members toggle on group rows but not on user rows", async () => {
@@ -850,10 +455,8 @@ describe("As LU running ShareDialog in controlled mode (workflow-driven)", () =>
850
455
  switch (request) {
851
456
  case "passbolt.share.search-aros":
852
457
  return [addedGroup.searchResult];
853
- case "passbolt.groups_users.get-by-group-id":
854
- return addedGroup.groupsUsers;
855
- case "passbolt.users.get-by-ids":
856
- return addedGroup.members;
458
+ case "passbolt.groups.find-by-ids-for-share":
459
+ return [addedGroup.group];
857
460
  }
858
461
  };
859
462
  mockContextRequest(requestBextMockImpl);