@redacto.io/consent-sdk-react 10.0.0-beta.8 → 10.0.0

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 (262) hide show
  1. package/NOTICE.md +17 -0
  2. package/README.md +141 -3
  3. package/dist/chunk-FEGTW73Q.mjs +182 -0
  4. package/dist/{chunk-6A665OPR.mjs → chunk-OGL6OC3A.mjs} +4 -0
  5. package/dist/fonts.d.mts +35 -0
  6. package/dist/fonts.d.ts +35 -0
  7. package/dist/fonts.js +183 -0
  8. package/dist/fonts.mjs +10 -0
  9. package/dist/index.d.mts +41 -4
  10. package/dist/index.d.ts +41 -4
  11. package/dist/index.js +881 -416
  12. package/dist/index.mjs +502 -253
  13. package/dist/montserrat.generated-NBTECYRW.mjs +22 -0
  14. package/dist/privacy-center.d.mts +51 -11
  15. package/dist/privacy-center.d.ts +51 -11
  16. package/dist/privacy-center.js +252 -136
  17. package/dist/privacy-center.mjs +251 -137
  18. package/dist/types-6Aj7faxL.d.mts +57 -0
  19. package/dist/types-6Aj7faxL.d.ts +57 -0
  20. package/package.json +10 -1
  21. package/.turbo/turbo-build.log +0 -22
  22. package/.turbo/turbo-test.log +0 -203
  23. package/.turbo/turbo-verify-pack.log +0 -6
  24. package/CHANGELOG.md +0 -343
  25. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +0 -934
  26. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +0 -2160
  27. package/src/RedactoNoticeAssisted/api/index.ts +0 -275
  28. package/src/RedactoNoticeAssisted/api/types.ts +0 -182
  29. package/src/RedactoNoticeAssisted/assets/redacto-logo.png +0 -0
  30. package/src/RedactoNoticeAssisted/constants.ts +0 -51
  31. package/src/RedactoNoticeAssisted/i18n.ts +0 -1408
  32. package/src/RedactoNoticeAssisted/index.ts +0 -1
  33. package/src/RedactoNoticeAssisted/injectStyles.ts +0 -251
  34. package/src/RedactoNoticeAssisted/styles.ts +0 -730
  35. package/src/RedactoNoticeAssisted/types.ts +0 -26
  36. package/src/RedactoNoticeAssisted/useMediaQuery.ts +0 -36
  37. package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +0 -1152
  38. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +0 -4258
  39. package/src/RedactoNoticeConsent/api/index.ts +0 -512
  40. package/src/RedactoNoticeConsent/api/types.ts +0 -469
  41. package/src/RedactoNoticeConsent/assets/redacto-logo.png +0 -0
  42. package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +0 -602
  43. package/src/RedactoNoticeConsent/components/index.ts +0 -7
  44. package/src/RedactoNoticeConsent/constants.ts +0 -20
  45. package/src/RedactoNoticeConsent/index.ts +0 -1
  46. package/src/RedactoNoticeConsent/injectStyles.ts +0 -151
  47. package/src/RedactoNoticeConsent/language-codes.ts +0 -95
  48. package/src/RedactoNoticeConsent/services/storage.ts +0 -122
  49. package/src/RedactoNoticeConsent/styles.ts +0 -409
  50. package/src/RedactoNoticeConsent/types.ts +0 -54
  51. package/src/RedactoNoticeConsent/useMediaQuery.ts +0 -36
  52. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.test.tsx +0 -369
  53. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +0 -687
  54. package/src/RedactoNoticeConsentInline/api/index.ts +0 -106
  55. package/src/RedactoNoticeConsentInline/api/types.ts +0 -183
  56. package/src/RedactoNoticeConsentInline/assets/redacto-logo.png +0 -0
  57. package/src/RedactoNoticeConsentInline/index.ts +0 -1
  58. package/src/RedactoNoticeConsentInline/injectStyles.ts +0 -40
  59. package/src/RedactoNoticeConsentInline/styles.ts +0 -397
  60. package/src/RedactoNoticeConsentInline/types.ts +0 -51
  61. package/src/RedactoNoticeConsentInline/useMediaQuery.ts +0 -36
  62. package/src/RedactoPrivacyCenter/NotificationsPage.tsx +0 -182
  63. package/src/RedactoPrivacyCenter/PrivacyCenterActivityPage.tsx +0 -19
  64. package/src/RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage.tsx +0 -156
  65. package/src/RedactoPrivacyCenter/PrivacyCenterConsentManagerPage.tsx +0 -17
  66. package/src/RedactoPrivacyCenter/PrivacyCenterFormPage.tsx +0 -79
  67. package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +0 -36
  68. package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +0 -177
  69. package/src/RedactoPrivacyCenter/PrivacyCenterMyReceiptPage.tsx +0 -26
  70. package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +0 -58
  71. package/src/RedactoPrivacyCenter/api/actions.ts +0 -695
  72. package/src/RedactoPrivacyCenter/api/client.ts +0 -911
  73. package/src/RedactoPrivacyCenter/api/config.ts +0 -33
  74. package/src/RedactoPrivacyCenter/api/fetcher.ts +0 -260
  75. package/src/RedactoPrivacyCenter/api/orgBranding.ts +0 -16
  76. package/src/RedactoPrivacyCenter/api/upload.ts +0 -93
  77. package/src/RedactoPrivacyCenter/assets/character.svg +0 -31
  78. package/src/RedactoPrivacyCenter/assets/fileAttach.svg +0 -9
  79. package/src/RedactoPrivacyCenter/assets/greenTick.svg +0 -4
  80. package/src/RedactoPrivacyCenter/assets/mail.svg +0 -3
  81. package/src/RedactoPrivacyCenter/assets/poweredByRedacto.svg +0 -9
  82. package/src/RedactoPrivacyCenter/assets/sentImg.svg +0 -9
  83. package/src/RedactoPrivacyCenter/assets/uploadFileIcon.svg +0 -9
  84. package/src/RedactoPrivacyCenter/components/ActivitiesList.tsx +0 -252
  85. package/src/RedactoPrivacyCenter/components/ActivityTimeline.tsx +0 -239
  86. package/src/RedactoPrivacyCenter/components/AppShell/AppShell.tsx +0 -268
  87. package/src/RedactoPrivacyCenter/components/AppShell/MobileNavDrawer.tsx +0 -218
  88. package/src/RedactoPrivacyCenter/components/AppShell/NavItem.tsx +0 -205
  89. package/src/RedactoPrivacyCenter/components/AppShell/PageHeader.tsx +0 -107
  90. package/src/RedactoPrivacyCenter/components/AppShell/SidebarNav.tsx +0 -100
  91. package/src/RedactoPrivacyCenter/components/AppShell/TopAppBar.tsx +0 -339
  92. package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +0 -245
  93. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useIsTruncated.ts +0 -28
  94. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useKeyboardShortcut.ts +0 -40
  95. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useSidebarState.ts +0 -62
  96. package/src/RedactoPrivacyCenter/components/AppShell/usePrivacyCenterExitAction.ts +0 -36
  97. package/src/RedactoPrivacyCenter/components/CaseDetails/AttachmentCard.tsx +0 -38
  98. package/src/RedactoPrivacyCenter/components/CaseDetails/ChatBubble.tsx +0 -31
  99. package/src/RedactoPrivacyCenter/components/CaseDetails/DocumentRequestCard.tsx +0 -79
  100. package/src/RedactoPrivacyCenter/components/CaseDetails/FinalizedTooltipWrapper.tsx +0 -25
  101. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageComposer.tsx +0 -96
  102. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageItem.tsx +0 -97
  103. package/src/RedactoPrivacyCenter/components/CaseDetails/MessagesTab.tsx +0 -156
  104. package/src/RedactoPrivacyCenter/components/CaseDetails/RequestDetailsTab.tsx +0 -171
  105. package/src/RedactoPrivacyCenter/components/CaseDetails/StatusEvent.tsx +0 -23
  106. package/src/RedactoPrivacyCenter/components/CaseDetails/useFileUpload.ts +0 -116
  107. package/src/RedactoPrivacyCenter/components/CaseDetails/useMessagePolling.ts +0 -43
  108. package/src/RedactoPrivacyCenter/components/CaseDetails/utils.ts +0 -71
  109. package/src/RedactoPrivacyCenter/components/CaseDetailsModal.tsx +0 -469
  110. package/src/RedactoPrivacyCenter/components/CaseHistory.tsx +0 -426
  111. package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +0 -1206
  112. package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +0 -218
  113. package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +0 -138
  114. package/src/RedactoPrivacyCenter/components/ConsentManagerConstants.ts +0 -7
  115. package/src/RedactoPrivacyCenter/components/ConsentManagerExpandedRow.tsx +0 -179
  116. package/src/RedactoPrivacyCenter/components/ConsentManagerGroupedColumns.tsx +0 -318
  117. package/src/RedactoPrivacyCenter/components/ConsentManagerProductCards.tsx +0 -333
  118. package/src/RedactoPrivacyCenter/components/ConsentManagerPurposeCards.tsx +0 -102
  119. package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +0 -159
  120. package/src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection.tsx +0 -189
  121. package/src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection.tsx +0 -118
  122. package/src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection.tsx +0 -66
  123. package/src/RedactoPrivacyCenter/components/DataRequest/ProductSelectionSection.tsx +0 -222
  124. package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +0 -331
  125. package/src/RedactoPrivacyCenter/components/Form.tsx +0 -1796
  126. package/src/RedactoPrivacyCenter/components/GrievanceTable.tsx +0 -174
  127. package/src/RedactoPrivacyCenter/components/GrievanceTablePagination.tsx +0 -337
  128. package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +0 -334
  129. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationBell.tsx +0 -173
  130. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationCTAButton.tsx +0 -18
  131. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdown.tsx +0 -54
  132. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdownItem.tsx +0 -57
  133. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationIcon.tsx +0 -19
  134. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationListPanel.tsx +0 -92
  135. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRefreshButton.tsx +0 -20
  136. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRow.tsx +0 -58
  137. package/src/RedactoPrivacyCenter/components/NotificationHub/StatCard.tsx +0 -10
  138. package/src/RedactoPrivacyCenter/components/NotificationHub/useNotificationActions.ts +0 -112
  139. package/src/RedactoPrivacyCenter/components/NotificationHub/utils.ts +0 -27
  140. package/src/RedactoPrivacyCenter/components/Pagination.tsx +0 -140
  141. package/src/RedactoPrivacyCenter/components/PrivacyCenterEmptyState.tsx +0 -76
  142. package/src/RedactoPrivacyCenter/components/PrivacyCenterSessionExpired.tsx +0 -97
  143. package/src/RedactoPrivacyCenter/components/ReceiptsList.tsx +0 -454
  144. package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +0 -270
  145. package/src/RedactoPrivacyCenter/components/SelectUser.tsx +0 -95
  146. package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +0 -187
  147. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +0 -25
  148. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/types.ts +0 -21
  149. package/src/RedactoPrivacyCenter/components/caseHistoryColumns.tsx +0 -159
  150. package/src/RedactoPrivacyCenter/components/constant.ts +0 -52
  151. package/src/RedactoPrivacyCenter/components/groupHelpers.ts +0 -119
  152. package/src/RedactoPrivacyCenter/components/receiptColumns.tsx +0 -203
  153. package/src/RedactoPrivacyCenter/components/types.ts +0 -123
  154. package/src/RedactoPrivacyCenter/components/utils.tsx +0 -10
  155. package/src/RedactoPrivacyCenter/config/routes.ts +0 -9
  156. package/src/RedactoPrivacyCenter/config/table.ts +0 -25
  157. package/src/RedactoPrivacyCenter/context/AuthContext.tsx +0 -160
  158. package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +0 -47
  159. package/src/RedactoPrivacyCenter/context/BrandingContext.tsx +0 -52
  160. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.session-expired.test.tsx +0 -92
  161. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.tsx +0 -181
  162. package/src/RedactoPrivacyCenter/context/LocaleContext.tsx +0 -11
  163. package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +0 -96
  164. package/src/RedactoPrivacyCenter/context/OrganizationContext.tsx +0 -30
  165. package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +0 -80
  166. package/src/RedactoPrivacyCenter/context/ProfileSwitchContext.tsx +0 -15
  167. package/src/RedactoPrivacyCenter/context/types.ts +0 -19
  168. package/src/RedactoPrivacyCenter/lib/api.ts +0 -759
  169. package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +0 -67
  170. package/src/RedactoPrivacyCenter/lib/constants.ts +0 -276
  171. package/src/RedactoPrivacyCenter/lib/i18n.ts +0 -81
  172. package/src/RedactoPrivacyCenter/lib/locales.ts +0 -102
  173. package/src/RedactoPrivacyCenter/lib/queries.ts +0 -141
  174. package/src/RedactoPrivacyCenter/lib/types.ts +0 -876
  175. package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +0 -37
  176. package/src/RedactoPrivacyCenter/lib/utils.refresh-circuit.test.ts +0 -127
  177. package/src/RedactoPrivacyCenter/lib/utils.refresh-storage.test.ts +0 -85
  178. package/src/RedactoPrivacyCenter/lib/utils.session-expired.test.ts +0 -109
  179. package/src/RedactoPrivacyCenter/lib/utils.ts +0 -783
  180. package/src/RedactoPrivacyCenter/locales/as/translation.json +0 -342
  181. package/src/RedactoPrivacyCenter/locales/bn/translation.json +0 -342
  182. package/src/RedactoPrivacyCenter/locales/brx/translation.json +0 -342
  183. package/src/RedactoPrivacyCenter/locales/doi/translation.json +0 -342
  184. package/src/RedactoPrivacyCenter/locales/en/translation.json +0 -357
  185. package/src/RedactoPrivacyCenter/locales/gom/translation.json +0 -342
  186. package/src/RedactoPrivacyCenter/locales/gu/translation.json +0 -342
  187. package/src/RedactoPrivacyCenter/locales/hi/translation.json +0 -345
  188. package/src/RedactoPrivacyCenter/locales/kn/translation.json +0 -342
  189. package/src/RedactoPrivacyCenter/locales/ks/translation.json +0 -342
  190. package/src/RedactoPrivacyCenter/locales/mai/translation.json +0 -342
  191. package/src/RedactoPrivacyCenter/locales/ml/translation.json +0 -342
  192. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +0 -342
  193. package/src/RedactoPrivacyCenter/locales/mr/translation.json +0 -342
  194. package/src/RedactoPrivacyCenter/locales/ne/translation.json +0 -342
  195. package/src/RedactoPrivacyCenter/locales/or/translation.json +0 -342
  196. package/src/RedactoPrivacyCenter/locales/pa/translation.json +0 -342
  197. package/src/RedactoPrivacyCenter/locales/sa/translation.json +0 -342
  198. package/src/RedactoPrivacyCenter/locales/sat/translation.json +0 -342
  199. package/src/RedactoPrivacyCenter/locales/sd/translation.json +0 -342
  200. package/src/RedactoPrivacyCenter/locales/ta/translation.json +0 -342
  201. package/src/RedactoPrivacyCenter/locales/te/translation.json +0 -342
  202. package/src/RedactoPrivacyCenter/locales/ur/translation.json +0 -342
  203. package/src/RedactoPrivacyCenter/styles/applyBrandingTheme.ts +0 -66
  204. package/src/RedactoPrivacyCenter/styles/base.css +0 -117
  205. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +0 -3108
  206. package/src/RedactoPrivacyCenter/styles/pcStyles.ts +0 -831
  207. package/src/RedactoPrivacyCenter/styles/responsive.ts +0 -138
  208. package/src/RedactoPrivacyCenter/styles/variables.css +0 -96
  209. package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +0 -387
  210. package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +0 -468
  211. package/src/RedactoPrivacyCenter/table/index.ts +0 -2
  212. package/src/RedactoPrivacyCenter/types/images.d.ts +0 -29
  213. package/src/RedactoPrivacyCenter/ui/Footer.tsx +0 -69
  214. package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +0 -54
  215. package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +0 -93
  216. package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +0 -47
  217. package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +0 -83
  218. package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +0 -93
  219. package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +0 -48
  220. package/src/RedactoPrivacyCenter/ui/PCButton.tsx +0 -77
  221. package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +0 -55
  222. package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +0 -107
  223. package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +0 -35
  224. package/src/RedactoPrivacyCenter/ui/PCInput.tsx +0 -132
  225. package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +0 -31
  226. package/src/RedactoPrivacyCenter/ui/PCModal.tsx +0 -106
  227. package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +0 -206
  228. package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +0 -433
  229. package/src/RedactoPrivacyCenter/ui/PCTable.tsx +0 -149
  230. package/src/RedactoPrivacyCenter/ui/PCText.tsx +0 -41
  231. package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +0 -43
  232. package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +0 -37
  233. package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +0 -121
  234. package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +0 -25
  235. package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +0 -53
  236. package/src/RedactoPrivacyCenter/ui/index.ts +0 -18
  237. package/src/RedactoPrivacyCenter/utils/cn.ts +0 -28
  238. package/src/RedactoPrivacyCenter/utils/date.ts +0 -48
  239. package/src/RedactoPrivacyCenter/utils/status.ts +0 -111
  240. package/src/RedactoPrivacyCenter/utils/toast.ts +0 -130
  241. package/src/index.ts +0 -19
  242. package/src/privacy-center.ts +0 -113
  243. package/src/shared/api-errors.ts +0 -180
  244. package/src/shared/notice-consent-status.ts +0 -190
  245. package/src/types/css.d.ts +0 -4
  246. package/src/types/images.d.ts +0 -19
  247. package/src/types/react-jsx.d.ts +0 -26
  248. package/tests/DataAvailabilityContext.test.tsx +0 -123
  249. package/tests/Form.test.tsx +0 -1287
  250. package/tests/ManageConsentErrorMapping.test.tsx +0 -85
  251. package/tests/ProductSelectionSection.test.tsx +0 -328
  252. package/tests/RequestSubmit.test.tsx +0 -135
  253. package/tests/RevocablePurpose.test.tsx +0 -146
  254. package/tests/RevokeWarningMessage.test.tsx +0 -151
  255. package/tests/consentClient.test.ts +0 -217
  256. package/tests/manageConsentServer.test.ts +0 -38
  257. package/tests/mocks.ts +0 -257
  258. package/tests/resolveContactFromJwt.test.ts +0 -44
  259. package/tests/setup.ts +0 -16
  260. package/tsconfig.json +0 -16
  261. package/tsup.config.ts +0 -31
  262. package/vitest.config.ts +0 -16
@@ -1,1287 +0,0 @@
1
- import { render, screen, fireEvent, waitFor, act, within } from '@testing-library/react';
2
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
-
4
- // ─── react-i18next stub ──────────────────────────────────────────────────────
5
- vi.mock('react-i18next', () => {
6
- const en: Record<string, string> = {
7
- raiseDataRequest: 'Raise a data request',
8
- contact: 'Contact',
9
- contactPlaceholder: 'Enter email',
10
- requestType: 'Request type',
11
- requestDetails: 'Request details',
12
- selectRequestType: 'Select request type',
13
- supportingDocumentation: 'Supporting documentation',
14
- confirmCheckBox: 'I confirm the details above are accurate',
15
- submit: 'Submit',
16
- cancel: 'Cancel',
17
- uploadFile: 'Upload file',
18
- uploadFileButton: 'Browse',
19
- description: 'Description',
20
- additionalNote: 'Additional note',
21
- reasonOptional: 'Reason (optional)',
22
- timePeriod: 'Time period',
23
- today: 'Today',
24
- last7Days: 'Last 7 days',
25
- last30Days: 'Last 30 days',
26
- last3Months: 'Last 3 months',
27
- access: 'access',
28
- correction: 'correction',
29
- erasure: 'erasure',
30
- grievance: 'grievance',
31
- nomination: 'nomination',
32
- forProduct: 'For {{productName}}',
33
- actingOnBehalfOfShort: 'acting on behalf of {{nominator}}',
34
- selectPurposesForThisProduct: 'Select purposes within this product.',
35
- selectProductsForRequest:
36
- 'Select a product for your {{requestType}} request',
37
- selectProductsForRequestGeneric: 'Select a product to continue',
38
- nominationChipSuffix: '· {{nominator}}',
39
- yourData: 'Your data',
40
- actingOnBehalfOf: 'Acting on behalf of {{nominator}}',
41
- activePurposes_one: '{{count}} purpose',
42
- activePurposes_other: '{{count}} purposes',
43
- autoSelected: 'Auto-selected',
44
- noProductsAvailable: 'No products available',
45
- noProductsAvailableDescription: 'You have no consents to manage yet.',
46
- requestSubmittedSuccess: 'Request submitted',
47
- requestSubmissionFailed: 'Request failed',
48
- submissionFailed: 'Submission failed',
49
- whatDataToAccess: 'What data to access',
50
- whatDataToDelete: 'What data to delete',
51
- selectAll: 'Select all',
52
- dataCollected: 'Data collected',
53
- revokeConsentNo: 'No',
54
- revokeConsentYes: 'Yes',
55
- revokeConsentModalTitle: 'Revoke consent?',
56
- revokeConsentModalQuestion: 'Do you also want to revoke consent?',
57
- revokeConsentModalPurposesLabel: 'Purposes',
58
- revokeConsentModalYourPurposes: 'Your purposes',
59
- revokeConsentModalIfYesLabel: 'If yes:',
60
- revokeConsentModalIfYesBody: 'Your consent will be revoked.',
61
- requestSubmittedSuccessfully: 'Request submitted successfully',
62
- thankYouForSubmittingYourRequest: 'Thanks',
63
- };
64
- const interpolate = (template: string, vars?: Record<string, unknown>) =>
65
- template.replace(/\{\{(\w+)\}\}/g, (_match, key: string) => {
66
- const value = vars?.[key];
67
- return value === undefined || value === null ? '' : String(value);
68
- });
69
- const t = (key: string, opts?: Record<string, unknown>) => {
70
- const count = typeof opts?.count === 'number' ? opts.count : undefined;
71
- const pluralKey =
72
- count !== undefined
73
- ? count === 1
74
- ? `${key}_one`
75
- : `${key}_other`
76
- : key;
77
- const template = en[pluralKey] ?? en[key] ?? key;
78
- return interpolate(template, opts);
79
- };
80
- return {
81
- useTranslation: () => ({
82
- t,
83
- i18n: { language: 'en', on: vi.fn(), off: vi.fn() },
84
- }),
85
- };
86
- });
87
-
88
- // ─── i18n module stub (used directly by Form.tsx for `on`/`off`) ─────────────
89
- vi.mock('../src/RedactoPrivacyCenter/lib/i18n', () => ({
90
- default: {
91
- language: 'en',
92
- on: vi.fn(),
93
- off: vi.fn(),
94
- },
95
- }));
96
-
97
- // ─── API stubs ───────────────────────────────────────────────────────────────
98
- // 1-form -> 1-case: only `createCaseRequest` is consumed by Form.tsx now.
99
- const createCaseRequest = vi.fn();
100
- const getFormData = vi.fn();
101
- const fetchUserConsents = vi.fn();
102
- vi.mock('../src/RedactoPrivacyCenter/lib/api', () => ({
103
- createCaseRequest: (...args: unknown[]) => createCaseRequest(...args),
104
- getFormData: (...args: unknown[]) => getFormData(...args),
105
- // Approach A sources the product picker from the ledger's user-consents.
106
- // Default to no ledger result so the form falls back to the getFormData
107
- // product groups these tests set up.
108
- fetchUserConsents: (...args: unknown[]) => fetchUserConsents(...args),
109
- }));
110
-
111
- // ─── upload stub ─────────────────────────────────────────────────────────────
112
- vi.mock('../src/RedactoPrivacyCenter/api/upload', () => ({
113
- uploadFileWithS2S: vi.fn(),
114
- }));
115
-
116
- // ─── tanstack/react-query stub ───────────────────────────────────────────────
117
- vi.mock('@tanstack/react-query', () => ({
118
- useQueryClient: () => ({ invalidateQueries: vi.fn() }),
119
- }));
120
-
121
- // ─── Toast stub ──────────────────────────────────────────────────────────────
122
- vi.mock('../src/RedactoPrivacyCenter/utils/toast', () => ({
123
- toast: {
124
- success: vi.fn(),
125
- error: vi.fn(),
126
- info: vi.fn(),
127
- },
128
- }));
129
-
130
- // ─── Auth / BaseUrl / Organization context stubs ─────────────────────────────
131
- // Stable references prevent identity churn from re-firing effects whose deps
132
- // include context-derived values (auth, consentClient, organization).
133
- vi.mock('../src/RedactoPrivacyCenter/context/AuthContext', () => {
134
- const auth = {
135
- accessToken: 'tok',
136
- refreshToken: 'rtok',
137
- onError: () => false,
138
- updateTokens: () => {},
139
- };
140
- return { useAuth: () => auth };
141
- });
142
-
143
- // Mutable so individual tests can drop `ledgerBaseUrl` to exercise the legacy
144
- // (no-ledger) mode; beforeEach restores the ledger default.
145
- const baseUrlStub = vi.hoisted(() => ({
146
- consentClient: { get: () => Promise.resolve(null), post: () => Promise.resolve(null) },
147
- baseUrl: 'https://consent.test',
148
- ledgerBaseUrl: 'https://ledger.test/consent-ledger' as string | undefined,
149
- }));
150
- vi.mock('../src/RedactoPrivacyCenter/context/BaseUrlContext', () => ({
151
- useBaseUrl: () => baseUrlStub,
152
- }));
153
-
154
- vi.mock('../src/RedactoPrivacyCenter/context/OrganizationContext', () => {
155
- const org = {
156
- organization: {
157
- uuid: 'org-uuid',
158
- slug: 'acme',
159
- name: 'Acme',
160
- workspaces: [{ uuid: 'ws-uuid' }],
161
- },
162
- };
163
- return { useOrganization: () => org };
164
- });
165
-
166
- // ─── Optional peer-dep icon libs: stub with concrete named exports.
167
- // `lucide-react` and `react-icons/*` are peer deps with no entry in the
168
- // package's own node_modules. Tests don't care about icon glyphs — we
169
- // stub every name imported by transitively-loaded SDK modules.
170
- vi.mock('lucide-react', () => {
171
- const S = () => null;
172
- return {
173
- X: S, ChevronDown: S, ChevronDownIcon: S, Check: S, Mail: S, Search: S,
174
- ArrowUpToLine: S, ArrowLeft: S, Filter: S, Circle: S, Smartphone: S,
175
- LaptopMinimal: S, ShieldCheck: S, Globe2: S, Menu: S, MessageCircleWarning: S,
176
- PanelLeftClose: S, PanelLeftOpen: S, LogOut: S, Activity: S, ReceiptText: S,
177
- };
178
- });
179
- vi.mock('react-icons/ai', () => ({ AiOutlineClose: () => null }));
180
- vi.mock('react-icons/pi', () => {
181
- const S = () => null;
182
- return {
183
- PiUploadBold: S, PiWarningCircleBold: S, PiCaretDownFill: S, PiCaretUpFill: S,
184
- };
185
- });
186
- vi.mock('react-icons/fi', () => {
187
- const S = () => null;
188
- return {
189
- FiAlertCircle: S, FiChevronDown: S, FiChevronUp: S, FiX: S,
190
- FiDownload: S, FiSearch: S, FiFilter: S,
191
- };
192
- });
193
- vi.mock('react-icons/io5', () => {
194
- const S = () => null;
195
- return {
196
- IoArrowBack: S, IoChevronBackOutline: S, IoAdd: S, IoAttach: S,
197
- IoDocumentText: S, IoNotificationsOutline: S, IoPersonOutline: S,
198
- IoRefresh: S, IoRefreshOutline: S, IoSend: S, IoTimeOutline: S,
199
- IoDocumentOutline: S, IoShieldCheckmarkOutline: S, IoAlertCircleOutline: S,
200
- IoSettingsOutline: S,
201
- };
202
- });
203
-
204
- // ─── PCSelect stub: replace at module source so the barrel re-export
205
- // picks up the stub. PCSelect uses lucide-react, which is fragile in
206
- // tests; stubbing also lets us drive it with a native <select>.
207
- vi.mock('../src/RedactoPrivacyCenter/ui/PCSelect', () => {
208
- type Option = { value: string | number; label: string };
209
- const PCSelect = ({
210
- options,
211
- value,
212
- onChange,
213
- label,
214
- disabled,
215
- }: {
216
- options: readonly Option[];
217
- value: Option | null;
218
- onChange?: (opt: Option | null) => void;
219
- label?: React.ReactNode;
220
- disabled?: boolean;
221
- }) => (
222
- <label>
223
- {typeof label === 'string' ? label : null}
224
- <select
225
- data-testid="pc-select"
226
- disabled={disabled}
227
- value={value ? String(value.value) : ''}
228
- onChange={(e) => {
229
- const opt = options.find((o) => String(o.value) === e.target.value);
230
- onChange?.(opt ?? null);
231
- }}
232
- >
233
- <option value="">--</option>
234
- {options.map((o) => (
235
- <option key={String(o.value)} value={String(o.value)}>
236
- {o.label}
237
- </option>
238
- ))}
239
- </select>
240
- </label>
241
- );
242
- return { PCSelect };
243
- });
244
-
245
- // ─── PCModal stub: render inline always when isOpen ──────────────────────────
246
- vi.mock('../src/RedactoPrivacyCenter/ui/PCModal', () => ({
247
- PCModal: ({
248
- isOpen,
249
- children,
250
- footer,
251
- }: {
252
- isOpen: boolean;
253
- children?: React.ReactNode;
254
- footer?: React.ReactNode;
255
- }) =>
256
- isOpen ? (
257
- <div data-testid="pc-modal">
258
- {children}
259
- {footer}
260
- </div>
261
- ) : null,
262
- }));
263
-
264
- // ─── Heavy/optional child stubs we don't want to exercise ────────────────────
265
- // CorrectionDataSection stub: light enough to render quickly, rich enough
266
- // for the per-product CORRECTION grouped-flow tests to drive selection
267
- // and value entry. Mirrors the real component's prop contract: a checkbox
268
- // per data-element plus two inputs (current / updated) per selected name.
269
- // Existing tests that don't interact with it still pass — they just see
270
- // an empty checklist when their request type isn't CORRECTION.
271
- vi.mock(
272
- '../src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection',
273
- () => ({
274
- default: ({
275
- dataElements,
276
- selected,
277
- setSelected,
278
- correctionValues,
279
- setCorrectionValues,
280
- }: {
281
- dataElements: Array<{ uuid: string; name: string }>;
282
- selected: string[];
283
- setSelected: (values: string[]) => void;
284
- correctionValues: Record<
285
- string,
286
- { current: string; updated: string }
287
- >;
288
- setCorrectionValues: (
289
- values: Record<string, { current: string; updated: string }>,
290
- ) => void;
291
- }) => (
292
- <div data-testid="correction-section">
293
- {dataElements.map((de) => (
294
- <div key={de.uuid}>
295
- <label>
296
- <input
297
- type="checkbox"
298
- aria-label={`correction-de-${de.name}`}
299
- checked={selected.includes(de.name)}
300
- onChange={(e) =>
301
- setSelected(
302
- e.target.checked
303
- ? [...selected, de.name]
304
- : selected.filter((n) => n !== de.name),
305
- )
306
- }
307
- />
308
- {de.name}
309
- </label>
310
- {selected.includes(de.name) && (
311
- <>
312
- <input
313
- aria-label={`correction-current-${de.name}`}
314
- value={correctionValues[de.name]?.current ?? ''}
315
- onChange={(e) =>
316
- setCorrectionValues({
317
- ...correctionValues,
318
- [de.name]: {
319
- ...(correctionValues[de.name] ?? {
320
- current: '',
321
- updated: '',
322
- }),
323
- current: e.target.value,
324
- },
325
- })
326
- }
327
- />
328
- <input
329
- aria-label={`correction-updated-${de.name}`}
330
- value={correctionValues[de.name]?.updated ?? ''}
331
- onChange={(e) =>
332
- setCorrectionValues({
333
- ...correctionValues,
334
- [de.name]: {
335
- ...(correctionValues[de.name] ?? {
336
- current: '',
337
- updated: '',
338
- }),
339
- updated: e.target.value,
340
- },
341
- })
342
- }
343
- />
344
- </>
345
- )}
346
- </div>
347
- ))}
348
- </div>
349
- ),
350
- }),
351
- );
352
- vi.mock(
353
- '../src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection',
354
- () => ({
355
- default: () => <div data-testid="grievance-section" />,
356
- }),
357
- );
358
- vi.mock(
359
- '../src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection',
360
- () => ({
361
- // Test-only stub: exposes an email input that calls the real
362
- // `setNominationData` setter, so tests can drive the form to a
363
- // valid NOMINATION state and exercise the actual submit path
364
- // (not just the "button disabled" gate).
365
- default: ({ nominationData, setNominationData }: any) => (
366
- <div data-testid="nomination-section">
367
- <input
368
- data-testid="nominee-email-input"
369
- value={nominationData?.nominee_email ?? ''}
370
- onChange={(e) =>
371
- setNominationData((prev: any) => ({
372
- ...prev,
373
- nominee_email: e.target.value,
374
- }))
375
- }
376
- />
377
- </div>
378
- ),
379
- }),
380
- );
381
- vi.mock('../src/RedactoPrivacyCenter/components/RequestSubmit', () => ({
382
- default: ({
383
- result,
384
- }: {
385
- result: {
386
- case_id: string;
387
- uuid: string;
388
- product_uuid: string;
389
- product_name: string;
390
- };
391
- }) => (
392
- <div data-testid="request-submitted">
393
- <span data-testid="request-submitted-case-id">{result.case_id}</span>
394
- <span data-testid="request-submitted-product-uuid">
395
- {result.product_uuid}
396
- </span>
397
- <span data-testid="request-submitted-product-name">
398
- {result.product_name}
399
- </span>
400
- </div>
401
- ),
402
- }));
403
-
404
- // ─── Imports under test (must come after all vi.mock calls) ──────────────────
405
- import Form from '../src/RedactoPrivacyCenter/components/Form';
406
- import {
407
- RequestTypeEnum,
408
- type FormData,
409
- type FormProductGroup,
410
- } from '../src/RedactoPrivacyCenter/lib/types';
411
-
412
- const baseDataElement = (uuid: string, name: string) => ({
413
- uuid,
414
- name,
415
- description: '',
416
- enabled: true,
417
- required: false,
418
- given_consent: true,
419
- selected: true,
420
- });
421
-
422
- const basePurpose = (
423
- uuid: string,
424
- name: string,
425
- dataElements = [baseDataElement(`${uuid}-de1`, `${name}-data`)],
426
- ) => ({
427
- uuid,
428
- name,
429
- description: '',
430
- industries: '',
431
- selected: false,
432
- given_consent: true,
433
- data_elements: dataElements,
434
- });
435
-
436
- /**
437
- * Build a FormData stub.
438
- *
439
- * `formUuid` is the FormDataOut session uuid (a fresh uuid the backend
440
- * mints per call to `PrivacyCenterSDK._generate_uuid()`) — intentionally
441
- * distinct from any user / nominator ConsentUser uuid so tests catch
442
- * the regression where the SDK previously sent this as `data_principal_uuid`
443
- * on direct cards and the backend rejected it as `invalid_data_principal`.
444
- */
445
- const makeFormData = (
446
- overrides: Partial<FormData> = {},
447
- formUuid = 'form-session-uuid',
448
- ): FormData => ({
449
- uuid: formUuid,
450
- name: 'Jane Principal',
451
- contact: 'jane@example.com',
452
- grievance_options: [],
453
- purposes: [],
454
- direct_groups: [],
455
- nominated_groups: [],
456
- ...overrides,
457
- });
458
-
459
- const makeGroup = (
460
- overrides: Partial<FormProductGroup> = {},
461
- ): FormProductGroup => ({
462
- product_uuid: 'prod-1',
463
- product_name: 'Acme Loyalty',
464
- product_description: null,
465
- nominator: null,
466
- purposes: [basePurpose('purp-1', 'Marketing')],
467
- ...overrides,
468
- });
469
-
470
- const setupSession = (email = 'jane@example.com') => {
471
- sessionStorage.setItem('email', email);
472
- };
473
-
474
- const pickRequestType = (value: string) => {
475
- const select = screen.getByTestId('pc-select') as HTMLSelectElement;
476
- fireEvent.change(select, { target: { value } });
477
- };
478
-
479
- const clickProductChip = (groupKey: string) => {
480
- fireEvent.click(screen.getByTestId(`product-chip-${groupKey}`));
481
- };
482
-
483
- describe('Form (P2-SDK-3)', () => {
484
- beforeEach(() => {
485
- createCaseRequest.mockReset();
486
- getFormData.mockReset();
487
- fetchUserConsents.mockReset();
488
- baseUrlStub.ledgerBaseUrl = 'https://ledger.test/consent-ledger';
489
- sessionStorage.clear();
490
- });
491
-
492
- afterEach(() => {
493
- sessionStorage.clear();
494
- });
495
-
496
- it('blocks submit for product-scoped types when the DP has no consent groups', async () => {
497
- // 1-form -> 1-case -> 1-product means product-scoped request types
498
- // (ACCESS/ERASURE/CORRECTION) MUST have a product anchor. When the
499
- // DP has zero consent groups (direct + nominated), the picker shows
500
- // its empty state and submit must be hard-blocked at the validity
501
- // gate so the case can never be created without an anchor.
502
- setupSession();
503
- getFormData.mockResolvedValue(
504
- makeFormData({ direct_groups: [], nominated_groups: [] }),
505
- );
506
-
507
- render(<Form onCreateRequest={vi.fn()} />);
508
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
509
-
510
- pickRequestType(RequestTypeEnum.ERASURE);
511
-
512
- // Confirm checkbox alone is not enough — the validity gate has to
513
- // see at least one product selected.
514
- const confirmCheckbox = (
515
- screen.getAllByRole('checkbox') as HTMLInputElement[]
516
- ).find((c) => c.closest('label')?.textContent?.includes('I confirm'));
517
- expect(confirmCheckbox).toBeTruthy();
518
- fireEvent.click(confirmCheckbox!);
519
-
520
- const submitButton = screen.getByRole(
521
- 'button',
522
- { name: /^submit$/i },
523
- ) as HTMLButtonElement;
524
- expect(submitButton.disabled).toBe(true);
525
- });
526
-
527
- it('skips the ledger picker overlay when no ledgerBaseUrl is configured', async () => {
528
- // Without a ledger, consents still live in Python and the form/data
529
- // groups are authoritative — the overlay must not fire a user-consents
530
- // read (it would hit the legacy endpoint and mis-map its shape).
531
- baseUrlStub.ledgerBaseUrl = undefined;
532
- setupSession();
533
- getFormData.mockResolvedValue(
534
- makeFormData({
535
- direct_groups: [
536
- makeGroup(),
537
- makeGroup({
538
- product_uuid: 'prod-direct-2',
539
- product_name: 'Acme Rewards',
540
- purposes: [basePurpose('purp-2', 'Analytics')],
541
- }),
542
- ],
543
- }),
544
- );
545
-
546
- render(<Form onCreateRequest={vi.fn()} />);
547
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
548
-
549
- pickRequestType(RequestTypeEnum.ERASURE);
550
- await waitFor(() => {
551
- expect(screen.getByText('Acme Loyalty')).toBeInTheDocument();
552
- });
553
- expect(fetchUserConsents).not.toHaveBeenCalled();
554
- });
555
-
556
- it('runs the ledger picker overlay when ledgerBaseUrl is configured', async () => {
557
- setupSession();
558
- getFormData.mockResolvedValue(
559
- makeFormData({ direct_groups: [makeGroup()] }),
560
- );
561
-
562
- render(<Form onCreateRequest={vi.fn()} />);
563
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
564
-
565
- await waitFor(() => expect(fetchUserConsents).toHaveBeenCalled());
566
- });
567
-
568
- it('renders the product step for DSAR types when direct_groups is present', async () => {
569
- setupSession();
570
- const direct = makeGroup({
571
- product_uuid: 'prod-direct',
572
- product_name: 'Acme Loyalty',
573
- });
574
- const second = makeGroup({
575
- product_uuid: 'prod-direct-2',
576
- product_name: 'Acme Rewards',
577
- purposes: [basePurpose('purp-2', 'Analytics')],
578
- });
579
- getFormData.mockResolvedValue(
580
- makeFormData({ direct_groups: [direct, second] }),
581
- );
582
-
583
- render(<Form onCreateRequest={vi.fn()} />);
584
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
585
-
586
- pickRequestType(RequestTypeEnum.ERASURE);
587
-
588
- await waitFor(() => {
589
- expect(screen.getByText('Acme Loyalty')).toBeInTheDocument();
590
- });
591
- expect(screen.getByText('Acme Rewards')).toBeInTheDocument();
592
- expect(
593
- screen.getByText(/Select a product for your erasure request/i),
594
- ).toBeInTheDocument();
595
- });
596
-
597
- it('skips the product selection step when only one consent group exists', async () => {
598
- // TECH-3712 UX: when the DP has exactly one consent group total
599
- // (direct + nominated combined), ProductSelectionSection is friction —
600
- // step 2 must not render at all. The lone group is auto-selected so
601
- // step 3 (per-product purpose picker) renders directly.
602
- setupSession();
603
- const soleGroup = makeGroup({
604
- product_uuid: 'prod-sole',
605
- product_name: 'Acme Loyalty',
606
- purposes: [basePurpose('purp-sole', 'Marketing')],
607
- });
608
- getFormData.mockResolvedValue(
609
- makeFormData({ direct_groups: [soleGroup], nominated_groups: [] }),
610
- );
611
-
612
- render(<Form onCreateRequest={vi.fn()} />);
613
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
614
-
615
- pickRequestType(RequestTypeEnum.ERASURE);
616
-
617
- // Per-product card for the sole group should appear without the user
618
- // touching a product card (auto-selected at Form level).
619
- await waitFor(() => {
620
- expect(
621
- screen.getByTestId('per-product-purposes-prod-sole'),
622
- ).toBeInTheDocument();
623
- });
624
-
625
- // ProductSelectionSection itself must NOT render. The step-2 product
626
- // chip (data-testid `product-chip-prod-sole`) and the step-2 header
627
- // ("Select a product...") are both signals it rendered.
628
- expect(
629
- screen.queryByTestId('product-chip-prod-sole'),
630
- ).not.toBeInTheDocument();
631
- expect(
632
- screen.queryByText(/Select a product/i),
633
- ).not.toBeInTheDocument();
634
-
635
- // Step 3 (per-product purpose picker) is fully wired up: the purpose
636
- // checkbox is present and tickable.
637
- await waitFor(() => {
638
- expect(screen.getByText('Marketing')).toBeInTheDocument();
639
- });
640
- const marketingCheckbox = screen
641
- .getByText('Marketing')
642
- .closest('label')
643
- ?.querySelector('input[type="checkbox"]') as HTMLInputElement | null;
644
- expect(marketingCheckbox).toBeTruthy();
645
- });
646
-
647
- it('skips the product step for nomination and grievance', async () => {
648
- setupSession();
649
- const direct = makeGroup();
650
- getFormData.mockResolvedValue(
651
- makeFormData({
652
- direct_groups: [direct],
653
- grievance_options: [
654
- { value: 'consent_violation', label: 'Consent violation' },
655
- ],
656
- }),
657
- );
658
-
659
- render(<Form onCreateRequest={vi.fn()} />);
660
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
661
-
662
- pickRequestType(RequestTypeEnum.GRIEVANCE);
663
-
664
- await waitFor(() => {
665
- expect(screen.getByTestId('grievance-section')).toBeInTheDocument();
666
- });
667
- expect(
668
- screen.queryByText(/Select a product/i),
669
- ).not.toBeInTheDocument();
670
-
671
- pickRequestType(RequestTypeEnum.NOMINATION);
672
-
673
- await waitFor(() => {
674
- expect(screen.getByTestId('nomination-section')).toBeInTheDocument();
675
- });
676
- expect(
677
- screen.queryByText(/Select a product/i),
678
- ).not.toBeInTheDocument();
679
- });
680
-
681
- it('fires one createCaseRequest with correct anchors on single-product erasure submit', async () => {
682
- setupSession();
683
- const directGroup = makeGroup({
684
- product_uuid: 'prod-direct',
685
- product_name: 'Acme Loyalty',
686
- purposes: [basePurpose('purp-direct', 'Marketing')],
687
- });
688
- const nominatedGroup = makeGroup({
689
- product_uuid: 'prod-nominated',
690
- product_name: 'Partner Bank',
691
- nominator: {
692
- uuid: 'nominator-uuid',
693
- org_user_id: 'org-user-1',
694
- name: 'Alice',
695
- email: 'alice@example.com',
696
- },
697
- purposes: [basePurpose('purp-nominated', 'Analytics')],
698
- });
699
- getFormData.mockResolvedValue(
700
- makeFormData({
701
- direct_groups: [directGroup],
702
- nominated_groups: [nominatedGroup],
703
- }),
704
- );
705
- createCaseRequest.mockResolvedValueOnce({
706
- case_id: 'CASE-1',
707
- uuid: 'uuid-1',
708
- });
709
-
710
- render(<Form onCreateRequest={vi.fn()} />);
711
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
712
-
713
- pickRequestType(RequestTypeEnum.ERASURE);
714
-
715
- await waitFor(() =>
716
- expect(screen.getByText('Acme Loyalty')).toBeInTheDocument(),
717
- );
718
- clickProductChip('prod-direct');
719
-
720
- await waitFor(() => {
721
- expect(
722
- screen.getByTestId('per-product-purposes-prod-direct'),
723
- ).toBeInTheDocument();
724
- });
725
-
726
- const marketingCheckbox = screen
727
- .getByText('Marketing')
728
- .closest('label')
729
- ?.querySelector('input[type="checkbox"]') as HTMLInputElement | null;
730
- expect(marketingCheckbox).toBeTruthy();
731
- fireEvent.click(marketingCheckbox!);
732
-
733
- const allCheckboxes = screen.getAllByRole(
734
- 'checkbox',
735
- ) as HTMLInputElement[];
736
- const confirmCheckbox = allCheckboxes.find((c) =>
737
- c.closest('label')?.textContent?.includes('I confirm'),
738
- );
739
- expect(confirmCheckbox).toBeTruthy();
740
- fireEvent.click(confirmCheckbox!);
741
-
742
- const submitButton = screen.getByRole('button', { name: /^submit$/i });
743
- expect(submitButton).not.toBeDisabled();
744
- await act(async () => {
745
- fireEvent.click(submitButton);
746
- });
747
-
748
- // ERASURE asks whether to also revoke consent before it submits.
749
- // Choosing "Yes" (revokeConsentYes) sets revoke_consent_on_fulfilment=true.
750
- const revokeYesButton = await screen.findByRole('button', { name: 'Yes' });
751
- await act(async () => {
752
- fireEvent.click(revokeYesButton);
753
- });
754
-
755
- await waitFor(() => {
756
- expect(createCaseRequest).toHaveBeenCalledTimes(1);
757
- });
758
-
759
- const payload = createCaseRequest.mock.calls[0][2];
760
- expect(payload.product_uuid).toBe('prod-direct');
761
- expect('data_principal_uuid' in payload).toBe(false);
762
- expect(payload.uuid).toBe('form-session-uuid');
763
- expect(payload.request_type).toBe('erasure');
764
- // The user chose "Yes" in the consent-revoke modal, so the backend's
765
- // auto-revoke task fires when the case is fulfilled (DPDPA Sec 12:
766
- // erasing data implies revoking the consent that authorized
767
- // processing it).
768
- expect(payload.revoke_consent_on_fulfilment).toBe(true);
769
-
770
- await waitFor(() => {
771
- expect(screen.getByTestId('request-submitted')).toBeInTheDocument();
772
- });
773
- });
774
-
775
- it('opens the consent-revoke modal on erasure and sends revoke_consent_on_fulfilment=false when the user declines', async () => {
776
- setupSession();
777
- const directGroup = makeGroup({
778
- product_uuid: 'prod-direct',
779
- product_name: 'Acme Loyalty',
780
- purposes: [basePurpose('purp-direct', 'Marketing')],
781
- });
782
- const nominatedGroup = makeGroup({
783
- product_uuid: 'prod-nominated',
784
- product_name: 'Partner Bank',
785
- nominator: {
786
- uuid: 'nominator-uuid',
787
- org_user_id: 'org-user-1',
788
- name: 'Alice',
789
- email: 'alice@example.com',
790
- },
791
- purposes: [basePurpose('purp-nominated', 'Analytics')],
792
- });
793
- getFormData.mockResolvedValue(
794
- makeFormData({
795
- direct_groups: [directGroup],
796
- nominated_groups: [nominatedGroup],
797
- }),
798
- );
799
- createCaseRequest.mockResolvedValueOnce({
800
- case_id: 'CASE-2',
801
- uuid: 'uuid-2',
802
- });
803
-
804
- render(<Form onCreateRequest={vi.fn()} />);
805
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
806
-
807
- pickRequestType(RequestTypeEnum.ERASURE);
808
-
809
- await waitFor(() =>
810
- expect(screen.getByText('Acme Loyalty')).toBeInTheDocument(),
811
- );
812
- clickProductChip('prod-direct');
813
-
814
- await waitFor(() => {
815
- expect(
816
- screen.getByTestId('per-product-purposes-prod-direct'),
817
- ).toBeInTheDocument();
818
- });
819
-
820
- const marketingCheckbox = screen
821
- .getByText('Marketing')
822
- .closest('label')
823
- ?.querySelector('input[type="checkbox"]') as HTMLInputElement | null;
824
- expect(marketingCheckbox).toBeTruthy();
825
- fireEvent.click(marketingCheckbox!);
826
-
827
- const confirmCheckbox = (
828
- screen.getAllByRole('checkbox') as HTMLInputElement[]
829
- ).find((c) => c.closest('label')?.textContent?.includes('I confirm'));
830
- expect(confirmCheckbox).toBeTruthy();
831
- fireEvent.click(confirmCheckbox!);
832
-
833
- await act(async () => {
834
- fireEvent.click(screen.getByRole('button', { name: /^submit$/i }));
835
- });
836
-
837
- // The consent-revoke modal must appear, and no request fires until the
838
- // user makes a choice. ('Revoke consent?' === revokeConsentModalTitle stub.)
839
- expect(await screen.findByText('Revoke consent?')).toBeInTheDocument();
840
- expect(createCaseRequest).not.toHaveBeenCalled();
841
-
842
- // Declining ('No' === revokeConsentNo) submits with the flag explicitly false.
843
- await act(async () => {
844
- fireEvent.click(screen.getByRole('button', { name: 'No' }));
845
- });
846
-
847
- await waitFor(() => {
848
- expect(createCaseRequest).toHaveBeenCalledTimes(1);
849
- });
850
- const payload = createCaseRequest.mock.calls[0][2];
851
- expect(payload.request_type).toBe('erasure');
852
- expect(payload.revoke_consent_on_fulfilment).toBe(false);
853
- });
854
-
855
- it('switches the inline purpose panel when another product chip is selected', async () => {
856
- setupSession();
857
- const creditCard = makeGroup({
858
- product_uuid: 'prod-cc',
859
- product_name: 'Credit Card',
860
- purposes: [basePurpose('purp-cc', 'Marketing')],
861
- });
862
- const savings = makeGroup({
863
- product_uuid: 'prod-sav',
864
- product_name: 'Savings Account',
865
- purposes: [basePurpose('purp-sav', 'Analytics')],
866
- });
867
- getFormData.mockResolvedValue(
868
- makeFormData({ direct_groups: [creditCard, savings] }),
869
- );
870
-
871
- render(<Form onCreateRequest={vi.fn()} />);
872
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
873
-
874
- pickRequestType(RequestTypeEnum.ERASURE);
875
-
876
- await waitFor(() =>
877
- expect(screen.getByText('Credit Card')).toBeInTheDocument(),
878
- );
879
- clickProductChip('prod-cc');
880
-
881
- const ccPanel = await screen.findByTestId('per-product-purposes-prod-cc');
882
- expect(within(ccPanel).getByText('Credit Card')).toBeInTheDocument();
883
- expect(within(ccPanel).getByText('Marketing')).toBeInTheDocument();
884
- expect(
885
- screen.queryByTestId('per-product-purposes-prod-sav'),
886
- ).not.toBeInTheDocument();
887
-
888
- clickProductChip('prod-sav');
889
-
890
- const savPanel = await screen.findByTestId('per-product-purposes-prod-sav');
891
- expect(within(savPanel).getByText('Savings Account')).toBeInTheDocument();
892
- expect(within(savPanel).getByText('Analytics')).toBeInTheDocument();
893
- expect(
894
- screen.queryByTestId('per-product-purposes-prod-cc'),
895
- ).not.toBeInTheDocument();
896
-
897
- clickProductChip('prod-cc');
898
- await screen.findByTestId('per-product-purposes-prod-cc');
899
- expect(screen.getByText('Marketing')).toBeInTheDocument();
900
- });
901
-
902
- it('disambiguates direct vs nominated chips on the same product via inline panel header', async () => {
903
- setupSession();
904
- const direct = makeGroup({
905
- product_uuid: 'prod-cc',
906
- product_name: 'Credit Card',
907
- purposes: [basePurpose('purp-direct', 'Marketing')],
908
- });
909
- const nominated = makeGroup({
910
- product_uuid: 'prod-cc',
911
- product_name: 'Credit Card',
912
- nominator: {
913
- uuid: 'alice-uuid',
914
- org_user_id: 'org-user-alice',
915
- name: 'Alice',
916
- email: 'alice@example.com',
917
- },
918
- purposes: [basePurpose('purp-nominated', 'Analytics')],
919
- });
920
- getFormData.mockResolvedValue(
921
- makeFormData({
922
- direct_groups: [direct],
923
- nominated_groups: [nominated],
924
- }),
925
- );
926
-
927
- render(<Form onCreateRequest={vi.fn()} />);
928
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
929
-
930
- pickRequestType(RequestTypeEnum.ERASURE);
931
-
932
- await waitFor(() =>
933
- expect(screen.getByTestId('product-chip-prod-cc')).toBeInTheDocument(),
934
- );
935
- clickProductChip('prod-cc');
936
-
937
- const directPanel = await screen.findByTestId(
938
- 'per-product-purposes-prod-cc',
939
- );
940
- expect(within(directPanel).getByText('Credit Card')).toBeInTheDocument();
941
- expect(
942
- within(directPanel).queryByText(/acting on behalf of/i),
943
- ).not.toBeInTheDocument();
944
-
945
- clickProductChip('prod-cc:alice-uuid');
946
-
947
- const nominatedPanel = await screen.findByTestId(
948
- 'per-product-purposes-prod-cc:alice-uuid',
949
- );
950
- expect(within(nominatedPanel).getByText('Credit Card')).toBeInTheDocument();
951
- expect(
952
- within(nominatedPanel).getByText(/acting on behalf of Alice/i),
953
- ).toBeInTheDocument();
954
- });
955
-
956
- it('fires one createCaseRequest with per-product correction_data on single-product correction submit', async () => {
957
- setupSession();
958
- const loyalty = makeGroup({
959
- product_uuid: 'prod-loyalty',
960
- product_name: 'Acme Loyalty',
961
- purposes: [
962
- basePurpose('purp-loyalty', 'Marketing', [
963
- baseDataElement('de-loyalty-email', 'email'),
964
- ]),
965
- ],
966
- });
967
- const rewards = makeGroup({
968
- product_uuid: 'prod-rewards',
969
- product_name: 'Acme Rewards',
970
- purposes: [
971
- basePurpose('purp-rewards', 'Analytics', [
972
- baseDataElement('de-rewards-phone', 'phone'),
973
- ]),
974
- ],
975
- });
976
- getFormData.mockResolvedValue(
977
- makeFormData({
978
- direct_groups: [loyalty, rewards],
979
- purposes: [
980
- {
981
- purpose: basePurpose('purp-loyalty', 'Marketing', [
982
- baseDataElement('de-loyalty-email', 'email'),
983
- ]),
984
- },
985
- {
986
- purpose: basePurpose('purp-rewards', 'Analytics', [
987
- baseDataElement('de-rewards-phone', 'phone'),
988
- ]),
989
- },
990
- ],
991
- }),
992
- );
993
- createCaseRequest.mockResolvedValueOnce({
994
- case_id: 'CASE-1',
995
- uuid: 'uuid-1',
996
- });
997
-
998
- render(<Form onCreateRequest={vi.fn()} />);
999
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
1000
-
1001
- pickRequestType(RequestTypeEnum.CORRECTION);
1002
-
1003
- await waitFor(() =>
1004
- expect(screen.getByText('Acme Loyalty')).toBeInTheDocument(),
1005
- );
1006
- clickProductChip('prod-loyalty');
1007
-
1008
- const loyaltyPanel = await screen.findByTestId(
1009
- 'per-product-purposes-prod-loyalty',
1010
- );
1011
-
1012
- expect(
1013
- within(loyaltyPanel).getByLabelText('correction-de-email'),
1014
- ).toBeInTheDocument();
1015
- expect(
1016
- within(loyaltyPanel).queryByLabelText('correction-de-phone'),
1017
- ).not.toBeInTheDocument();
1018
-
1019
- fireEvent.click(within(loyaltyPanel).getByLabelText('correction-de-email'));
1020
- fireEvent.change(
1021
- within(loyaltyPanel).getByLabelText('correction-current-email'),
1022
- { target: { value: 'old@x.com' } },
1023
- );
1024
- fireEvent.change(
1025
- within(loyaltyPanel).getByLabelText('correction-updated-email'),
1026
- { target: { value: 'new@x.com' } },
1027
- );
1028
-
1029
- const allCheckboxes = screen.getAllByRole(
1030
- 'checkbox',
1031
- ) as HTMLInputElement[];
1032
- const confirmCheckbox = allCheckboxes.find((c) =>
1033
- c.closest('label')?.textContent?.includes('I confirm'),
1034
- );
1035
- expect(confirmCheckbox).toBeTruthy();
1036
- fireEvent.click(confirmCheckbox!);
1037
-
1038
- const submitButton = screen.getByRole('button', { name: /^submit$/i });
1039
- expect(submitButton).not.toBeDisabled();
1040
- await act(async () => {
1041
- fireEvent.click(submitButton);
1042
- });
1043
-
1044
- await waitFor(() => {
1045
- expect(createCaseRequest).toHaveBeenCalledTimes(1);
1046
- });
1047
-
1048
- const payload = createCaseRequest.mock.calls[0][2];
1049
- expect(payload.product_uuid).toBe('prod-loyalty');
1050
- expect(payload.request_type).toBe('correction');
1051
- expect('data_principal_uuid' in payload).toBe(false);
1052
- expect(payload.request_details.purposes).toEqual([]);
1053
- expect(payload.request_details.correction_data).toEqual([
1054
- { name: 'email', curr_value: 'old@x.com', new_value: 'new@x.com' },
1055
- ]);
1056
-
1057
- await waitFor(() => {
1058
- expect(screen.getByTestId('request-submitted')).toBeInTheDocument();
1059
- });
1060
- });
1061
-
1062
- it('submits NOMINATION as an org-level case without product_uuid or data_principal_uuid', async () => {
1063
- // NOMINATION is org-level — the picker is not rendered and the
1064
- // payload must omit `product_uuid` (backend rejects it on these
1065
- // types) AND `data_principal_uuid` (this is a direct grant, not a
1066
- // nominee acting on someone's behalf). Even when the contact has
1067
- // consent groups available, NOMINATION must not leak them onto
1068
- // the case anchor.
1069
- setupSession();
1070
- const direct = makeGroup();
1071
- getFormData.mockResolvedValue(
1072
- makeFormData({ direct_groups: [direct], nominated_groups: [] }),
1073
- );
1074
- createCaseRequest.mockResolvedValueOnce({
1075
- case_id: 'CASE-NOM',
1076
- uuid: 'uuid-nom',
1077
- });
1078
-
1079
- render(<Form onCreateRequest={vi.fn()} />);
1080
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
1081
-
1082
- pickRequestType(RequestTypeEnum.NOMINATION);
1083
-
1084
- await waitFor(() => {
1085
- expect(screen.getByTestId('nomination-section')).toBeInTheDocument();
1086
- });
1087
- // Product picker must not render for NOMINATION even with groups.
1088
- expect(
1089
- screen.queryByText(/Select a product/i),
1090
- ).not.toBeInTheDocument();
1091
-
1092
- const submitButton = screen.getByRole(
1093
- 'button',
1094
- { name: /^submit$/i },
1095
- ) as HTMLButtonElement;
1096
- // Sanity: gate is closed before a valid nominee email is provided.
1097
- expect(submitButton.disabled).toBe(true);
1098
-
1099
- // Drive the form to a valid NOMINATION state via the stubbed
1100
- // nomination input (see vi.mock above).
1101
- const emailInput = screen.getByTestId('nominee-email-input');
1102
- fireEvent.change(emailInput, { target: { value: 'nominee@example.com' } });
1103
-
1104
- const confirmCheckbox = (
1105
- screen.getAllByRole('checkbox') as HTMLInputElement[]
1106
- ).find((c) => c.closest('label')?.textContent?.includes('I confirm'));
1107
- expect(confirmCheckbox).toBeTruthy();
1108
- fireEvent.click(confirmCheckbox!);
1109
-
1110
- await waitFor(() => {
1111
- const btn = screen.getByRole(
1112
- 'button',
1113
- { name: /^submit$/i },
1114
- ) as HTMLButtonElement;
1115
- expect(btn.disabled).toBe(false);
1116
- });
1117
-
1118
- fireEvent.click(
1119
- screen.getByRole('button', { name: /^submit$/i }),
1120
- );
1121
-
1122
- await waitFor(() => expect(createCaseRequest).toHaveBeenCalled());
1123
-
1124
- const payload = createCaseRequest.mock.calls[0][2];
1125
- expect(payload.request_type).toBe('nomination');
1126
- expect(payload).not.toHaveProperty('product_uuid');
1127
- expect(payload).not.toHaveProperty('data_principal_uuid');
1128
- expect(payload.request_details.nomination_data).toMatchObject({
1129
- nominee_email: 'nominee@example.com',
1130
- });
1131
- });
1132
-
1133
- it('sends data_principal_uuid and product anchors on a nominated-card submit', async () => {
1134
- setupSession();
1135
- const otherDirect = makeGroup({
1136
- product_uuid: 'prod-other',
1137
- product_name: 'Other Product',
1138
- purposes: [basePurpose('purp-other', 'Other')],
1139
- });
1140
- const nominated = makeGroup({
1141
- product_uuid: 'prod-cc',
1142
- product_name: 'Credit Card',
1143
- nominator: {
1144
- uuid: 'alice-uuid',
1145
- org_user_id: 'org-user-alice',
1146
- name: 'Alice',
1147
- email: 'alice@example.com',
1148
- },
1149
- purposes: [basePurpose('purp-nominated', 'Analytics')],
1150
- });
1151
- getFormData.mockResolvedValue(
1152
- makeFormData({
1153
- direct_groups: [otherDirect],
1154
- nominated_groups: [nominated],
1155
- }),
1156
- );
1157
- createCaseRequest.mockResolvedValueOnce({
1158
- case_id: 'CASE-NOMINATED',
1159
- uuid: 'uuid-nominated',
1160
- });
1161
-
1162
- render(<Form onCreateRequest={vi.fn()} />);
1163
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
1164
-
1165
- pickRequestType(RequestTypeEnum.ERASURE);
1166
-
1167
- await waitFor(() =>
1168
- expect(
1169
- screen.getByTestId('product-chip-prod-cc:alice-uuid'),
1170
- ).toBeInTheDocument(),
1171
- );
1172
- clickProductChip('prod-cc:alice-uuid');
1173
-
1174
- const nominatedPanel = await screen.findByTestId(
1175
- 'per-product-purposes-prod-cc:alice-uuid',
1176
- );
1177
- fireEvent.click(
1178
- within(nominatedPanel)
1179
- .getByText('Analytics')
1180
- .closest('label')!
1181
- .querySelector('input[type="checkbox"]')!,
1182
- );
1183
-
1184
- const confirmCheckbox = (
1185
- screen.getAllByRole('checkbox') as HTMLInputElement[]
1186
- ).find((c) => c.closest('label')?.textContent?.includes('I confirm'));
1187
- fireEvent.click(confirmCheckbox!);
1188
-
1189
- await act(async () => {
1190
- fireEvent.click(screen.getByRole('button', { name: /^submit$/i }));
1191
- });
1192
-
1193
- // ERASURE routes through the consent-revoke modal before submitting.
1194
- await act(async () => {
1195
- fireEvent.click(await screen.findByRole('button', { name: 'Yes' }));
1196
- });
1197
-
1198
- await waitFor(() => {
1199
- expect(createCaseRequest).toHaveBeenCalledTimes(1);
1200
- });
1201
-
1202
- const payload = createCaseRequest.mock.calls[0][2];
1203
- expect(payload.product_uuid).toBe('prod-cc');
1204
- // Nominated cards send data_principal_uuid sourced from the
1205
- // nominator's ConsentUser uuid — NOT from formData.uuid.
1206
- expect(payload.data_principal_uuid).toBe('alice-uuid');
1207
-
1208
- await waitFor(() => {
1209
- expect(screen.getByTestId('request-submitted')).toBeInTheDocument();
1210
- });
1211
- expect(
1212
- screen.getByTestId('request-submitted-product-uuid').textContent,
1213
- ).toBe('prod-cc');
1214
- expect(
1215
- screen.getByTestId('request-submitted-case-id').textContent,
1216
- ).toBe('CASE-NOMINATED');
1217
- });
1218
-
1219
- it('disables submit when the selected CORRECTION product has incomplete entries', async () => {
1220
- setupSession();
1221
- const loyalty = makeGroup({
1222
- product_uuid: 'prod-loyalty',
1223
- product_name: 'Acme Loyalty',
1224
- purposes: [
1225
- basePurpose('purp-loyalty', 'Marketing', [
1226
- baseDataElement('de-loyalty-email', 'email'),
1227
- ]),
1228
- ],
1229
- });
1230
- const rewards = makeGroup({
1231
- product_uuid: 'prod-rewards',
1232
- product_name: 'Acme Rewards',
1233
- purposes: [
1234
- basePurpose('purp-rewards', 'Analytics', [
1235
- baseDataElement('de-rewards-phone', 'phone'),
1236
- ]),
1237
- ],
1238
- });
1239
- getFormData.mockResolvedValue(
1240
- makeFormData({ direct_groups: [loyalty, rewards] }),
1241
- );
1242
-
1243
- render(<Form onCreateRequest={vi.fn()} />);
1244
- await waitFor(() => expect(getFormData).toHaveBeenCalled());
1245
-
1246
- pickRequestType(RequestTypeEnum.CORRECTION);
1247
-
1248
- await waitFor(() =>
1249
- expect(screen.getByText('Acme Loyalty')).toBeInTheDocument(),
1250
- );
1251
- clickProductChip('prod-loyalty');
1252
-
1253
- const loyaltyPanel = await screen.findByTestId(
1254
- 'per-product-purposes-prod-loyalty',
1255
- );
1256
-
1257
- const allCheckboxes = screen.getAllByRole(
1258
- 'checkbox',
1259
- ) as HTMLInputElement[];
1260
- const confirmCheckbox = allCheckboxes.find((c) =>
1261
- c.closest('label')?.textContent?.includes('I confirm'),
1262
- );
1263
- expect(confirmCheckbox).toBeTruthy();
1264
- fireEvent.click(confirmCheckbox!);
1265
-
1266
- const submitButton = screen.getByRole(
1267
- 'button',
1268
- { name: /^submit$/i },
1269
- ) as HTMLButtonElement;
1270
- expect(submitButton.disabled).toBe(true);
1271
-
1272
- fireEvent.click(within(loyaltyPanel).getByLabelText('correction-de-email'));
1273
- fireEvent.change(
1274
- within(loyaltyPanel).getByLabelText('correction-current-email'),
1275
- { target: { value: 'old@x.com' } },
1276
- );
1277
- fireEvent.change(
1278
- within(loyaltyPanel).getByLabelText('correction-updated-email'),
1279
- { target: { value: 'new@x.com' } },
1280
- );
1281
-
1282
- expect(
1283
- (screen.getByRole('button', { name: /^submit$/i }) as HTMLButtonElement)
1284
- .disabled,
1285
- ).toBe(false);
1286
- });
1287
- });