@redacto.io/consent-sdk-react 3.3.0 → 3.4.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/CHANGELOG.md +6 -0
- package/README.md +11 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +279 -32
- package/dist/index.mjs +279 -32
- package/package.json +1 -1
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +123 -1
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +924 -652
- package/src/RedactoNoticeConsent/api/index.ts +5 -1
- package/src/RedactoNoticeConsent/api/types.ts +47 -8
- package/src/RedactoNoticeConsent/constants.ts +20 -0
- package/src/RedactoNoticeConsent/styles.ts +3 -6
- package/src/RedactoNoticeConsent/types.ts +11 -5
- package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +12 -3
- package/src/RedactoNoticeConsentInline/api/types.ts +8 -6
- package/src/RedactoNoticeConsentInline/types.ts +9 -4
- package/src/types/react-jsx.d.ts +26 -0
- package/tests/mocks.ts +53 -7
- package/tsconfig.json +1 -5
|
@@ -10,6 +10,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
10
10
|
import {
|
|
11
11
|
defaultProps,
|
|
12
12
|
mockConsentContent,
|
|
13
|
+
mockMagicLinkContent,
|
|
13
14
|
mockMinorConsentContent,
|
|
14
15
|
mockReconsentContent,
|
|
15
16
|
} from "../../tests/mocks";
|
|
@@ -22,6 +23,28 @@ vi.mock("./api", () => ({
|
|
|
22
23
|
fetchConsentContent: vi.fn(),
|
|
23
24
|
submitConsentEvent: vi.fn(),
|
|
24
25
|
submitGuardianInfo: vi.fn(),
|
|
26
|
+
fetchTTSAudioUrls: vi.fn().mockResolvedValue({
|
|
27
|
+
code: 200,
|
|
28
|
+
status: "success",
|
|
29
|
+
detail: {
|
|
30
|
+
uuid: "notice-123",
|
|
31
|
+
language: "en",
|
|
32
|
+
notice_text_audio_url: "",
|
|
33
|
+
additional_text_audio_url: "",
|
|
34
|
+
notice_summary_audio_url: "",
|
|
35
|
+
confirm_button_text_audio_url: "",
|
|
36
|
+
decline_button_text_audio_url: "",
|
|
37
|
+
privacy_policy_prefix_text_audio_url: "",
|
|
38
|
+
privacy_policy_anchor_text_audio_url: "",
|
|
39
|
+
purpose_section_heading_audio_url: "",
|
|
40
|
+
notice_banner_heading_audio_url: "",
|
|
41
|
+
purposes_audio: {
|
|
42
|
+
"purpose-1": { name_audio_url: "", description_audio_url: "" },
|
|
43
|
+
"purpose-2": { name_audio_url: "", description_audio_url: "" },
|
|
44
|
+
},
|
|
45
|
+
data_elements_audio: {},
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
25
48
|
clearApiCache: vi.fn(),
|
|
26
49
|
}));
|
|
27
50
|
|
|
@@ -54,10 +77,32 @@ describe("RedactoNoticeConsent", () => {
|
|
|
54
77
|
);
|
|
55
78
|
mockedApi.submitConsentEvent.mockReturnValue(Promise.resolve(undefined));
|
|
56
79
|
mockedApi.submitGuardianInfo.mockReturnValue(Promise.resolve(undefined));
|
|
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
|
+
});
|
|
57
102
|
});
|
|
58
103
|
|
|
59
104
|
afterEach(() => {
|
|
60
|
-
vi.
|
|
105
|
+
vi.clearAllMocks();
|
|
61
106
|
});
|
|
62
107
|
|
|
63
108
|
it("renders loading state initially", () => {
|
|
@@ -398,6 +443,28 @@ describe("RedactoNoticeConsent", () => {
|
|
|
398
443
|
beforeEach(() => {
|
|
399
444
|
mockedApi.fetchConsentContent.mockResolvedValue(mockReconsentContent);
|
|
400
445
|
mockedApi.submitConsentEvent.mockResolvedValue(undefined);
|
|
446
|
+
mockedApi.fetchTTSAudioUrls.mockResolvedValue({
|
|
447
|
+
code: 200,
|
|
448
|
+
status: "success",
|
|
449
|
+
detail: {
|
|
450
|
+
uuid: "notice-123",
|
|
451
|
+
language: "en",
|
|
452
|
+
notice_text_audio_url: "",
|
|
453
|
+
additional_text_audio_url: "",
|
|
454
|
+
notice_summary_audio_url: "",
|
|
455
|
+
confirm_button_text_audio_url: "",
|
|
456
|
+
decline_button_text_audio_url: "",
|
|
457
|
+
privacy_policy_prefix_text_audio_url: "",
|
|
458
|
+
privacy_policy_anchor_text_audio_url: "",
|
|
459
|
+
purpose_section_heading_audio_url: "",
|
|
460
|
+
notice_banner_heading_audio_url: "",
|
|
461
|
+
purposes_audio: {
|
|
462
|
+
"purpose-1": { name_audio_url: "", description_audio_url: "" },
|
|
463
|
+
"purpose-2": { name_audio_url: "", description_audio_url: "" },
|
|
464
|
+
},
|
|
465
|
+
data_elements_audio: {},
|
|
466
|
+
},
|
|
467
|
+
});
|
|
401
468
|
});
|
|
402
469
|
|
|
403
470
|
it("shows reconsent UI with visual indicators for different consent states", async () => {
|
|
@@ -445,6 +512,7 @@ describe("RedactoNoticeConsent", () => {
|
|
|
445
512
|
language: "en",
|
|
446
513
|
specific_uuid: undefined,
|
|
447
514
|
validate_against: "required",
|
|
515
|
+
include_fully_consented_data: false,
|
|
448
516
|
signal: expect.any(AbortSignal),
|
|
449
517
|
});
|
|
450
518
|
},
|
|
@@ -464,6 +532,60 @@ describe("RedactoNoticeConsent", () => {
|
|
|
464
532
|
language: "en",
|
|
465
533
|
specific_uuid: undefined,
|
|
466
534
|
validate_against: "all",
|
|
535
|
+
include_fully_consented_data: false,
|
|
536
|
+
signal: expect.any(AbortSignal),
|
|
537
|
+
});
|
|
538
|
+
},
|
|
539
|
+
{ timeout: 3000 }
|
|
540
|
+
);
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
describe("includeFullyConsentedData (magic link flow)", () => {
|
|
545
|
+
beforeEach(() => {
|
|
546
|
+
mockedApi.fetchTTSAudioUrls.mockResolvedValue({
|
|
547
|
+
code: 200,
|
|
548
|
+
status: "success",
|
|
549
|
+
detail: {
|
|
550
|
+
uuid: "notice-123",
|
|
551
|
+
language: "en",
|
|
552
|
+
notice_text_audio_url: "",
|
|
553
|
+
additional_text_audio_url: "",
|
|
554
|
+
notice_summary_audio_url: "",
|
|
555
|
+
confirm_button_text_audio_url: "",
|
|
556
|
+
decline_button_text_audio_url: "",
|
|
557
|
+
privacy_policy_prefix_text_audio_url: "",
|
|
558
|
+
privacy_policy_anchor_text_audio_url: "",
|
|
559
|
+
purpose_section_heading_audio_url: "",
|
|
560
|
+
notice_banner_heading_audio_url: "",
|
|
561
|
+
purposes_audio: {
|
|
562
|
+
"purpose-1": { name_audio_url: "", description_audio_url: "" },
|
|
563
|
+
"purpose-2": { name_audio_url: "", description_audio_url: "" },
|
|
564
|
+
},
|
|
565
|
+
data_elements_audio: {},
|
|
566
|
+
},
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
it("passes include_fully_consented_data=true to API when prop is true", async () => {
|
|
571
|
+
mockedApi.fetchConsentContent.mockResolvedValue(mockMagicLinkContent);
|
|
572
|
+
render(
|
|
573
|
+
<RedactoNoticeConsent
|
|
574
|
+
{...defaultProps}
|
|
575
|
+
includeFullyConsentedData={true}
|
|
576
|
+
/>
|
|
577
|
+
);
|
|
578
|
+
await waitFor(
|
|
579
|
+
() => {
|
|
580
|
+
expect(api.fetchConsentContent).toHaveBeenCalledWith({
|
|
581
|
+
noticeId: "notice-123",
|
|
582
|
+
accessToken: "mock-token",
|
|
583
|
+
refreshToken: "mock-refresh-token",
|
|
584
|
+
baseUrl: undefined,
|
|
585
|
+
language: "en",
|
|
586
|
+
specific_uuid: undefined,
|
|
587
|
+
validate_against: "all",
|
|
588
|
+
include_fully_consented_data: true,
|
|
467
589
|
signal: expect.any(AbortSignal),
|
|
468
590
|
});
|
|
469
591
|
},
|