@paypal/checkout-components 5.0.365 → 5.0.366

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.365",
3
+ "version": "5.0.366",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -330,6 +330,7 @@ export type ButtonStyle = {|
330
330
  disableMaxHeight?: boolean,
331
331
  borderRadius?: number,
332
332
  shouldApplyRebrandedStyles: boolean,
333
+ isButtonColorABTestMerchant: boolean,
333
334
  |};
334
335
 
335
336
  export type ButtonStyleInputs = {|
@@ -516,6 +517,7 @@ type HidePayPalAppSwitchOverlay = {|
516
517
  type ButtonColor = {|
517
518
  shouldApplyRebrandedStyles: boolean,
518
519
  color: $Values<typeof BUTTON_COLOR>,
520
+ isButtonColorABTestMerchant: boolean,
519
521
  |};
520
522
 
521
523
  type ColorABTestStorage = {|
@@ -738,6 +740,7 @@ export function determineRandomButtonColor({
738
740
  return {
739
741
  shouldApplyRebrandedStyles,
740
742
  color: buttonColor,
743
+ isButtonColorABTestMerchant: true,
741
744
  };
742
745
  }
743
746
 
@@ -876,6 +879,7 @@ export function getColorForFullRedesign({
876
879
  return {
877
880
  color: buttonColor,
878
881
  shouldApplyRebrandedStyles: true,
882
+ isButtonColorABTestMerchant: false,
879
883
  };
880
884
  }
881
885
 
@@ -953,6 +957,7 @@ export function getButtonColor({
953
957
  fundingSource,
954
958
  style,
955
959
  }),
960
+ isButtonColorABTestMerchant: false,
956
961
  };
957
962
  }
958
963
  }
@@ -971,7 +976,8 @@ export function normalizeButtonStyle(
971
976
 
972
977
  props = props || getDefaultButtonPropsInput();
973
978
  const { fundingSource, buttonColor } = props;
974
- const { color, shouldApplyRebrandedStyles } = buttonColor || {};
979
+ const { color, shouldApplyRebrandedStyles, isButtonColorABTestMerchant } =
980
+ buttonColor || {};
975
981
 
976
982
  const FUNDING_CONFIG = getFundingConfig();
977
983
  const fundingConfig =
@@ -1118,6 +1124,7 @@ export function normalizeButtonStyle(
1118
1124
  disableMaxHeight,
1119
1125
  borderRadius,
1120
1126
  shouldApplyRebrandedStyles,
1127
+ isButtonColorABTestMerchant,
1121
1128
  };
1122
1129
  }
1123
1130
 
@@ -81,6 +81,7 @@ describe("determineRandomButtonColor", () => {
81
81
  expect(result).toEqual({
82
82
  shouldApplyRebrandedStyles: true,
83
83
  color: BUTTON_COLOR.REBRAND_BLUE,
84
+ isButtonColorABTestMerchant: true,
84
85
  });
85
86
  });
86
87
 
@@ -94,6 +95,7 @@ describe("determineRandomButtonColor", () => {
94
95
  expect(result).toEqual({
95
96
  shouldApplyRebrandedStyles: true,
96
97
  color: BUTTON_COLOR.REBRAND_DARKBLUE,
98
+ isButtonColorABTestMerchant: true,
97
99
  });
98
100
  });
99
101
 
@@ -107,6 +109,7 @@ describe("determineRandomButtonColor", () => {
107
109
  expect(result).toEqual({
108
110
  shouldApplyRebrandedStyles: false,
109
111
  color: BUTTON_COLOR.BLACK,
112
+ isButtonColorABTestMerchant: true,
110
113
  });
111
114
  });
112
115
 
@@ -120,6 +123,7 @@ describe("determineRandomButtonColor", () => {
120
123
  expect(result).toEqual({
121
124
  shouldApplyRebrandedStyles: false,
122
125
  color: BUTTON_COLOR.GOLD,
126
+ isButtonColorABTestMerchant: true,
123
127
  });
124
128
  });
125
129
  });
@@ -494,6 +498,7 @@ describe("getColorForFullRedesign", () => {
494
498
  expect(result).toEqual({
495
499
  color: BUTTON_COLOR.REBRAND_BLUE,
496
500
  shouldApplyRebrandedStyles: true,
501
+ isButtonColorABTestMerchant: false,
497
502
  });
498
503
  });
499
504
 
@@ -507,6 +512,7 @@ describe("getColorForFullRedesign", () => {
507
512
  expect(result).toEqual({
508
513
  color: BUTTON_COLOR.REBRAND_DARKBLUE,
509
514
  shouldApplyRebrandedStyles: true,
515
+ isButtonColorABTestMerchant: false,
510
516
  });
511
517
  });
512
518
 
@@ -520,6 +526,7 @@ describe("getColorForFullRedesign", () => {
520
526
  expect(result).toEqual({
521
527
  color: BUTTON_COLOR.REBRAND_BLUE,
522
528
  shouldApplyRebrandedStyles: true,
529
+ isButtonColorABTestMerchant: false,
523
530
  });
524
531
  });
525
532
 
@@ -533,6 +540,7 @@ describe("getColorForFullRedesign", () => {
533
540
  expect(result).toEqual({
534
541
  color: BUTTON_COLOR.REBRAND_DARKBLUE,
535
542
  shouldApplyRebrandedStyles: true,
543
+ isButtonColorABTestMerchant: false,
536
544
  });
537
545
  });
538
546
 
@@ -577,6 +585,7 @@ describe("getColorForFullRedesign", () => {
577
585
  expect(result).toEqual({
578
586
  color: BUTTON_COLOR.REBRAND_BLUE,
579
587
  shouldApplyRebrandedStyles: true,
588
+ isButtonColorABTestMerchant: false,
580
589
  });
581
590
  });
582
591
 
@@ -740,6 +749,7 @@ describe("getButtonColor", () => {
740
749
  expect(result).toEqual({
741
750
  color: BUTTON_COLOR.GOLD,
742
751
  shouldApplyRebrandedStyles: false,
752
+ isButtonColorABTestMerchant: false,
743
753
  });
744
754
  });
745
755
 
@@ -765,9 +775,36 @@ describe("getButtonColor", () => {
765
775
  expect(result).toEqual({
766
776
  color: BUTTON_COLOR.REBRAND_BLUE,
767
777
  shouldApplyRebrandedStyles: true,
778
+ isButtonColorABTestMerchant: false,
768
779
  });
769
780
  });
770
781
 
782
+ it("should return isButtonColorABTestMerchant === true for eligible AB Test Merchants and SDK configurations", () => {
783
+ const style = { color: BUTTON_COLOR.BLUE };
784
+ const storageState = { get: vi.fn(), set: vi.fn() };
785
+ const sessionID = "test-session";
786
+ const fundingSource = FUNDING.PAYPAL;
787
+ const experiment = {
788
+ isPaypalRebrandEnabled: true,
789
+ isPaypalRebrandABTestEnabled: true,
790
+ };
791
+
792
+ const result = getButtonColor({
793
+ experiment,
794
+ // $FlowFixMe
795
+ style,
796
+ sessionID,
797
+ storageState,
798
+ fundingSource,
799
+ });
800
+
801
+ expect(result).toEqual(
802
+ expect.objectContaining({
803
+ isButtonColorABTestMerchant: true,
804
+ })
805
+ );
806
+ });
807
+
771
808
  it("should return the default color for non-PayPal funding sources", () => {
772
809
  const style = { color: BUTTON_COLOR.BLUE };
773
810
  const storageState = { get: vi.fn(), set: vi.fn() };
@@ -790,6 +827,7 @@ describe("getButtonColor", () => {
790
827
  expect(result).toEqual({
791
828
  color: BUTTON_COLOR.BLUE,
792
829
  shouldApplyRebrandedStyles: false,
830
+ isButtonColorABTestMerchant: false,
793
831
  });
794
832
  });
795
833
 
@@ -814,6 +852,7 @@ describe("getButtonColor", () => {
814
852
  expect(result).toEqual({
815
853
  color: BUTTON_COLOR.WHITE,
816
854
  shouldApplyRebrandedStyles: false,
855
+ isButtonColorABTestMerchant: false,
817
856
  });
818
857
  });
819
858
 
@@ -825,6 +864,7 @@ describe("getButtonColor", () => {
825
864
  expect(result).toEqual({
826
865
  color: BUTTON_COLOR.GOLD,
827
866
  shouldApplyRebrandedStyles: false,
867
+ isButtonColorABTestMerchant: false,
828
868
  });
829
869
  });
830
870
  });
@@ -115,6 +115,13 @@ export function getComponentScript(): () => void {
115
115
  }
116
116
 
117
117
  function calculateGap(optionalParent: HTMLElement): number {
118
+ const isTagline = optionalParent?.classList.contains(
119
+ "paypal-button-tagline" || false
120
+ );
121
+
122
+ if (isTagline) {
123
+ return 0;
124
+ }
118
125
  // Get the button element
119
126
  const parentElement = optionalParent.parentElement;
120
127