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

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 (259) hide show
  1. package/NOTICE.md +17 -0
  2. package/README.md +67 -3
  3. package/dist/chunk-FEGTW73Q.mjs +182 -0
  4. package/dist/fonts.d.mts +35 -0
  5. package/dist/fonts.d.ts +35 -0
  6. package/dist/fonts.js +183 -0
  7. package/dist/fonts.mjs +10 -0
  8. package/dist/index.d.mts +12 -1
  9. package/dist/index.d.ts +12 -1
  10. package/dist/index.js +613 -249
  11. package/dist/index.mjs +235 -85
  12. package/dist/montserrat.generated-NBTECYRW.mjs +22 -0
  13. package/dist/types-6Aj7faxL.d.mts +57 -0
  14. package/dist/types-6Aj7faxL.d.ts +57 -0
  15. package/package.json +10 -1
  16. package/.turbo/turbo-build.log +0 -22
  17. package/.turbo/turbo-test.log +0 -203
  18. package/.turbo/turbo-verify-pack.log +0 -6
  19. package/CHANGELOG.md +0 -383
  20. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +0 -934
  21. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +0 -2160
  22. package/src/RedactoNoticeAssisted/api/index.ts +0 -275
  23. package/src/RedactoNoticeAssisted/api/types.ts +0 -182
  24. package/src/RedactoNoticeAssisted/assets/redacto-logo.png +0 -0
  25. package/src/RedactoNoticeAssisted/constants.ts +0 -51
  26. package/src/RedactoNoticeAssisted/i18n.ts +0 -1408
  27. package/src/RedactoNoticeAssisted/index.ts +0 -1
  28. package/src/RedactoNoticeAssisted/injectStyles.ts +0 -251
  29. package/src/RedactoNoticeAssisted/styles.ts +0 -730
  30. package/src/RedactoNoticeAssisted/types.ts +0 -26
  31. package/src/RedactoNoticeAssisted/useMediaQuery.ts +0 -36
  32. package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +0 -1186
  33. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +0 -4299
  34. package/src/RedactoNoticeConsent/api/index.ts +0 -486
  35. package/src/RedactoNoticeConsent/api/sandbox.ts +0 -150
  36. package/src/RedactoNoticeConsent/api/types.ts +0 -505
  37. package/src/RedactoNoticeConsent/assets/redacto-logo.png +0 -0
  38. package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +0 -602
  39. package/src/RedactoNoticeConsent/components/index.ts +0 -7
  40. package/src/RedactoNoticeConsent/constants.ts +0 -20
  41. package/src/RedactoNoticeConsent/index.ts +0 -1
  42. package/src/RedactoNoticeConsent/injectStyles.ts +0 -151
  43. package/src/RedactoNoticeConsent/language-codes.ts +0 -95
  44. package/src/RedactoNoticeConsent/services/storage.ts +0 -122
  45. package/src/RedactoNoticeConsent/styles.ts +0 -409
  46. package/src/RedactoNoticeConsent/types.ts +0 -80
  47. package/src/RedactoNoticeConsent/useMediaQuery.ts +0 -36
  48. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.test.tsx +0 -369
  49. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +0 -709
  50. package/src/RedactoNoticeConsentInline/api/index.ts +0 -115
  51. package/src/RedactoNoticeConsentInline/api/notice-read-routing.test.ts +0 -72
  52. package/src/RedactoNoticeConsentInline/api/types.ts +0 -185
  53. package/src/RedactoNoticeConsentInline/assets/redacto-logo.png +0 -0
  54. package/src/RedactoNoticeConsentInline/index.ts +0 -1
  55. package/src/RedactoNoticeConsentInline/injectStyles.ts +0 -40
  56. package/src/RedactoNoticeConsentInline/styles.ts +0 -397
  57. package/src/RedactoNoticeConsentInline/types.ts +0 -51
  58. package/src/RedactoNoticeConsentInline/useMediaQuery.ts +0 -36
  59. package/src/RedactoPrivacyCenter/NotificationsPage.tsx +0 -182
  60. package/src/RedactoPrivacyCenter/PrivacyCenterActivityPage.tsx +0 -19
  61. package/src/RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage.tsx +0 -156
  62. package/src/RedactoPrivacyCenter/PrivacyCenterConsentManagerPage.tsx +0 -17
  63. package/src/RedactoPrivacyCenter/PrivacyCenterFormPage.tsx +0 -79
  64. package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +0 -36
  65. package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +0 -177
  66. package/src/RedactoPrivacyCenter/PrivacyCenterMyReceiptPage.tsx +0 -26
  67. package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +0 -93
  68. package/src/RedactoPrivacyCenter/api/actions.ts +0 -682
  69. package/src/RedactoPrivacyCenter/api/client.ts +0 -1003
  70. package/src/RedactoPrivacyCenter/api/config.ts +0 -33
  71. package/src/RedactoPrivacyCenter/api/fetcher.ts +0 -275
  72. package/src/RedactoPrivacyCenter/api/orgBranding.ts +0 -16
  73. package/src/RedactoPrivacyCenter/api/upload.ts +0 -93
  74. package/src/RedactoPrivacyCenter/assets/character.svg +0 -31
  75. package/src/RedactoPrivacyCenter/assets/fileAttach.svg +0 -9
  76. package/src/RedactoPrivacyCenter/assets/greenTick.svg +0 -4
  77. package/src/RedactoPrivacyCenter/assets/mail.svg +0 -3
  78. package/src/RedactoPrivacyCenter/assets/poweredByRedacto.svg +0 -9
  79. package/src/RedactoPrivacyCenter/assets/sentImg.svg +0 -9
  80. package/src/RedactoPrivacyCenter/assets/uploadFileIcon.svg +0 -9
  81. package/src/RedactoPrivacyCenter/components/ActivitiesList.tsx +0 -252
  82. package/src/RedactoPrivacyCenter/components/ActivityTimeline.tsx +0 -239
  83. package/src/RedactoPrivacyCenter/components/AppShell/AppShell.tsx +0 -268
  84. package/src/RedactoPrivacyCenter/components/AppShell/MobileNavDrawer.tsx +0 -218
  85. package/src/RedactoPrivacyCenter/components/AppShell/NavItem.tsx +0 -205
  86. package/src/RedactoPrivacyCenter/components/AppShell/PageHeader.tsx +0 -107
  87. package/src/RedactoPrivacyCenter/components/AppShell/SidebarNav.tsx +0 -100
  88. package/src/RedactoPrivacyCenter/components/AppShell/TopAppBar.tsx +0 -339
  89. package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +0 -245
  90. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useIsTruncated.ts +0 -28
  91. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useKeyboardShortcut.ts +0 -40
  92. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useSidebarState.ts +0 -62
  93. package/src/RedactoPrivacyCenter/components/AppShell/usePrivacyCenterExitAction.ts +0 -36
  94. package/src/RedactoPrivacyCenter/components/CaseDetails/AttachmentCard.tsx +0 -38
  95. package/src/RedactoPrivacyCenter/components/CaseDetails/ChatBubble.tsx +0 -31
  96. package/src/RedactoPrivacyCenter/components/CaseDetails/DocumentRequestCard.tsx +0 -79
  97. package/src/RedactoPrivacyCenter/components/CaseDetails/FinalizedTooltipWrapper.tsx +0 -25
  98. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageComposer.tsx +0 -96
  99. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageItem.tsx +0 -97
  100. package/src/RedactoPrivacyCenter/components/CaseDetails/MessagesTab.tsx +0 -156
  101. package/src/RedactoPrivacyCenter/components/CaseDetails/RequestDetailsTab.tsx +0 -171
  102. package/src/RedactoPrivacyCenter/components/CaseDetails/StatusEvent.tsx +0 -23
  103. package/src/RedactoPrivacyCenter/components/CaseDetails/useFileUpload.ts +0 -116
  104. package/src/RedactoPrivacyCenter/components/CaseDetails/useMessagePolling.ts +0 -43
  105. package/src/RedactoPrivacyCenter/components/CaseDetails/utils.ts +0 -71
  106. package/src/RedactoPrivacyCenter/components/CaseDetailsModal.tsx +0 -469
  107. package/src/RedactoPrivacyCenter/components/CaseHistory.tsx +0 -426
  108. package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +0 -1199
  109. package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +0 -201
  110. package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +0 -138
  111. package/src/RedactoPrivacyCenter/components/ConsentManagerConstants.ts +0 -7
  112. package/src/RedactoPrivacyCenter/components/ConsentManagerExpandedRow.tsx +0 -179
  113. package/src/RedactoPrivacyCenter/components/ConsentManagerGroupedColumns.tsx +0 -318
  114. package/src/RedactoPrivacyCenter/components/ConsentManagerProductCards.tsx +0 -333
  115. package/src/RedactoPrivacyCenter/components/ConsentManagerPurposeCards.tsx +0 -102
  116. package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +0 -159
  117. package/src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection.tsx +0 -189
  118. package/src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection.tsx +0 -118
  119. package/src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection.tsx +0 -66
  120. package/src/RedactoPrivacyCenter/components/DataRequest/ProductSelectionSection.tsx +0 -222
  121. package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +0 -331
  122. package/src/RedactoPrivacyCenter/components/Form.tsx +0 -1821
  123. package/src/RedactoPrivacyCenter/components/GrievanceTable.tsx +0 -174
  124. package/src/RedactoPrivacyCenter/components/GrievanceTablePagination.tsx +0 -337
  125. package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +0 -334
  126. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationBell.tsx +0 -173
  127. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationCTAButton.tsx +0 -18
  128. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdown.tsx +0 -54
  129. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdownItem.tsx +0 -57
  130. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationIcon.tsx +0 -19
  131. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationListPanel.tsx +0 -92
  132. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRefreshButton.tsx +0 -20
  133. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRow.tsx +0 -58
  134. package/src/RedactoPrivacyCenter/components/NotificationHub/StatCard.tsx +0 -10
  135. package/src/RedactoPrivacyCenter/components/NotificationHub/useNotificationActions.ts +0 -112
  136. package/src/RedactoPrivacyCenter/components/NotificationHub/utils.ts +0 -27
  137. package/src/RedactoPrivacyCenter/components/Pagination.tsx +0 -140
  138. package/src/RedactoPrivacyCenter/components/PrivacyCenterEmptyState.tsx +0 -76
  139. package/src/RedactoPrivacyCenter/components/PrivacyCenterSessionExpired.tsx +0 -97
  140. package/src/RedactoPrivacyCenter/components/ReceiptsList.tsx +0 -454
  141. package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +0 -270
  142. package/src/RedactoPrivacyCenter/components/SelectUser.tsx +0 -95
  143. package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +0 -195
  144. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +0 -25
  145. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/types.ts +0 -21
  146. package/src/RedactoPrivacyCenter/components/caseHistoryColumns.tsx +0 -159
  147. package/src/RedactoPrivacyCenter/components/constant.ts +0 -52
  148. package/src/RedactoPrivacyCenter/components/groupHelpers.ts +0 -155
  149. package/src/RedactoPrivacyCenter/components/receiptColumns.tsx +0 -203
  150. package/src/RedactoPrivacyCenter/components/types.ts +0 -123
  151. package/src/RedactoPrivacyCenter/components/utils.tsx +0 -10
  152. package/src/RedactoPrivacyCenter/config/routes.ts +0 -9
  153. package/src/RedactoPrivacyCenter/config/table.ts +0 -25
  154. package/src/RedactoPrivacyCenter/context/AuthContext.tsx +0 -252
  155. package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +0 -47
  156. package/src/RedactoPrivacyCenter/context/BrandingContext.tsx +0 -52
  157. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.session-expired.test.tsx +0 -92
  158. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.tsx +0 -181
  159. package/src/RedactoPrivacyCenter/context/LocaleContext.tsx +0 -11
  160. package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +0 -96
  161. package/src/RedactoPrivacyCenter/context/OrganizationContext.tsx +0 -30
  162. package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +0 -80
  163. package/src/RedactoPrivacyCenter/context/ProfileSwitchContext.tsx +0 -15
  164. package/src/RedactoPrivacyCenter/context/types.ts +0 -57
  165. package/src/RedactoPrivacyCenter/lib/api.ts +0 -759
  166. package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +0 -67
  167. package/src/RedactoPrivacyCenter/lib/constants.ts +0 -283
  168. package/src/RedactoPrivacyCenter/lib/i18n.ts +0 -81
  169. package/src/RedactoPrivacyCenter/lib/locales.ts +0 -102
  170. package/src/RedactoPrivacyCenter/lib/queries.ts +0 -141
  171. package/src/RedactoPrivacyCenter/lib/sandbox.ts +0 -104
  172. package/src/RedactoPrivacyCenter/lib/types.ts +0 -892
  173. package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +0 -37
  174. package/src/RedactoPrivacyCenter/lib/utils.refresh-circuit.test.ts +0 -127
  175. package/src/RedactoPrivacyCenter/lib/utils.refresh-storage.test.ts +0 -85
  176. package/src/RedactoPrivacyCenter/lib/utils.session-expired.test.ts +0 -109
  177. package/src/RedactoPrivacyCenter/lib/utils.ts +0 -798
  178. package/src/RedactoPrivacyCenter/locales/as/translation.json +0 -340
  179. package/src/RedactoPrivacyCenter/locales/bn/translation.json +0 -340
  180. package/src/RedactoPrivacyCenter/locales/brx/translation.json +0 -340
  181. package/src/RedactoPrivacyCenter/locales/doi/translation.json +0 -340
  182. package/src/RedactoPrivacyCenter/locales/en/translation.json +0 -355
  183. package/src/RedactoPrivacyCenter/locales/gom/translation.json +0 -340
  184. package/src/RedactoPrivacyCenter/locales/gu/translation.json +0 -340
  185. package/src/RedactoPrivacyCenter/locales/hi/translation.json +0 -343
  186. package/src/RedactoPrivacyCenter/locales/kn/translation.json +0 -340
  187. package/src/RedactoPrivacyCenter/locales/ks/translation.json +0 -340
  188. package/src/RedactoPrivacyCenter/locales/mai/translation.json +0 -340
  189. package/src/RedactoPrivacyCenter/locales/ml/translation.json +0 -340
  190. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +0 -340
  191. package/src/RedactoPrivacyCenter/locales/mr/translation.json +0 -340
  192. package/src/RedactoPrivacyCenter/locales/ne/translation.json +0 -340
  193. package/src/RedactoPrivacyCenter/locales/or/translation.json +0 -340
  194. package/src/RedactoPrivacyCenter/locales/pa/translation.json +0 -340
  195. package/src/RedactoPrivacyCenter/locales/sa/translation.json +0 -340
  196. package/src/RedactoPrivacyCenter/locales/sat/translation.json +0 -340
  197. package/src/RedactoPrivacyCenter/locales/sd/translation.json +0 -340
  198. package/src/RedactoPrivacyCenter/locales/ta/translation.json +0 -340
  199. package/src/RedactoPrivacyCenter/locales/te/translation.json +0 -340
  200. package/src/RedactoPrivacyCenter/locales/ur/translation.json +0 -340
  201. package/src/RedactoPrivacyCenter/styles/applyBrandingTheme.ts +0 -66
  202. package/src/RedactoPrivacyCenter/styles/base.css +0 -117
  203. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +0 -3108
  204. package/src/RedactoPrivacyCenter/styles/pcStyles.ts +0 -831
  205. package/src/RedactoPrivacyCenter/styles/responsive.ts +0 -138
  206. package/src/RedactoPrivacyCenter/styles/variables.css +0 -96
  207. package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +0 -387
  208. package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +0 -468
  209. package/src/RedactoPrivacyCenter/table/index.ts +0 -2
  210. package/src/RedactoPrivacyCenter/types/images.d.ts +0 -29
  211. package/src/RedactoPrivacyCenter/ui/Footer.tsx +0 -69
  212. package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +0 -54
  213. package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +0 -93
  214. package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +0 -47
  215. package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +0 -83
  216. package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +0 -93
  217. package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +0 -48
  218. package/src/RedactoPrivacyCenter/ui/PCButton.tsx +0 -77
  219. package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +0 -55
  220. package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +0 -107
  221. package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +0 -35
  222. package/src/RedactoPrivacyCenter/ui/PCInput.tsx +0 -132
  223. package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +0 -31
  224. package/src/RedactoPrivacyCenter/ui/PCModal.tsx +0 -106
  225. package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +0 -206
  226. package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +0 -433
  227. package/src/RedactoPrivacyCenter/ui/PCTable.tsx +0 -149
  228. package/src/RedactoPrivacyCenter/ui/PCText.tsx +0 -41
  229. package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +0 -43
  230. package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +0 -37
  231. package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +0 -121
  232. package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +0 -25
  233. package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +0 -53
  234. package/src/RedactoPrivacyCenter/ui/index.ts +0 -18
  235. package/src/RedactoPrivacyCenter/utils/cn.ts +0 -28
  236. package/src/RedactoPrivacyCenter/utils/date.ts +0 -48
  237. package/src/RedactoPrivacyCenter/utils/status.ts +0 -111
  238. package/src/RedactoPrivacyCenter/utils/toast.ts +0 -130
  239. package/src/index.ts +0 -19
  240. package/src/privacy-center.ts +0 -113
  241. package/src/shared/api-errors.ts +0 -180
  242. package/src/shared/notice-consent-status.ts +0 -190
  243. package/src/shared/sandbox.ts +0 -6
  244. package/src/types/css.d.ts +0 -4
  245. package/src/types/images.d.ts +0 -19
  246. package/src/types/react-jsx.d.ts +0 -26
  247. package/tests/DataAvailabilityContext.test.tsx +0 -123
  248. package/tests/Form.test.tsx +0 -1424
  249. package/tests/ProductSelectionSection.test.tsx +0 -328
  250. package/tests/RequestSubmit.test.tsx +0 -135
  251. package/tests/RevokeWarningMessage.test.tsx +0 -151
  252. package/tests/consentClient.test.ts +0 -217
  253. package/tests/manageConsentServer.test.ts +0 -38
  254. package/tests/mocks.ts +0 -257
  255. package/tests/resolveContactFromJwt.test.ts +0 -44
  256. package/tests/setup.ts +0 -16
  257. package/tsconfig.json +0 -16
  258. package/tsup.config.ts +0 -31
  259. package/vitest.config.ts +0 -16
@@ -1,1186 +0,0 @@
1
- import "@testing-library/jest-dom";
2
- import {
3
- act,
4
- fireEvent,
5
- render,
6
- screen,
7
- waitFor,
8
- } from "@testing-library/react";
9
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
10
- import {
11
- defaultProps,
12
- mockConsentContent,
13
- mockMagicLinkContent,
14
- mockMinorConsentContent,
15
- mockReconsentContent,
16
- } from "../../tests/mocks";
17
- import { RedactoNoticeConsent } from "./RedactoNoticeConsent";
18
- import * as api from "./api";
19
- import type { ConsentContent } from "./api/types";
20
-
21
- // Mock the API functions
22
- vi.mock("./api", () => ({
23
- fetchConsentContent: vi.fn(),
24
- submitConsentEvent: vi.fn(),
25
- clearApiCache: vi.fn(),
26
- fetchTTSAudioUrls: vi.fn(),
27
- initiateGuardianVerification: vi.fn(),
28
- verifyGuardianStatus: vi.fn(),
29
- }));
30
-
31
- // Mock jwt-decode
32
- vi.mock("jwt-decode", () => ({
33
- jwtDecode: vi.fn(() => ({
34
- organisation_uuid: "org-123",
35
- workspace_uuid: "workspace-123",
36
- user_uuid: "user-123",
37
- })),
38
- }));
39
-
40
- // Mock the logo import correctly for ES modules
41
- vi.mock("./assets/redacto-logo.png", () => ({
42
- default: "mocked-logo.png",
43
- }));
44
-
45
- // Mock injectCheckboxStyles to avoid DOM manipulation in tests
46
- vi.mock("./injectStyles", () => ({
47
- injectCheckboxStyles: vi.fn(),
48
- }));
49
-
50
- // Mock storage service
51
- vi.mock("./services/storage", () => ({
52
- saveConsentState: vi.fn(),
53
- getConsentState: vi.fn(() => null),
54
- clearConsentState: vi.fn(),
55
- updateConsentState: vi.fn(),
56
- hasPendingVerification: vi.fn(() => false),
57
- getVerificationResult: vi.fn(() => null),
58
- getVerificationReference: vi.fn(() => null),
59
- }));
60
-
61
- // Mock window.open for popup tests
62
- const mockWindowOpen = vi.fn(() => ({
63
- closed: false,
64
- focus: vi.fn(),
65
- close: vi.fn(),
66
- }));
67
- Object.defineProperty(window, 'open', {
68
- writable: true,
69
- value: mockWindowOpen,
70
- });
71
-
72
- describe("RedactoNoticeConsent", () => {
73
- const mockedApi = vi.mocked(api);
74
-
75
- const setupCommonMocks = () => {
76
- // Mock API calls synchronously to avoid act() warnings
77
- mockedApi.fetchConsentContent.mockResolvedValue(mockConsentContent);
78
- mockedApi.submitConsentEvent.mockResolvedValue(undefined);
79
- // Mock TTS audio URLs API
80
- mockedApi.fetchTTSAudioUrls.mockResolvedValue({
81
- code: 200,
82
- status: "success",
83
- detail: {
84
- uuid: "notice-123",
85
- language: "en",
86
- notice_text_audio_url: "",
87
- additional_text_audio_url: "",
88
- notice_summary_audio_url: "",
89
- confirm_button_text_audio_url: "",
90
- decline_button_text_audio_url: "",
91
- privacy_policy_prefix_text_audio_url: "",
92
- privacy_policy_anchor_text_audio_url: "",
93
- purpose_section_heading_audio_url: "",
94
- notice_banner_heading_audio_url: "",
95
- purposes_audio: {
96
- "purpose-1": { name_audio_url: "", description_audio_url: "" },
97
- "purpose-2": { name_audio_url: "", description_audio_url: "" },
98
- },
99
- data_elements_audio: {},
100
- },
101
- });
102
- // Mock guardian verification APIs (DigiLocker flow)
103
- mockedApi.initiateGuardianVerification.mockResolvedValue({
104
- success: true,
105
- already_verified: false,
106
- session_token: "gvs_test-session-token",
107
- digilocker_redirect_url: "https://digilocker.example.com/authorize?session=xyz",
108
- expires_at: new Date(Date.now() + 600000).toISOString(),
109
- guardian_info_uuid: "test-guardian-uuid",
110
- });
111
- mockedApi.verifyGuardianStatus.mockResolvedValue({
112
- status: "verified" as const,
113
- guardian_info_uuid: "test-guardian-uuid",
114
- verification_reference: "VER_ABC123",
115
- guardian_details: {
116
- verified_name: "John Doe",
117
- is_guardian_adult: true,
118
- verified_at: new Date().toISOString(),
119
- verification_reference: "VER_ABC123",
120
- },
121
- error: null,
122
- error_code: null,
123
- can_retry: false,
124
- });
125
- };
126
-
127
- beforeEach(() => {
128
- vi.resetAllMocks();
129
- mockWindowOpen.mockClear();
130
- setupCommonMocks();
131
- });
132
-
133
- afterEach(() => {
134
- vi.clearAllMocks();
135
- });
136
-
137
- it("renders loading state initially", () => {
138
- act(() => {
139
- render(<RedactoNoticeConsent {...defaultProps} />);
140
- });
141
- expect(screen.getByText("Loading...")).toBeInTheDocument();
142
- });
143
-
144
- it("renders consent content after loading", async () => {
145
- await act(async () => {
146
- render(<RedactoNoticeConsent {...defaultProps} />);
147
- });
148
- await waitFor(
149
- () => {
150
- expect(screen.getByText("Privacy Notice")).toBeInTheDocument();
151
- expect(
152
- screen.getByText(/We care about your privacy/i)
153
- ).toBeInTheDocument();
154
- expect(
155
- screen.getByRole("link", { name: /Privacy Policy/i })
156
- ).toBeInTheDocument();
157
- expect(screen.getByText("Marketing")).toBeInTheDocument();
158
- },
159
- { timeout: 3000 }
160
- );
161
- });
162
-
163
- it("displays logo from content", async () => {
164
- const { unmount } = render(<RedactoNoticeConsent {...defaultProps} />);
165
- await waitFor(
166
- () => {
167
- const logo = screen.getByAltText("Redacto Logo");
168
- expect(logo).toHaveAttribute("src", "https://example.com/logo.png");
169
- },
170
- { timeout: 3000 }
171
- );
172
- unmount();
173
- });
174
-
175
- it("displays fallback logo when no content logo provided", async () => {
176
- const noLogoContent: ConsentContent = {
177
- ...mockConsentContent,
178
- detail: {
179
- ...mockConsentContent.detail,
180
- active_config: {
181
- ...mockConsentContent.detail.active_config,
182
- logo_url: "",
183
- },
184
- },
185
- };
186
- mockedApi.fetchConsentContent.mockResolvedValueOnce(noLogoContent);
187
- const { unmount } = render(<RedactoNoticeConsent {...defaultProps} />);
188
- await waitFor(
189
- () => {
190
- const logo = screen.getByAltText("Redacto Logo");
191
- expect(logo).toHaveAttribute("src", "mocked-logo.png");
192
- },
193
- { timeout: 3000 }
194
- );
195
- unmount();
196
- });
197
-
198
- it("handles language selection", async () => {
199
- await act(async () => {
200
- render(<RedactoNoticeConsent {...defaultProps} />);
201
- });
202
- await waitFor(
203
- () => {
204
- expect(screen.getByRole("button", { name: "en" })).toBeInTheDocument();
205
- },
206
- { timeout: 3000 }
207
- );
208
-
209
- await act(async () => {
210
- fireEvent.click(screen.getByRole("button", { name: "en" }));
211
- });
212
- await waitFor(
213
- () => {
214
- expect(screen.getByRole("option", { name: "es" })).toBeInTheDocument();
215
- },
216
- { timeout: 3000 }
217
- );
218
- await act(async () => {
219
- fireEvent.click(screen.getByText("es"));
220
- });
221
-
222
- await waitFor(
223
- () => {
224
- expect(
225
- screen.getByText(/Nos importa tu privacidad/i)
226
- ).toBeInTheDocument();
227
- expect(
228
- screen.getByText("[Política de Privacidad]")
229
- ).toBeInTheDocument();
230
- expect(
231
- screen.getByText("Gestionar Consentimiento")
232
- ).toBeInTheDocument();
233
- },
234
- { timeout: 3000 }
235
- );
236
- });
237
-
238
- it("toggles purpose collapse", async () => {
239
- render(<RedactoNoticeConsent {...defaultProps} />);
240
- await waitFor(
241
- () => {
242
- expect(screen.getByText("Marketing")).toBeInTheDocument();
243
- },
244
- { timeout: 3000 }
245
- );
246
-
247
- const marketingHeading = screen.getByText("Marketing");
248
- const collapseDiv = marketingHeading
249
- .closest('div[style*="cursor: pointer"]')
250
- ?.querySelector("svg");
251
- if (!collapseDiv) throw new Error("Collapse div not found");
252
-
253
- await act(async () => {
254
- fireEvent.click(collapseDiv);
255
- });
256
- await waitFor(
257
- () => {
258
- expect(screen.getByText("Email")).toBeInTheDocument();
259
- expect(screen.getByText("Phone")).toBeInTheDocument();
260
- },
261
- { timeout: 3000 }
262
- );
263
-
264
- await act(async () => {
265
- fireEvent.click(collapseDiv);
266
- });
267
- await waitFor(
268
- () => {
269
- expect(screen.queryByText("Email")).not.toBeInTheDocument();
270
- },
271
- { timeout: 3000 }
272
- );
273
- });
274
-
275
- it("handles purpose checkbox interaction", async () => {
276
- render(<RedactoNoticeConsent {...defaultProps} />);
277
- await waitFor(
278
- () => {
279
- expect(screen.getByText("Marketing")).toBeInTheDocument();
280
- },
281
- { timeout: 3000 }
282
- );
283
-
284
- const marketingHeading = screen.getByText("Marketing");
285
- const purposeCheckbox = marketingHeading
286
- .closest('div[style*="justify-content: space-between"]')
287
- ?.querySelector('input[type="checkbox"]');
288
- if (!purposeCheckbox) throw new Error("Purpose checkbox not found");
289
-
290
- expect(purposeCheckbox).not.toBeChecked();
291
- await act(async () => {
292
- fireEvent.click(purposeCheckbox);
293
- });
294
- expect(purposeCheckbox).toBeChecked();
295
-
296
- await act(async () => {
297
- fireEvent.click(purposeCheckbox);
298
- });
299
- expect(purposeCheckbox).not.toBeChecked();
300
- });
301
-
302
- it("disables required data element checkboxes", async () => {
303
- await act(async () => {
304
- render(<RedactoNoticeConsent {...defaultProps} />);
305
- });
306
- await waitFor(
307
- () => {
308
- expect(screen.getByText("Marketing")).toBeInTheDocument();
309
- },
310
- { timeout: 3000 }
311
- );
312
-
313
- const marketingHeading = screen.getByText("Marketing");
314
- const collapseDiv = marketingHeading
315
- .closest('div[style*="cursor: pointer"]')
316
- ?.querySelector("svg");
317
- if (!collapseDiv) throw new Error("Collapse div not found");
318
- await act(async () => {
319
- fireEvent.click(collapseDiv);
320
- });
321
-
322
- await waitFor(
323
- () => {
324
- const emailText = screen.getByText("Email");
325
- const emailCheckbox = emailText
326
- .closest('div[style*="align-items: center"]')
327
- ?.querySelector('input[type="checkbox"]');
328
- if (!emailCheckbox) throw new Error("Email checkbox not found");
329
-
330
- const phoneText = screen.getByText(/Phone/);
331
- const phoneCheckbox = phoneText
332
- .closest('div[style*="align-items: center"]')
333
- ?.querySelector('input[type="checkbox"]');
334
- if (!phoneCheckbox) throw new Error("Phone checkbox not found");
335
-
336
- expect(phoneCheckbox).toBeDisabled();
337
- expect(phoneCheckbox).toBeChecked();
338
-
339
- expect(emailCheckbox).not.toBeDisabled();
340
- fireEvent.click(emailCheckbox);
341
- expect(emailCheckbox).toBeChecked();
342
- },
343
- { timeout: 3000 }
344
- );
345
- });
346
-
347
- it("calls submitConsentEvent on accept", async () => {
348
- await act(async () => {
349
- render(<RedactoNoticeConsent {...defaultProps} />);
350
- });
351
- await waitFor(
352
- () => {
353
- expect(screen.getByText("Accept")).toBeInTheDocument();
354
- },
355
- { timeout: 3000 }
356
- );
357
-
358
- await act(async () => {
359
- fireEvent.click(screen.getByText("Accept"));
360
- });
361
- await waitFor(
362
- () => {
363
- expect(api.submitConsentEvent).toHaveBeenCalledWith({
364
- accessToken: "mock-token",
365
- baseUrl: undefined,
366
- noticeUuid: "notice-123",
367
- purposes: [
368
- {
369
- uuid: "purpose-1",
370
- name: "Marketing",
371
- description: "We use data for marketing purposes.",
372
- industries: "Marketing",
373
- data_elements: [
374
- {
375
- uuid: "element-1",
376
- name: "Email",
377
- required: false,
378
- description: null,
379
- industries: null,
380
- enabled: true,
381
- selected: false,
382
- },
383
- {
384
- uuid: "element-2",
385
- name: "Phone",
386
- required: true,
387
- description: null,
388
- industries: null,
389
- enabled: true,
390
- selected: true,
391
- },
392
- ],
393
- selected: false,
394
- },
395
- ],
396
- declined: false,
397
- meta_data: undefined,
398
- guardianVerificationReference: undefined,
399
- signal: expect.any(AbortSignal),
400
- });
401
- expect(defaultProps.onAccept).toHaveBeenCalled();
402
- },
403
- { timeout: 3000 }
404
- );
405
- });
406
-
407
- it("calls onDecline on decline", async () => {
408
- render(<RedactoNoticeConsent {...defaultProps} />);
409
- await waitFor(
410
- () => {
411
- expect(screen.getByText("Decline")).toBeInTheDocument();
412
- },
413
- { timeout: 3000 }
414
- );
415
-
416
- await act(async () => {
417
- fireEvent.click(screen.getByText("Decline"));
418
- });
419
- await waitFor(
420
- () => {
421
- expect(defaultProps.onDecline).toHaveBeenCalled();
422
- },
423
- { timeout: 3000 }
424
- );
425
- });
426
-
427
- it("handles 409 conflict error (already consented)", async () => {
428
- mockedApi.fetchConsentContent.mockRejectedValueOnce({ status: 409 });
429
- await act(async () => {
430
- render(<RedactoNoticeConsent {...defaultProps} />);
431
- });
432
- await waitFor(
433
- () => {
434
- expect(defaultProps.onAccept).toHaveBeenCalled();
435
- expect(screen.queryByText("Privacy Notice")).not.toBeInTheDocument();
436
- },
437
- { timeout: 3000 }
438
- );
439
- });
440
-
441
- it("handles other errors", async () => {
442
- mockedApi.fetchConsentContent.mockRejectedValueOnce(
443
- new Error("Network Error")
444
- );
445
- await act(async () => {
446
- render(<RedactoNoticeConsent {...defaultProps} />);
447
- });
448
- await waitFor(
449
- () => {
450
- expect(defaultProps.onError).toHaveBeenCalledWith(expect.any(Error));
451
- },
452
- { timeout: 3000 }
453
- );
454
- });
455
-
456
- it("applies custom styles from settings", async () => {
457
- render(<RedactoNoticeConsent {...defaultProps} />);
458
- await waitFor(
459
- () => {
460
- const modal = screen.getByRole("dialog");
461
- expect(modal).toHaveStyle({
462
- backgroundColor: "#ffffff",
463
- borderRadius: "8px",
464
- });
465
-
466
- const acceptButton = screen.getByText("Accept");
467
- expect(acceptButton).toHaveStyle({
468
- backgroundColor: "#4f87ff",
469
- color: "#ffffff",
470
- });
471
- },
472
- { timeout: 3000 }
473
- );
474
- });
475
-
476
- describe("reconsent functionality", () => {
477
- beforeEach(() => {
478
- vi.resetAllMocks();
479
- mockWindowOpen.mockClear();
480
- setupCommonMocks();
481
- mockedApi.fetchConsentContent.mockResolvedValue(mockReconsentContent);
482
- });
483
-
484
- it("shows reconsent UI with visual indicators for different consent states", async () => {
485
- render(<RedactoNoticeConsent {...defaultProps} />);
486
- await waitFor(
487
- () => {
488
- expect(screen.getByText("Marketing")).toBeInTheDocument();
489
- expect(screen.getByText("Analytics")).toBeInTheDocument();
490
- },
491
- { timeout: 3000 }
492
- );
493
-
494
- // Check that both purposes are displayed in the reconsent UI
495
- expect(screen.getByText("Marketing")).toBeInTheDocument();
496
- expect(screen.getByText("Analytics")).toBeInTheDocument();
497
- });
498
-
499
- it("allows reconsent UI to render without errors", async () => {
500
- render(<RedactoNoticeConsent {...defaultProps} />);
501
- await waitFor(
502
- () => {
503
- expect(screen.getByText("Marketing")).toBeInTheDocument();
504
- },
505
- { timeout: 3000 }
506
- );
507
-
508
- // Verify the reconsent UI renders successfully with visual indicators
509
- expect(screen.getByText("Analytics")).toBeInTheDocument();
510
- // Verify both purposes are present in the reconsent layout
511
- const purposes = screen.getAllByText(/Marketing|Analytics/);
512
- expect(purposes).toHaveLength(2);
513
- });
514
-
515
- it("passes validate_against parameter to API", async () => {
516
- await act(async () => {
517
- render(
518
- <RedactoNoticeConsent {...defaultProps} validateAgainst="required" />
519
- );
520
- });
521
- await waitFor(
522
- () => {
523
- expect(api.fetchConsentContent).toHaveBeenCalledWith({
524
- noticeId: "notice-123",
525
- accessToken: "mock-token",
526
- refreshToken: "mock-refresh-token",
527
- baseUrl: defaultProps.ledgerBaseUrl,
528
- language: "en",
529
- specific_uuid: undefined,
530
- validate_against: "required",
531
- include_fully_consented_data: false,
532
- signal: expect.any(AbortSignal),
533
- });
534
- },
535
- { timeout: 3000 }
536
- );
537
- });
538
-
539
- it("defaults to validate_against 'all' when not specified", async () => {
540
- await act(async () => {
541
- render(<RedactoNoticeConsent {...defaultProps} />);
542
- });
543
- await waitFor(
544
- () => {
545
- expect(api.fetchConsentContent).toHaveBeenCalledWith({
546
- noticeId: "notice-123",
547
- accessToken: "mock-token",
548
- refreshToken: "mock-refresh-token",
549
- baseUrl: defaultProps.ledgerBaseUrl,
550
- language: "en",
551
- specific_uuid: undefined,
552
- validate_against: "all",
553
- include_fully_consented_data: false,
554
- signal: expect.any(AbortSignal),
555
- });
556
- },
557
- { timeout: 3000 }
558
- );
559
- });
560
- });
561
-
562
- describe("ledger routing", () => {
563
- it("routes the standard notice fetch to the ledger base url", async () => {
564
- await act(async () => {
565
- render(<RedactoNoticeConsent {...defaultProps} />);
566
- });
567
- await waitFor(
568
- () => {
569
- expect(api.fetchConsentContent).toHaveBeenCalledWith(
570
- expect.objectContaining({ baseUrl: defaultProps.ledgerBaseUrl })
571
- );
572
- },
573
- { timeout: 3000 }
574
- );
575
- });
576
-
577
- it("keeps the magic-link flow (applicationId) on the consent server", async () => {
578
- await act(async () => {
579
- render(
580
- <RedactoNoticeConsent {...defaultProps} applicationId="app-xyz" />
581
- );
582
- });
583
- await waitFor(
584
- () => {
585
- expect(api.fetchConsentContent).toHaveBeenCalledWith(
586
- expect.objectContaining({
587
- // defaultProps has no baseUrl, so the magic-link flow routes the
588
- // fetch to baseUrl=undefined (the consent server / SDK default),
589
- // i.e. NOT ledgerBaseUrl — same as the submitConsentEvent
590
- // assertion above. The point is the ledger routing is bypassed.
591
- baseUrl: undefined,
592
- specific_uuid: "app-xyz",
593
- })
594
- );
595
- },
596
- { timeout: 3000 }
597
- );
598
- });
599
- });
600
-
601
- describe("includeFullyConsentedData (magic link flow)", () => {
602
- beforeEach(() => {
603
- mockedApi.fetchTTSAudioUrls.mockResolvedValue({
604
- code: 200,
605
- status: "success",
606
- detail: {
607
- uuid: "notice-123",
608
- language: "en",
609
- notice_text_audio_url: "",
610
- additional_text_audio_url: "",
611
- notice_summary_audio_url: "",
612
- confirm_button_text_audio_url: "",
613
- decline_button_text_audio_url: "",
614
- privacy_policy_prefix_text_audio_url: "",
615
- privacy_policy_anchor_text_audio_url: "",
616
- purpose_section_heading_audio_url: "",
617
- notice_banner_heading_audio_url: "",
618
- purposes_audio: {
619
- "purpose-1": { name_audio_url: "", description_audio_url: "" },
620
- "purpose-2": { name_audio_url: "", description_audio_url: "" },
621
- },
622
- data_elements_audio: {},
623
- },
624
- });
625
- });
626
-
627
- it("passes include_fully_consented_data=true to API when prop is true", async () => {
628
- mockedApi.fetchConsentContent.mockResolvedValue(mockMagicLinkContent);
629
- render(
630
- <RedactoNoticeConsent
631
- {...defaultProps}
632
- includeFullyConsentedData={true}
633
- />
634
- );
635
- await waitFor(
636
- () => {
637
- expect(api.fetchConsentContent).toHaveBeenCalledWith({
638
- noticeId: "notice-123",
639
- accessToken: "mock-token",
640
- refreshToken: "mock-refresh-token",
641
- baseUrl: defaultProps.ledgerBaseUrl,
642
- language: "en",
643
- specific_uuid: undefined,
644
- validate_against: "all",
645
- include_fully_consented_data: true,
646
- signal: expect.any(AbortSignal),
647
- });
648
- },
649
- { timeout: 3000 }
650
- );
651
- });
652
- });
653
-
654
- describe("age verification and minor consent functionality", () => {
655
- beforeEach(() => {
656
- vi.resetAllMocks();
657
- mockWindowOpen.mockClear();
658
- setupCommonMocks();
659
- mockedApi.fetchConsentContent.mockResolvedValue(mockMinorConsentContent);
660
- });
661
-
662
- it("shows age verification when is_minor is true", async () => {
663
- render(<RedactoNoticeConsent {...defaultProps} />);
664
- await waitFor(
665
- () => {
666
- expect(
667
- screen.getByText("Age Verification Required")
668
- ).toBeInTheDocument();
669
- expect(
670
- screen.getByText(/Are you 18 years of age or older/)
671
- ).toBeInTheDocument();
672
- },
673
- { timeout: 3000 }
674
- );
675
- });
676
-
677
- it("shows age verification fields", async () => {
678
- render(<RedactoNoticeConsent {...defaultProps} />);
679
- await waitFor(
680
- () => {
681
- expect(
682
- screen.getByText("Age Verification Required")
683
- ).toBeInTheDocument();
684
- expect(screen.getByText("Yes, I am 18 or older")).toBeInTheDocument();
685
- expect(screen.getByText("No, I am under 18")).toBeInTheDocument();
686
- expect(screen.getByAltText("Redacto Logo")).toBeInTheDocument();
687
- },
688
- { timeout: 3000 }
689
- );
690
- });
691
-
692
- it("proceeds to consent form when user clicks Yes (18+)", async () => {
693
- render(<RedactoNoticeConsent {...defaultProps} />);
694
- await waitFor(
695
- () => {
696
- expect(
697
- screen.getByText("Age Verification Required")
698
- ).toBeInTheDocument();
699
- },
700
- { timeout: 3000 }
701
- );
702
-
703
- const yesButton = screen.getByText("Yes, I am 18 or older");
704
- fireEvent.click(yesButton);
705
-
706
- // Should transition directly to consent form
707
- await waitFor(
708
- () => {
709
- expect(screen.getByText("Privacy Notice")).toBeInTheDocument();
710
- expect(
711
- screen.queryByText("Age Verification Required")
712
- ).not.toBeInTheDocument();
713
- expect(
714
- screen.queryByText("Guardian Verification")
715
- ).not.toBeInTheDocument();
716
- },
717
- { timeout: 3000 }
718
- );
719
-
720
- // Verify the adult can submit consent without guardian verification
721
- const acceptButton = screen.getByText("Accept");
722
- fireEvent.click(acceptButton);
723
-
724
- await waitFor(
725
- () => {
726
- expect(mockedApi.submitConsentEvent).toHaveBeenCalledWith(
727
- expect.objectContaining({
728
- accessToken: "mock-token",
729
- noticeUuid: "notice-123",
730
- declined: false,
731
- guardianVerificationReference: undefined,
732
- })
733
- );
734
- expect(defaultProps.onAccept).toHaveBeenCalled();
735
- },
736
- { timeout: 3000 }
737
- );
738
- });
739
-
740
- it("shows guardian form when user clicks No (under 18)", async () => {
741
- render(<RedactoNoticeConsent {...defaultProps} />);
742
- await waitFor(
743
- () => {
744
- expect(
745
- screen.getByText("Age Verification Required")
746
- ).toBeInTheDocument();
747
- },
748
- { timeout: 3000 }
749
- );
750
-
751
- const noButton = screen.getByText("No, I am under 18");
752
- fireEvent.click(noButton);
753
-
754
- // Should transition to guardian form
755
- await waitFor(
756
- () => {
757
- expect(
758
- screen.getByText("Guardian Verification")
759
- ).toBeInTheDocument();
760
- expect(
761
- screen.queryByText("Age Verification Required")
762
- ).not.toBeInTheDocument();
763
- },
764
- { timeout: 3000 }
765
- );
766
- });
767
-
768
- it("completes full minor flow: age verification -> guardian form -> verification screen", async () => {
769
- render(<RedactoNoticeConsent {...defaultProps} />);
770
- await waitFor(
771
- () => {
772
- expect(
773
- screen.getByText("Age Verification Required")
774
- ).toBeInTheDocument();
775
- },
776
- { timeout: 3000 }
777
- );
778
-
779
- // Click No to proceed to guardian form
780
- const noButton = screen.getByText("No, I am under 18");
781
- fireEvent.click(noButton);
782
-
783
- // Should show guardian form
784
- await waitFor(
785
- () => {
786
- expect(
787
- screen.getByText("Guardian Verification")
788
- ).toBeInTheDocument();
789
- expect(
790
- screen.getByText(/a legal guardian must verify/i)
791
- ).toBeInTheDocument();
792
- },
793
- { timeout: 3000 }
794
- );
795
-
796
- // Fill out guardian form
797
- const nameInput = screen.getByLabelText(/Guardian's Full Name/i);
798
- const contactInput = screen.getByLabelText(/Guardian's Phone Number/i);
799
- fireEvent.change(nameInput, { target: { value: "John Doe" } });
800
- fireEvent.change(contactInput, { target: { value: "john@example.com" } });
801
- // Select "Father" from the custom dropdown
802
- const relationshipDropdown = screen.getByRole("combobox", { name: /Relationship/i });
803
- fireEvent.click(relationshipDropdown);
804
- fireEvent.click(screen.getByRole("option", { name: "Father" }));
805
-
806
- const nextButton = screen.getByText("Verify via DigiLocker");
807
- fireEvent.click(nextButton);
808
-
809
- // Should transition to verification screen (guardian form text should be gone)
810
- await waitFor(
811
- () => {
812
- expect(
813
- screen.queryByText(/a legal guardian must verify/i)
814
- ).not.toBeInTheDocument();
815
- },
816
- { timeout: 3000 }
817
- );
818
- });
819
-
820
- it("displays guardian form fields after age verification", async () => {
821
- render(<RedactoNoticeConsent {...defaultProps} />);
822
- await waitFor(
823
- () => {
824
- expect(
825
- screen.getByText("Age Verification Required")
826
- ).toBeInTheDocument();
827
- },
828
- { timeout: 3000 }
829
- );
830
-
831
- // Navigate to guardian form
832
- const noButton = screen.getByText("No, I am under 18");
833
- fireEvent.click(noButton);
834
-
835
- await waitFor(
836
- () => {
837
- expect(screen.getByAltText("Logo")).toBeInTheDocument();
838
- expect(
839
- screen.getByLabelText(/Guardian's Full Name/i)
840
- ).toBeInTheDocument();
841
- expect(
842
- screen.getByLabelText(/Guardian's Phone Number/i)
843
- ).toBeInTheDocument();
844
- expect(
845
- screen.getByRole("combobox", { name: /Relationship/i })
846
- ).toBeInTheDocument();
847
- expect(screen.getByText("Verify via DigiLocker")).toBeInTheDocument();
848
- expect(screen.getByText("Cancel")).toBeInTheDocument();
849
- },
850
- { timeout: 3000 }
851
- );
852
- });
853
-
854
- it("validates guardian form fields", async () => {
855
- render(<RedactoNoticeConsent {...defaultProps} />);
856
- await waitFor(
857
- () => {
858
- expect(
859
- screen.getByText("Age Verification Required")
860
- ).toBeInTheDocument();
861
- },
862
- { timeout: 3000 }
863
- );
864
-
865
- // Navigate to guardian form
866
- const noButton = screen.getByText("No, I am under 18");
867
- fireEvent.click(noButton);
868
-
869
- await waitFor(
870
- () => {
871
- expect(
872
- screen.getByText("Guardian Verification")
873
- ).toBeInTheDocument();
874
- },
875
- { timeout: 3000 }
876
- );
877
-
878
- const nextButton = screen.getByText("Verify via DigiLocker");
879
- fireEvent.click(nextButton);
880
-
881
- await waitFor(
882
- () => {
883
- expect(
884
- screen.getByText("Guardian name is required")
885
- ).toBeInTheDocument();
886
- expect(
887
- screen.getByText("Guardian contact is required")
888
- ).toBeInTheDocument();
889
- expect(
890
- screen.getByText("Relationship to guardian is required")
891
- ).toBeInTheDocument();
892
- },
893
- { timeout: 3000 }
894
- );
895
- });
896
-
897
- it("transitions to verification screen after filling guardian form", async () => {
898
- render(<RedactoNoticeConsent {...defaultProps} />);
899
- await waitFor(
900
- () => {
901
- expect(
902
- screen.getByText("Age Verification Required")
903
- ).toBeInTheDocument();
904
- },
905
- { timeout: 3000 }
906
- );
907
-
908
- // Navigate to guardian form
909
- const noButton = screen.getByText("No, I am under 18");
910
- fireEvent.click(noButton);
911
-
912
- await waitFor(
913
- () => {
914
- expect(
915
- screen.getByText("Guardian Verification")
916
- ).toBeInTheDocument();
917
- },
918
- { timeout: 3000 }
919
- );
920
-
921
- // Fill out guardian form
922
- const nameInput = screen.getByLabelText(/Guardian's Full Name/i);
923
- const contactInput = screen.getByLabelText(/Guardian's Phone Number/i);
924
- fireEvent.change(nameInput, { target: { value: "John Doe" } });
925
- fireEvent.change(contactInput, { target: { value: "john@example.com" } });
926
- // Select "Father" from the custom dropdown
927
- const relationshipDropdown = screen.getByRole("combobox", { name: /Relationship/i });
928
- fireEvent.click(relationshipDropdown);
929
- fireEvent.click(screen.getByRole("option", { name: "Father" }));
930
-
931
- const nextButton = screen.getByText("Verify via DigiLocker");
932
- fireEvent.click(nextButton);
933
-
934
- // Should transition to verification screen (guardian form fields should be gone)
935
- await waitFor(
936
- () => {
937
- expect(
938
- screen.queryByLabelText(/Guardian's Full Name/i)
939
- ).not.toBeInTheDocument();
940
- },
941
- { timeout: 3000 }
942
- );
943
- });
944
-
945
- it("validates whitespace-only input as empty", async () => {
946
- render(<RedactoNoticeConsent {...defaultProps} />);
947
- await waitFor(
948
- () => {
949
- expect(
950
- screen.getByText("Age Verification Required")
951
- ).toBeInTheDocument();
952
- },
953
- { timeout: 3000 }
954
- );
955
-
956
- // Navigate to guardian form
957
- const noButton = screen.getByText("No, I am under 18");
958
- fireEvent.click(noButton);
959
-
960
- await waitFor(
961
- () => {
962
- expect(
963
- screen.getByText("Guardian Verification")
964
- ).toBeInTheDocument();
965
- },
966
- { timeout: 3000 }
967
- );
968
-
969
- // Fill fields with only whitespace (leave relationship empty — don't select anything)
970
- const nameInput = screen.getByLabelText(/Guardian's Full Name/i);
971
- const contactInput = screen.getByLabelText(/Guardian's Phone Number/i);
972
-
973
- fireEvent.change(nameInput, { target: { value: " " } });
974
- fireEvent.change(contactInput, { target: { value: "\t\t" } });
975
-
976
- const nextButton = screen.getByText("Verify via DigiLocker");
977
- fireEvent.click(nextButton);
978
-
979
- // Should still show validation errors for whitespace-only input
980
- await waitFor(
981
- () => {
982
- expect(
983
- screen.getByText("Guardian name is required")
984
- ).toBeInTheDocument();
985
- expect(
986
- screen.getByText("Guardian contact is required")
987
- ).toBeInTheDocument();
988
- expect(
989
- screen.getByText("Relationship to guardian is required")
990
- ).toBeInTheDocument();
991
- },
992
- { timeout: 3000 }
993
- );
994
- });
995
-
996
- it("clears validation errors when user starts typing", async () => {
997
- render(<RedactoNoticeConsent {...defaultProps} />);
998
- await waitFor(
999
- () => {
1000
- expect(
1001
- screen.getByText("Age Verification Required")
1002
- ).toBeInTheDocument();
1003
- },
1004
- { timeout: 3000 }
1005
- );
1006
-
1007
- // Navigate to guardian form
1008
- const noButton = screen.getByText("No, I am under 18");
1009
- fireEvent.click(noButton);
1010
-
1011
- await waitFor(
1012
- () => {
1013
- expect(
1014
- screen.getByText("Guardian Verification")
1015
- ).toBeInTheDocument();
1016
- },
1017
- { timeout: 3000 }
1018
- );
1019
-
1020
- // Click next with empty fields to trigger errors
1021
- const nextButton = screen.getByText("Verify via DigiLocker");
1022
- fireEvent.click(nextButton);
1023
-
1024
- await waitFor(
1025
- () => {
1026
- expect(
1027
- screen.getByText("Guardian name is required")
1028
- ).toBeInTheDocument();
1029
- },
1030
- { timeout: 3000 }
1031
- );
1032
-
1033
- // Start typing in name field
1034
- const nameInput = screen.getByLabelText(/Guardian's Full Name/i);
1035
- fireEvent.change(nameInput, { target: { value: "J" } });
1036
-
1037
- // Error should be cleared
1038
- await waitFor(
1039
- () => {
1040
- expect(
1041
- screen.queryByText("Guardian name is required")
1042
- ).not.toBeInTheDocument();
1043
- },
1044
- { timeout: 3000 }
1045
- );
1046
- });
1047
-
1048
- it("calls onDecline when cancel is clicked in guardian form", async () => {
1049
- render(<RedactoNoticeConsent {...defaultProps} />);
1050
- await waitFor(
1051
- () => {
1052
- expect(
1053
- screen.getByText("Age Verification Required")
1054
- ).toBeInTheDocument();
1055
- },
1056
- { timeout: 3000 }
1057
- );
1058
-
1059
- // Navigate to guardian form
1060
- const noButton = screen.getByText("No, I am under 18");
1061
- fireEvent.click(noButton);
1062
-
1063
- await waitFor(
1064
- () => {
1065
- expect(
1066
- screen.getByText("Guardian Verification")
1067
- ).toBeInTheDocument();
1068
- },
1069
- { timeout: 3000 }
1070
- );
1071
-
1072
- const cancelButton = screen.getByText("Cancel");
1073
- fireEvent.click(cancelButton);
1074
-
1075
- await waitFor(
1076
- () => {
1077
- expect(defaultProps.onDecline).toHaveBeenCalled();
1078
- },
1079
- { timeout: 3000 }
1080
- );
1081
- });
1082
-
1083
- it("maintains focus when typing in guardian form fields", async () => {
1084
- render(<RedactoNoticeConsent {...defaultProps} />);
1085
- await waitFor(
1086
- () => {
1087
- expect(
1088
- screen.getByText("Age Verification Required")
1089
- ).toBeInTheDocument();
1090
- },
1091
- { timeout: 3000 }
1092
- );
1093
-
1094
- // Navigate to guardian form
1095
- const noButton = screen.getByText("No, I am under 18");
1096
- fireEvent.click(noButton);
1097
-
1098
- await waitFor(
1099
- () => {
1100
- expect(
1101
- screen.getByText("Guardian Verification")
1102
- ).toBeInTheDocument();
1103
- },
1104
- { timeout: 3000 }
1105
- );
1106
-
1107
- const contactInput = screen.getByLabelText(/Guardian's Phone Number/i);
1108
-
1109
- // Focus on contact field and type
1110
- contactInput.focus();
1111
- fireEvent.change(contactInput, { target: { value: "j" } });
1112
-
1113
- // Verify the input still has focus and value
1114
- expect(contactInput).toHaveFocus();
1115
- expect(contactInput).toHaveValue("j");
1116
-
1117
- // Continue typing
1118
- fireEvent.change(contactInput, { target: { value: "john@example.com" } });
1119
-
1120
- // Verify the input still has focus and updated value
1121
- expect(contactInput).toHaveFocus();
1122
- expect(contactInput).toHaveValue("john@example.com");
1123
-
1124
- // Test other fields maintain focus too
1125
- const nameInput = screen.getByLabelText(/Guardian's Full Name/i);
1126
- nameInput.focus();
1127
- fireEvent.change(nameInput, { target: { value: "J" } });
1128
-
1129
- expect(nameInput).toHaveFocus();
1130
- expect(nameInput).toHaveValue("J");
1131
- });
1132
-
1133
- it("calls initiateGuardianVerification with correct params", async () => {
1134
- render(<RedactoNoticeConsent {...defaultProps} />);
1135
- await waitFor(
1136
- () => {
1137
- expect(
1138
- screen.getByText("Age Verification Required")
1139
- ).toBeInTheDocument();
1140
- },
1141
- { timeout: 3000 }
1142
- );
1143
-
1144
- // Navigate to guardian form
1145
- const noButton = screen.getByText("No, I am under 18");
1146
- fireEvent.click(noButton);
1147
-
1148
- await waitFor(
1149
- () => {
1150
- expect(
1151
- screen.getByText("Guardian Verification")
1152
- ).toBeInTheDocument();
1153
- },
1154
- { timeout: 3000 }
1155
- );
1156
-
1157
- // Fill out guardian form
1158
- const nameInput = screen.getByLabelText(/Guardian's Full Name/i);
1159
- const contactInput = screen.getByLabelText(/Guardian's Phone Number/i);
1160
- fireEvent.change(nameInput, { target: { value: "John Doe" } });
1161
- fireEvent.change(contactInput, { target: { value: "john@example.com" } });
1162
- // Select "Father" from the custom dropdown
1163
- const relationshipDropdown = screen.getByRole("combobox", { name: /Relationship/i });
1164
- fireEvent.click(relationshipDropdown);
1165
- fireEvent.click(screen.getByRole("option", { name: "Father" }));
1166
-
1167
- const nextButton = screen.getByText("Verify via DigiLocker");
1168
- fireEvent.click(nextButton);
1169
-
1170
- // Verify initiateGuardianVerification was called with correct params
1171
- await waitFor(
1172
- () => {
1173
- expect(api.initiateGuardianVerification).toHaveBeenCalledWith(
1174
- expect.objectContaining({
1175
- accessToken: "mock-token",
1176
- guardianName: "John Doe",
1177
- guardianContact: "john@example.com",
1178
- guardianRelationship: "Father",
1179
- })
1180
- );
1181
- },
1182
- { timeout: 3000 }
1183
- );
1184
- });
1185
- });
1186
- });