@redacto.io/consent-sdk-react 1.1.0 → 1.3.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 +12 -0
- package/README.md +705 -20
- package/dist/index.d.mts +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.js +427 -413
- package/dist/index.mjs +428 -421
- package/package.json +1 -1
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +137 -50
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +3 -3
- package/src/RedactoNoticeConsent/api/index.ts +7 -7
- package/src/RedactoNoticeConsent/api/types.ts +1 -1
- package/src/RedactoNoticeConsent/types.ts +1 -1
- package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +489 -477
- package/src/RedactoNoticeConsentInline/api/index.ts +1 -3
- package/.turbo/turbo-build.log +0 -21
package/package.json
CHANGED
|
@@ -7,7 +7,12 @@ import {
|
|
|
7
7
|
waitFor,
|
|
8
8
|
} from "@testing-library/react";
|
|
9
9
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
defaultProps,
|
|
12
|
+
mockConsentContent,
|
|
13
|
+
mockMinorConsentContent,
|
|
14
|
+
mockReconsentContent,
|
|
15
|
+
} from "../../tests/mocks";
|
|
11
16
|
import { RedactoNoticeConsent } from "./RedactoNoticeConsent";
|
|
12
17
|
import * as api from "./api";
|
|
13
18
|
import type { ConsentContent } from "./api/types";
|
|
@@ -44,7 +49,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
44
49
|
beforeEach(() => {
|
|
45
50
|
vi.clearAllMocks();
|
|
46
51
|
// Mock API calls synchronously to avoid act() warnings
|
|
47
|
-
mockedApi.fetchConsentContent.mockReturnValue(
|
|
52
|
+
mockedApi.fetchConsentContent.mockReturnValue(
|
|
53
|
+
Promise.resolve(mockConsentContent)
|
|
54
|
+
);
|
|
48
55
|
mockedApi.submitConsentEvent.mockReturnValue(Promise.resolve(undefined));
|
|
49
56
|
mockedApi.submitGuardianInfo.mockReturnValue(Promise.resolve(undefined));
|
|
50
57
|
});
|
|
@@ -143,7 +150,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
143
150
|
expect(
|
|
144
151
|
screen.getByText(/Nos importa tu privacidad/i)
|
|
145
152
|
).toBeInTheDocument();
|
|
146
|
-
expect(
|
|
153
|
+
expect(
|
|
154
|
+
screen.getByText("[Política de Privacidad]")
|
|
155
|
+
).toBeInTheDocument();
|
|
147
156
|
expect(
|
|
148
157
|
screen.getByText("Gestionar Consentimiento")
|
|
149
158
|
).toBeInTheDocument();
|
|
@@ -344,9 +353,7 @@ describe("RedactoNoticeConsent", () => {
|
|
|
344
353
|
await waitFor(
|
|
345
354
|
() => {
|
|
346
355
|
expect(defaultProps.onAccept).toHaveBeenCalled();
|
|
347
|
-
expect(
|
|
348
|
-
screen.queryByText("Privacy Notice")
|
|
349
|
-
).not.toBeInTheDocument();
|
|
356
|
+
expect(screen.queryByText("Privacy Notice")).not.toBeInTheDocument();
|
|
350
357
|
},
|
|
351
358
|
{ timeout: 3000 }
|
|
352
359
|
);
|
|
@@ -424,8 +431,10 @@ describe("RedactoNoticeConsent", () => {
|
|
|
424
431
|
expect(purposes).toHaveLength(2);
|
|
425
432
|
});
|
|
426
433
|
|
|
427
|
-
it("passes
|
|
428
|
-
render(
|
|
434
|
+
it("passes validate_against parameter to API", async () => {
|
|
435
|
+
render(
|
|
436
|
+
<RedactoNoticeConsent {...defaultProps} validateAgainst="required" />
|
|
437
|
+
);
|
|
429
438
|
await waitFor(
|
|
430
439
|
() => {
|
|
431
440
|
expect(api.fetchConsentContent).toHaveBeenCalledWith({
|
|
@@ -435,7 +444,7 @@ describe("RedactoNoticeConsent", () => {
|
|
|
435
444
|
baseUrl: undefined,
|
|
436
445
|
language: "en",
|
|
437
446
|
specific_uuid: undefined,
|
|
438
|
-
|
|
447
|
+
validate_against: "required",
|
|
439
448
|
signal: expect.any(AbortSignal),
|
|
440
449
|
});
|
|
441
450
|
},
|
|
@@ -443,7 +452,7 @@ describe("RedactoNoticeConsent", () => {
|
|
|
443
452
|
);
|
|
444
453
|
});
|
|
445
454
|
|
|
446
|
-
it("defaults to
|
|
455
|
+
it("defaults to validate_against 'all' when not specified", async () => {
|
|
447
456
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
448
457
|
await waitFor(
|
|
449
458
|
() => {
|
|
@@ -454,7 +463,7 @@ describe("RedactoNoticeConsent", () => {
|
|
|
454
463
|
baseUrl: undefined,
|
|
455
464
|
language: "en",
|
|
456
465
|
specific_uuid: undefined,
|
|
457
|
-
|
|
466
|
+
validate_against: "all",
|
|
458
467
|
signal: expect.any(AbortSignal),
|
|
459
468
|
});
|
|
460
469
|
},
|
|
@@ -474,7 +483,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
474
483
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
475
484
|
await waitFor(
|
|
476
485
|
() => {
|
|
477
|
-
expect(
|
|
486
|
+
expect(
|
|
487
|
+
screen.getByText("Age Verification Required")
|
|
488
|
+
).toBeInTheDocument();
|
|
478
489
|
expect(
|
|
479
490
|
screen.getByText(/Are you 18 years of age or older/)
|
|
480
491
|
).toBeInTheDocument();
|
|
@@ -487,7 +498,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
487
498
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
488
499
|
await waitFor(
|
|
489
500
|
() => {
|
|
490
|
-
expect(
|
|
501
|
+
expect(
|
|
502
|
+
screen.getByText("Age Verification Required")
|
|
503
|
+
).toBeInTheDocument();
|
|
491
504
|
expect(screen.getByText("Yes, I am 18 or older")).toBeInTheDocument();
|
|
492
505
|
expect(screen.getByText("No, I am under 18")).toBeInTheDocument();
|
|
493
506
|
expect(screen.getByAltText("Redacto Logo")).toBeInTheDocument();
|
|
@@ -500,7 +513,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
500
513
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
501
514
|
await waitFor(
|
|
502
515
|
() => {
|
|
503
|
-
expect(
|
|
516
|
+
expect(
|
|
517
|
+
screen.getByText("Age Verification Required")
|
|
518
|
+
).toBeInTheDocument();
|
|
504
519
|
},
|
|
505
520
|
{ timeout: 3000 }
|
|
506
521
|
);
|
|
@@ -512,8 +527,12 @@ describe("RedactoNoticeConsent", () => {
|
|
|
512
527
|
await waitFor(
|
|
513
528
|
() => {
|
|
514
529
|
expect(screen.getByText("Privacy Notice")).toBeInTheDocument();
|
|
515
|
-
expect(
|
|
516
|
-
|
|
530
|
+
expect(
|
|
531
|
+
screen.queryByText("Age Verification Required")
|
|
532
|
+
).not.toBeInTheDocument();
|
|
533
|
+
expect(
|
|
534
|
+
screen.queryByText("Guardian Information Required")
|
|
535
|
+
).not.toBeInTheDocument();
|
|
517
536
|
},
|
|
518
537
|
{ timeout: 3000 }
|
|
519
538
|
);
|
|
@@ -523,7 +542,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
523
542
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
524
543
|
await waitFor(
|
|
525
544
|
() => {
|
|
526
|
-
expect(
|
|
545
|
+
expect(
|
|
546
|
+
screen.getByText("Age Verification Required")
|
|
547
|
+
).toBeInTheDocument();
|
|
527
548
|
},
|
|
528
549
|
{ timeout: 3000 }
|
|
529
550
|
);
|
|
@@ -534,8 +555,12 @@ describe("RedactoNoticeConsent", () => {
|
|
|
534
555
|
// Should transition to guardian form
|
|
535
556
|
await waitFor(
|
|
536
557
|
() => {
|
|
537
|
-
expect(
|
|
538
|
-
|
|
558
|
+
expect(
|
|
559
|
+
screen.getByText("Guardian Information Required")
|
|
560
|
+
).toBeInTheDocument();
|
|
561
|
+
expect(
|
|
562
|
+
screen.queryByText("Age Verification Required")
|
|
563
|
+
).not.toBeInTheDocument();
|
|
539
564
|
},
|
|
540
565
|
{ timeout: 3000 }
|
|
541
566
|
);
|
|
@@ -545,7 +570,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
545
570
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
546
571
|
await waitFor(
|
|
547
572
|
() => {
|
|
548
|
-
expect(
|
|
573
|
+
expect(
|
|
574
|
+
screen.getByText("Age Verification Required")
|
|
575
|
+
).toBeInTheDocument();
|
|
549
576
|
},
|
|
550
577
|
{ timeout: 3000 }
|
|
551
578
|
);
|
|
@@ -557,7 +584,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
557
584
|
// Should show guardian form
|
|
558
585
|
await waitFor(
|
|
559
586
|
() => {
|
|
560
|
-
expect(
|
|
587
|
+
expect(
|
|
588
|
+
screen.getByText("Guardian Information Required")
|
|
589
|
+
).toBeInTheDocument();
|
|
561
590
|
expect(
|
|
562
591
|
screen.getByText(/As you are under the age of consent/i)
|
|
563
592
|
).toBeInTheDocument();
|
|
@@ -568,7 +597,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
568
597
|
// Fill out guardian form
|
|
569
598
|
const nameInput = screen.getByLabelText(/Name of Guardian/i);
|
|
570
599
|
const contactInput = screen.getByLabelText(/Contact of Guardian/i);
|
|
571
|
-
const relationshipInput = screen.getByLabelText(
|
|
600
|
+
const relationshipInput = screen.getByLabelText(
|
|
601
|
+
/Relationship to Guardian/i
|
|
602
|
+
);
|
|
572
603
|
|
|
573
604
|
fireEvent.change(nameInput, { target: { value: "John Doe" } });
|
|
574
605
|
fireEvent.change(contactInput, { target: { value: "john@example.com" } });
|
|
@@ -581,7 +612,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
581
612
|
await waitFor(
|
|
582
613
|
() => {
|
|
583
614
|
expect(screen.getByText("Privacy Notice")).toBeInTheDocument();
|
|
584
|
-
expect(
|
|
615
|
+
expect(
|
|
616
|
+
screen.queryByText("Guardian Information Required")
|
|
617
|
+
).not.toBeInTheDocument();
|
|
585
618
|
},
|
|
586
619
|
{ timeout: 3000 }
|
|
587
620
|
);
|
|
@@ -591,7 +624,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
591
624
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
592
625
|
await waitFor(
|
|
593
626
|
() => {
|
|
594
|
-
expect(
|
|
627
|
+
expect(
|
|
628
|
+
screen.getByText("Age Verification Required")
|
|
629
|
+
).toBeInTheDocument();
|
|
595
630
|
},
|
|
596
631
|
{ timeout: 3000 }
|
|
597
632
|
);
|
|
@@ -603,9 +638,15 @@ describe("RedactoNoticeConsent", () => {
|
|
|
603
638
|
await waitFor(
|
|
604
639
|
() => {
|
|
605
640
|
expect(screen.getByAltText("Redacto Logo")).toBeInTheDocument();
|
|
606
|
-
expect(
|
|
607
|
-
|
|
608
|
-
|
|
641
|
+
expect(
|
|
642
|
+
screen.getByLabelText(/Name of Guardian/i)
|
|
643
|
+
).toBeInTheDocument();
|
|
644
|
+
expect(
|
|
645
|
+
screen.getByLabelText(/Contact of Guardian/i)
|
|
646
|
+
).toBeInTheDocument();
|
|
647
|
+
expect(
|
|
648
|
+
screen.getByLabelText(/Relationship to Guardian/i)
|
|
649
|
+
).toBeInTheDocument();
|
|
609
650
|
expect(screen.getByText("Next")).toBeInTheDocument();
|
|
610
651
|
expect(screen.getByText("Cancel")).toBeInTheDocument();
|
|
611
652
|
},
|
|
@@ -617,7 +658,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
617
658
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
618
659
|
await waitFor(
|
|
619
660
|
() => {
|
|
620
|
-
expect(
|
|
661
|
+
expect(
|
|
662
|
+
screen.getByText("Age Verification Required")
|
|
663
|
+
).toBeInTheDocument();
|
|
621
664
|
},
|
|
622
665
|
{ timeout: 3000 }
|
|
623
666
|
);
|
|
@@ -628,7 +671,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
628
671
|
|
|
629
672
|
await waitFor(
|
|
630
673
|
() => {
|
|
631
|
-
expect(
|
|
674
|
+
expect(
|
|
675
|
+
screen.getByText("Guardian Information Required")
|
|
676
|
+
).toBeInTheDocument();
|
|
632
677
|
},
|
|
633
678
|
{ timeout: 3000 }
|
|
634
679
|
);
|
|
@@ -638,9 +683,15 @@ describe("RedactoNoticeConsent", () => {
|
|
|
638
683
|
|
|
639
684
|
await waitFor(
|
|
640
685
|
() => {
|
|
641
|
-
expect(
|
|
642
|
-
|
|
643
|
-
|
|
686
|
+
expect(
|
|
687
|
+
screen.getByText("Guardian name is required")
|
|
688
|
+
).toBeInTheDocument();
|
|
689
|
+
expect(
|
|
690
|
+
screen.getByText("Guardian contact is required")
|
|
691
|
+
).toBeInTheDocument();
|
|
692
|
+
expect(
|
|
693
|
+
screen.getByText("Relationship to guardian is required")
|
|
694
|
+
).toBeInTheDocument();
|
|
644
695
|
},
|
|
645
696
|
{ timeout: 3000 }
|
|
646
697
|
);
|
|
@@ -650,7 +701,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
650
701
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
651
702
|
await waitFor(
|
|
652
703
|
() => {
|
|
653
|
-
expect(
|
|
704
|
+
expect(
|
|
705
|
+
screen.getByText("Age Verification Required")
|
|
706
|
+
).toBeInTheDocument();
|
|
654
707
|
},
|
|
655
708
|
{ timeout: 3000 }
|
|
656
709
|
);
|
|
@@ -661,7 +714,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
661
714
|
|
|
662
715
|
await waitFor(
|
|
663
716
|
() => {
|
|
664
|
-
expect(
|
|
717
|
+
expect(
|
|
718
|
+
screen.getByText("Guardian Information Required")
|
|
719
|
+
).toBeInTheDocument();
|
|
665
720
|
},
|
|
666
721
|
{ timeout: 3000 }
|
|
667
722
|
);
|
|
@@ -669,7 +724,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
669
724
|
// Fill out guardian form
|
|
670
725
|
const nameInput = screen.getByLabelText(/Name of Guardian/i);
|
|
671
726
|
const contactInput = screen.getByLabelText(/Contact of Guardian/i);
|
|
672
|
-
const relationshipInput = screen.getByLabelText(
|
|
727
|
+
const relationshipInput = screen.getByLabelText(
|
|
728
|
+
/Relationship to Guardian/i
|
|
729
|
+
);
|
|
673
730
|
|
|
674
731
|
fireEvent.change(nameInput, { target: { value: "John Doe" } });
|
|
675
732
|
fireEvent.change(contactInput, { target: { value: "john@example.com" } });
|
|
@@ -682,7 +739,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
682
739
|
await waitFor(
|
|
683
740
|
() => {
|
|
684
741
|
expect(screen.getByText("Privacy Notice")).toBeInTheDocument();
|
|
685
|
-
expect(
|
|
742
|
+
expect(
|
|
743
|
+
screen.queryByText("Guardian Information Required")
|
|
744
|
+
).not.toBeInTheDocument();
|
|
686
745
|
},
|
|
687
746
|
{ timeout: 3000 }
|
|
688
747
|
);
|
|
@@ -692,7 +751,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
692
751
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
693
752
|
await waitFor(
|
|
694
753
|
() => {
|
|
695
|
-
expect(
|
|
754
|
+
expect(
|
|
755
|
+
screen.getByText("Age Verification Required")
|
|
756
|
+
).toBeInTheDocument();
|
|
696
757
|
},
|
|
697
758
|
{ timeout: 3000 }
|
|
698
759
|
);
|
|
@@ -703,7 +764,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
703
764
|
|
|
704
765
|
await waitFor(
|
|
705
766
|
() => {
|
|
706
|
-
expect(
|
|
767
|
+
expect(
|
|
768
|
+
screen.getByText("Guardian Information Required")
|
|
769
|
+
).toBeInTheDocument();
|
|
707
770
|
},
|
|
708
771
|
{ timeout: 3000 }
|
|
709
772
|
);
|
|
@@ -711,7 +774,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
711
774
|
// Fill fields with only whitespace
|
|
712
775
|
const nameInput = screen.getByLabelText(/Name of Guardian/i);
|
|
713
776
|
const contactInput = screen.getByLabelText(/Contact of Guardian/i);
|
|
714
|
-
const relationshipInput = screen.getByLabelText(
|
|
777
|
+
const relationshipInput = screen.getByLabelText(
|
|
778
|
+
/Relationship to Guardian/i
|
|
779
|
+
);
|
|
715
780
|
|
|
716
781
|
fireEvent.change(nameInput, { target: { value: " " } });
|
|
717
782
|
fireEvent.change(contactInput, { target: { value: "\t\t" } });
|
|
@@ -723,9 +788,15 @@ describe("RedactoNoticeConsent", () => {
|
|
|
723
788
|
// Should still show validation errors for whitespace-only input
|
|
724
789
|
await waitFor(
|
|
725
790
|
() => {
|
|
726
|
-
expect(
|
|
727
|
-
|
|
728
|
-
|
|
791
|
+
expect(
|
|
792
|
+
screen.getByText("Guardian name is required")
|
|
793
|
+
).toBeInTheDocument();
|
|
794
|
+
expect(
|
|
795
|
+
screen.getByText("Guardian contact is required")
|
|
796
|
+
).toBeInTheDocument();
|
|
797
|
+
expect(
|
|
798
|
+
screen.getByText("Relationship to guardian is required")
|
|
799
|
+
).toBeInTheDocument();
|
|
729
800
|
},
|
|
730
801
|
{ timeout: 3000 }
|
|
731
802
|
);
|
|
@@ -735,7 +806,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
735
806
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
736
807
|
await waitFor(
|
|
737
808
|
() => {
|
|
738
|
-
expect(
|
|
809
|
+
expect(
|
|
810
|
+
screen.getByText("Age Verification Required")
|
|
811
|
+
).toBeInTheDocument();
|
|
739
812
|
},
|
|
740
813
|
{ timeout: 3000 }
|
|
741
814
|
);
|
|
@@ -746,7 +819,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
746
819
|
|
|
747
820
|
await waitFor(
|
|
748
821
|
() => {
|
|
749
|
-
expect(
|
|
822
|
+
expect(
|
|
823
|
+
screen.getByText("Guardian Information Required")
|
|
824
|
+
).toBeInTheDocument();
|
|
750
825
|
},
|
|
751
826
|
{ timeout: 3000 }
|
|
752
827
|
);
|
|
@@ -757,7 +832,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
757
832
|
|
|
758
833
|
await waitFor(
|
|
759
834
|
() => {
|
|
760
|
-
expect(
|
|
835
|
+
expect(
|
|
836
|
+
screen.getByText("Guardian name is required")
|
|
837
|
+
).toBeInTheDocument();
|
|
761
838
|
},
|
|
762
839
|
{ timeout: 3000 }
|
|
763
840
|
);
|
|
@@ -769,7 +846,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
769
846
|
// Error should be cleared
|
|
770
847
|
await waitFor(
|
|
771
848
|
() => {
|
|
772
|
-
expect(
|
|
849
|
+
expect(
|
|
850
|
+
screen.queryByText("Guardian name is required")
|
|
851
|
+
).not.toBeInTheDocument();
|
|
773
852
|
},
|
|
774
853
|
{ timeout: 3000 }
|
|
775
854
|
);
|
|
@@ -779,7 +858,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
779
858
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
780
859
|
await waitFor(
|
|
781
860
|
() => {
|
|
782
|
-
expect(
|
|
861
|
+
expect(
|
|
862
|
+
screen.getByText("Age Verification Required")
|
|
863
|
+
).toBeInTheDocument();
|
|
783
864
|
},
|
|
784
865
|
{ timeout: 3000 }
|
|
785
866
|
);
|
|
@@ -790,7 +871,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
790
871
|
|
|
791
872
|
await waitFor(
|
|
792
873
|
() => {
|
|
793
|
-
expect(
|
|
874
|
+
expect(
|
|
875
|
+
screen.getByText("Guardian Information Required")
|
|
876
|
+
).toBeInTheDocument();
|
|
794
877
|
},
|
|
795
878
|
{ timeout: 3000 }
|
|
796
879
|
);
|
|
@@ -810,7 +893,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
810
893
|
render(<RedactoNoticeConsent {...defaultProps} />);
|
|
811
894
|
await waitFor(
|
|
812
895
|
() => {
|
|
813
|
-
expect(
|
|
896
|
+
expect(
|
|
897
|
+
screen.getByText("Age Verification Required")
|
|
898
|
+
).toBeInTheDocument();
|
|
814
899
|
},
|
|
815
900
|
{ timeout: 3000 }
|
|
816
901
|
);
|
|
@@ -821,7 +906,9 @@ describe("RedactoNoticeConsent", () => {
|
|
|
821
906
|
|
|
822
907
|
await waitFor(
|
|
823
908
|
() => {
|
|
824
|
-
expect(
|
|
909
|
+
expect(
|
|
910
|
+
screen.getByText("Guardian Information Required")
|
|
911
|
+
).toBeInTheDocument();
|
|
825
912
|
},
|
|
826
913
|
{ timeout: 3000 }
|
|
827
914
|
);
|
|
@@ -699,7 +699,7 @@ export const RedactoNoticeConsent = ({
|
|
|
699
699
|
onError,
|
|
700
700
|
settings,
|
|
701
701
|
applicationId,
|
|
702
|
-
|
|
702
|
+
validateAgainst = "all",
|
|
703
703
|
}: Props) => {
|
|
704
704
|
// =============================================================================
|
|
705
705
|
// PROP VALIDATION
|
|
@@ -1050,7 +1050,7 @@ export const RedactoNoticeConsent = ({
|
|
|
1050
1050
|
baseUrl,
|
|
1051
1051
|
language,
|
|
1052
1052
|
specific_uuid: applicationId,
|
|
1053
|
-
|
|
1053
|
+
validate_against: validateAgainst,
|
|
1054
1054
|
signal: abortControllerRef.current?.signal,
|
|
1055
1055
|
});
|
|
1056
1056
|
setContent(consentContentData.detail.active_config);
|
|
@@ -1188,7 +1188,7 @@ export const RedactoNoticeConsent = ({
|
|
|
1188
1188
|
refreshToken,
|
|
1189
1189
|
language,
|
|
1190
1190
|
applicationId,
|
|
1191
|
-
|
|
1191
|
+
validateAgainst,
|
|
1192
1192
|
// Removed onError and isRefreshingToken from dependencies to prevent duplicate API calls
|
|
1193
1193
|
// onError is only called on errors, not needed for initial data fetching
|
|
1194
1194
|
]);
|
|
@@ -64,12 +64,12 @@ export const fetchConsentContent = async ({
|
|
|
64
64
|
baseUrl,
|
|
65
65
|
language = "en",
|
|
66
66
|
specific_uuid,
|
|
67
|
-
|
|
67
|
+
validate_against = "all",
|
|
68
68
|
signal, // AbortSignal for request cancellation
|
|
69
69
|
}: FetchConsentContentParams & { signal?: AbortSignal }): Promise<ConsentContent> => {
|
|
70
70
|
try {
|
|
71
71
|
// Validate required parameters
|
|
72
|
-
if (!noticeId || !accessToken) {
|
|
72
|
+
if (!noticeId || !accessToken || !validate_against) {
|
|
73
73
|
throw new Error("noticeId and accessToken are required");
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -86,10 +86,10 @@ export const fetchConsentContent = async ({
|
|
|
86
86
|
const apiBaseUrl = baseUrl || BASE_URL;
|
|
87
87
|
|
|
88
88
|
// Create cache key for this request - include accessToken to ensure different users get different cache
|
|
89
|
-
const cacheKey = `${accessToken}-${noticeId}-${
|
|
89
|
+
const cacheKey = `${accessToken}-${noticeId}-${validate_against}-${language}-${specific_uuid || ''}`;
|
|
90
90
|
|
|
91
91
|
// Check cache first (skip for reconsent requests as they need fresh data)
|
|
92
|
-
if (
|
|
92
|
+
if (validate_against === "all" && !specific_uuid) {
|
|
93
93
|
const cachedData = getCachedData(cacheKey);
|
|
94
94
|
if (cachedData) {
|
|
95
95
|
return cachedData;
|
|
@@ -103,7 +103,7 @@ export const fetchConsentContent = async ({
|
|
|
103
103
|
if (specific_uuid) {
|
|
104
104
|
url.searchParams.append("specific_uuid", specific_uuid);
|
|
105
105
|
}
|
|
106
|
-
url.searchParams.append("
|
|
106
|
+
url.searchParams.append("validate_against", validate_against);
|
|
107
107
|
|
|
108
108
|
const response = await fetch(url.toString(), {
|
|
109
109
|
method: "GET",
|
|
@@ -138,7 +138,7 @@ export const fetchConsentContent = async ({
|
|
|
138
138
|
const data: ConsentContent = await response.json();
|
|
139
139
|
|
|
140
140
|
// Cache successful responses (skip for reconsent as data may change)
|
|
141
|
-
if (
|
|
141
|
+
if (validate_against === "all" && !specific_uuid) {
|
|
142
142
|
setCachedData(cacheKey, data);
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -219,7 +219,7 @@ export const submitConsentEvent = async ({
|
|
|
219
219
|
const apiBaseUrl = baseUrl || BASE_URL;
|
|
220
220
|
|
|
221
221
|
const response = await fetch(
|
|
222
|
-
`${apiBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/
|
|
222
|
+
`${apiBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/submit-consent`,
|
|
223
223
|
{
|
|
224
224
|
method: "POST",
|
|
225
225
|
headers: {
|