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