@paypal/checkout-components 5.0.416 → 5.0.420
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/dist/button.js +1 -1
- package/dist/test/button.js +1 -1
- package/package.json +2 -2
- package/src/constants/button.js +0 -8
- package/src/funding/applepay/config.jsx +19 -1
- package/src/funding/card/config.jsx +15 -9
- package/src/funding/card/config.test.jsx +4 -8
- package/src/funding/common.jsx +51 -14
- package/src/funding/credit/config.jsx +16 -17
- package/src/funding/index.js +1 -0
- package/src/funding/itau/config.jsx +23 -5
- package/src/funding/paylater/config.jsx +9 -13
- package/src/funding/paypal/config.jsx +13 -8
- package/src/funding/sepa/config.jsx +11 -8
- package/src/funding/util.js +37 -0
- package/src/funding/util.test.js +84 -1
- package/src/funding/venmo/config.jsx +22 -12
- package/src/ui/buttons/button.jsx +9 -12
- package/src/ui/buttons/poweredBy.jsx +8 -8
- package/src/ui/buttons/props.js +55 -40
- package/src/ui/buttons/props.test.js +139 -77
- package/src/ui/buttons/styles/color.js +30 -26
- package/src/zoid/buttons/component.jsx +4 -3
- package/src/zoid/buttons/prerender.jsx +2 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { describe, expect, it, beforeEach, vi } from "vitest";
|
|
3
3
|
import { FUNDING } from "@paypal/sdk-constants";
|
|
4
4
|
|
|
5
|
-
import { BUTTON_COLOR } from "../../constants";
|
|
5
|
+
import { BUTTON_COLOR, BUTTON_LAYOUT, BUTTON_SHAPE } from "../../constants";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
getButtonColor,
|
|
@@ -13,8 +13,20 @@ import {
|
|
|
13
13
|
throwErrorForInvalidButtonColor,
|
|
14
14
|
determineRandomButtonColor,
|
|
15
15
|
getColorABTestFromStorage,
|
|
16
|
+
getBrandVersion,
|
|
17
|
+
normalizeButtonStyle,
|
|
16
18
|
} from "./props";
|
|
17
19
|
|
|
20
|
+
describe("getBrandVersion", () => {
|
|
21
|
+
it("should return v2 when rebrand styles are applied", () => {
|
|
22
|
+
expect(getBrandVersion({ shouldApplyRebrandedStyles: true })).toBe("v2");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should return v1 when rebrand styles are not applied", () => {
|
|
26
|
+
expect(getBrandVersion({ shouldApplyRebrandedStyles: false })).toBe("v1");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
18
30
|
describe("getColorABTestFromStorage", () => {
|
|
19
31
|
it("should return null when storage state has no colorABTest value", () => {
|
|
20
32
|
const storageState = {
|
|
@@ -43,7 +55,7 @@ describe("getColorABTestFromStorage", () => {
|
|
|
43
55
|
it("should return value when storage state has colorABTest with value property", () => {
|
|
44
56
|
const mockStoredValue = {
|
|
45
57
|
shouldApplyRebrandedStyles: true,
|
|
46
|
-
color: BUTTON_COLOR.
|
|
58
|
+
color: BUTTON_COLOR.BLUE,
|
|
47
59
|
sessionID: "test-session",
|
|
48
60
|
};
|
|
49
61
|
|
|
@@ -70,7 +82,7 @@ describe("determineRandomButtonColor", () => {
|
|
|
70
82
|
mathRandomSpy.mockRestore();
|
|
71
83
|
});
|
|
72
84
|
|
|
73
|
-
it("should return rebrand blue when random value is less than 0.
|
|
85
|
+
it("should return rebrand blue when random value is less than 0.5", () => {
|
|
74
86
|
mathRandomSpy.mockReturnValue(0);
|
|
75
87
|
|
|
76
88
|
const result = determineRandomButtonColor({
|
|
@@ -79,26 +91,13 @@ describe("determineRandomButtonColor", () => {
|
|
|
79
91
|
|
|
80
92
|
expect(result).toEqual({
|
|
81
93
|
shouldApplyRebrandedStyles: true,
|
|
82
|
-
color: BUTTON_COLOR.
|
|
83
|
-
isButtonColorABTestMerchant: true,
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("should return rebrand darkblue when random value is between 0.33 and 0.67", () => {
|
|
88
|
-
mathRandomSpy.mockReturnValue(0.4);
|
|
89
|
-
|
|
90
|
-
const result = determineRandomButtonColor({
|
|
91
|
-
buttonColorInput: BUTTON_COLOR.GOLD,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
expect(result).toEqual({
|
|
95
|
-
shouldApplyRebrandedStyles: true,
|
|
96
|
-
color: BUTTON_COLOR.REBRAND_DARKBLUE,
|
|
94
|
+
color: BUTTON_COLOR.BLUE,
|
|
97
95
|
isButtonColorABTestMerchant: true,
|
|
96
|
+
brandVersion: "v2",
|
|
98
97
|
});
|
|
99
98
|
});
|
|
100
99
|
|
|
101
|
-
it("should return provided buttonColorInput when random value is above 0.
|
|
100
|
+
it("should return provided buttonColorInput when random value is above 0.5", () => {
|
|
102
101
|
mathRandomSpy.mockReturnValue(0.8);
|
|
103
102
|
|
|
104
103
|
const result = determineRandomButtonColor({
|
|
@@ -109,6 +108,7 @@ describe("determineRandomButtonColor", () => {
|
|
|
109
108
|
shouldApplyRebrandedStyles: false,
|
|
110
109
|
color: BUTTON_COLOR.BLACK,
|
|
111
110
|
isButtonColorABTestMerchant: true,
|
|
111
|
+
brandVersion: "v1",
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
114
|
|
|
@@ -123,6 +123,7 @@ describe("determineRandomButtonColor", () => {
|
|
|
123
123
|
shouldApplyRebrandedStyles: false,
|
|
124
124
|
color: BUTTON_COLOR.GOLD,
|
|
125
125
|
isButtonColorABTestMerchant: true,
|
|
126
|
+
brandVersion: "v1",
|
|
126
127
|
});
|
|
127
128
|
});
|
|
128
129
|
});
|
|
@@ -171,55 +172,46 @@ describe("throwErrorForInvalidButtonColor", () => {
|
|
|
171
172
|
});
|
|
172
173
|
}).toThrow(/paypal/i);
|
|
173
174
|
});
|
|
174
|
-
|
|
175
|
-
it("should filter out rebranded colors from error message", () => {
|
|
176
|
-
// Define a local helper function to capture error message
|
|
177
|
-
function getErrorMessage(fn): string {
|
|
178
|
-
try {
|
|
179
|
-
fn();
|
|
180
|
-
return "";
|
|
181
|
-
} catch (err) {
|
|
182
|
-
return err.message;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const errorMessage = getErrorMessage(() => {
|
|
187
|
-
throwErrorForInvalidButtonColor({
|
|
188
|
-
fundingSource: FUNDING.PAYPAL,
|
|
189
|
-
fundingSourceColors: [
|
|
190
|
-
BUTTON_COLOR.GOLD,
|
|
191
|
-
BUTTON_COLOR.BLUE,
|
|
192
|
-
BUTTON_COLOR.REBRAND_BLUE, // This should be filtered out
|
|
193
|
-
],
|
|
194
|
-
invalidButtonColor: BUTTON_COLOR.BLACK,
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// Check that the error message contains gold and blue
|
|
199
|
-
expect(errorMessage).toMatch(/gold/i);
|
|
200
|
-
expect(errorMessage).toMatch(/blue/i);
|
|
201
|
-
|
|
202
|
-
// Check that the error message doesn't contain rebrand_blue
|
|
203
|
-
expect(errorMessage).not.toMatch(/rebrand_blue/i);
|
|
204
|
-
});
|
|
205
175
|
});
|
|
206
176
|
|
|
207
177
|
describe("getDefaultColorForFundingSource", () => {
|
|
208
178
|
beforeEach(() => {
|
|
209
179
|
// Mock getFundingConfig to return consistent test data
|
|
210
|
-
vi.mock("../../funding", () =>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
180
|
+
vi.mock("../../funding", async (importOriginal) => {
|
|
181
|
+
const actual = await importOriginal();
|
|
182
|
+
return {
|
|
183
|
+
...actual,
|
|
184
|
+
getFundingConfig: () => ({
|
|
185
|
+
[FUNDING.PAYPAL]: {
|
|
186
|
+
colors: [
|
|
187
|
+
BUTTON_COLOR.GOLD,
|
|
188
|
+
BUTTON_COLOR.BLUE,
|
|
189
|
+
BUTTON_COLOR.SILVER,
|
|
190
|
+
BUTTON_COLOR.WHITE,
|
|
191
|
+
],
|
|
192
|
+
colorsRebrand: [
|
|
193
|
+
BUTTON_COLOR.BLUE,
|
|
194
|
+
BUTTON_COLOR.BLACK,
|
|
195
|
+
BUTTON_COLOR.WHITE,
|
|
196
|
+
],
|
|
197
|
+
layouts: [BUTTON_LAYOUT.VERTICAL, BUTTON_LAYOUT.HORIZONTAL],
|
|
198
|
+
shapes: [BUTTON_SHAPE.RECT, BUTTON_SHAPE.PILL, BUTTON_SHAPE.SHARP],
|
|
199
|
+
logoColors: {},
|
|
200
|
+
logoColorsRebrand: {},
|
|
201
|
+
textColors: {},
|
|
202
|
+
textColorsRebrand: {},
|
|
203
|
+
secondaryColors: {},
|
|
204
|
+
secondaryColorsRebrand: {},
|
|
205
|
+
},
|
|
206
|
+
[FUNDING.VENMO]: {
|
|
207
|
+
colors: [BUTTON_COLOR.BLUE],
|
|
208
|
+
},
|
|
209
|
+
[FUNDING.PAYLATER]: {
|
|
210
|
+
colors: [BUTTON_COLOR.WHITE, BUTTON_COLOR.BLACK],
|
|
211
|
+
},
|
|
212
|
+
}),
|
|
213
|
+
};
|
|
214
|
+
});
|
|
223
215
|
});
|
|
224
216
|
|
|
225
217
|
afterEach(() => {
|
|
@@ -229,6 +221,7 @@ describe("getDefaultColorForFundingSource", () => {
|
|
|
229
221
|
it("should return the first color in the funding source config when style.color is undefined", () => {
|
|
230
222
|
const result = getDefaultColorForFundingSource({
|
|
231
223
|
fundingSource: FUNDING.PAYPAL,
|
|
224
|
+
shouldApplyRebrandedStyles: false,
|
|
232
225
|
// $FlowFixMe
|
|
233
226
|
style: {},
|
|
234
227
|
});
|
|
@@ -239,6 +232,7 @@ describe("getDefaultColorForFundingSource", () => {
|
|
|
239
232
|
it("should return style.color if it is valid for the funding source", () => {
|
|
240
233
|
const result = getDefaultColorForFundingSource({
|
|
241
234
|
fundingSource: FUNDING.PAYPAL,
|
|
235
|
+
shouldApplyRebrandedStyles: false,
|
|
242
236
|
// $FlowFixMe
|
|
243
237
|
style: { color: BUTTON_COLOR.BLUE },
|
|
244
238
|
});
|
|
@@ -250,6 +244,7 @@ describe("getDefaultColorForFundingSource", () => {
|
|
|
250
244
|
expect(() => {
|
|
251
245
|
getDefaultColorForFundingSource({
|
|
252
246
|
fundingSource: FUNDING.PAYPAL,
|
|
247
|
+
shouldApplyRebrandedStyles: false,
|
|
253
248
|
// $FlowFixMe
|
|
254
249
|
style: { color: BUTTON_COLOR.BLACK },
|
|
255
250
|
});
|
|
@@ -259,18 +254,21 @@ describe("getDefaultColorForFundingSource", () => {
|
|
|
259
254
|
it("should return different default colors for different funding sources", () => {
|
|
260
255
|
const paypalResult = getDefaultColorForFundingSource({
|
|
261
256
|
fundingSource: FUNDING.PAYPAL,
|
|
257
|
+
shouldApplyRebrandedStyles: false,
|
|
262
258
|
// $FlowFixMe
|
|
263
259
|
style: {},
|
|
264
260
|
});
|
|
265
261
|
|
|
266
262
|
const venmoResult = getDefaultColorForFundingSource({
|
|
267
263
|
fundingSource: FUNDING.VENMO,
|
|
264
|
+
shouldApplyRebrandedStyles: false,
|
|
268
265
|
// $FlowFixMe
|
|
269
266
|
style: {},
|
|
270
267
|
});
|
|
271
268
|
|
|
272
269
|
const paylaterResult = getDefaultColorForFundingSource({
|
|
273
270
|
fundingSource: FUNDING.PAYLATER,
|
|
271
|
+
shouldApplyRebrandedStyles: false,
|
|
274
272
|
// $FlowFixMe
|
|
275
273
|
style: {},
|
|
276
274
|
});
|
|
@@ -283,6 +281,7 @@ describe("getDefaultColorForFundingSource", () => {
|
|
|
283
281
|
it("should default to GOLD for smart stack (fundingSource is undefined)", () => {
|
|
284
282
|
const result = getDefaultColorForFundingSource({
|
|
285
283
|
fundingSource: FUNDING.IDEAL,
|
|
284
|
+
shouldApplyRebrandedStyles: false,
|
|
286
285
|
// $FlowFixMe
|
|
287
286
|
style: {},
|
|
288
287
|
});
|
|
@@ -293,6 +292,7 @@ describe("getDefaultColorForFundingSource", () => {
|
|
|
293
292
|
it("should return style.color if provided for smart stack (fundingSource is undefined)", () => {
|
|
294
293
|
const result = getDefaultColorForFundingSource({
|
|
295
294
|
fundingSource: FUNDING.IDEAL,
|
|
295
|
+
shouldApplyRebrandedStyles: false,
|
|
296
296
|
// $FlowFixMe
|
|
297
297
|
style: { color: BUTTON_COLOR.BLACK },
|
|
298
298
|
});
|
|
@@ -303,6 +303,7 @@ describe("getDefaultColorForFundingSource", () => {
|
|
|
303
303
|
it("should handle null style", () => {
|
|
304
304
|
const result = getDefaultColorForFundingSource({
|
|
305
305
|
fundingSource: FUNDING.PAYPAL,
|
|
306
|
+
shouldApplyRebrandedStyles: false,
|
|
306
307
|
style: null,
|
|
307
308
|
});
|
|
308
309
|
|
|
@@ -312,6 +313,7 @@ describe("getDefaultColorForFundingSource", () => {
|
|
|
312
313
|
it("should handle undefined fundingSource", () => {
|
|
313
314
|
const result = getDefaultColorForFundingSource({
|
|
314
315
|
fundingSource: undefined,
|
|
316
|
+
shouldApplyRebrandedStyles: false,
|
|
315
317
|
// $FlowFixMe
|
|
316
318
|
style: {},
|
|
317
319
|
});
|
|
@@ -324,9 +326,10 @@ describe("getColorForABTest", () => {
|
|
|
324
326
|
it("should return color from storage if sessionID matches", () => {
|
|
325
327
|
const mockSessionID = "test-session-123";
|
|
326
328
|
const mockStoredValue = {
|
|
327
|
-
color: BUTTON_COLOR.
|
|
329
|
+
color: BUTTON_COLOR.BLUE,
|
|
328
330
|
shouldApplyRebrandedStyles: true,
|
|
329
331
|
sessionID: mockSessionID,
|
|
332
|
+
brandVersion: "v2",
|
|
330
333
|
};
|
|
331
334
|
|
|
332
335
|
const storageState = {
|
|
@@ -342,8 +345,9 @@ describe("getColorForABTest", () => {
|
|
|
342
345
|
});
|
|
343
346
|
|
|
344
347
|
expect(result).toEqual({
|
|
345
|
-
color: BUTTON_COLOR.
|
|
348
|
+
color: BUTTON_COLOR.BLUE,
|
|
346
349
|
shouldApplyRebrandedStyles: true,
|
|
350
|
+
brandVersion: "v2",
|
|
347
351
|
});
|
|
348
352
|
expect(storageState.get).toHaveBeenCalledWith("colorABTest");
|
|
349
353
|
expect(storageState.set).not.toHaveBeenCalled();
|
|
@@ -352,7 +356,7 @@ describe("getColorForABTest", () => {
|
|
|
352
356
|
it("should generate new color and save it if sessionID does not match", () => {
|
|
353
357
|
const mockSessionID = "new-session-456";
|
|
354
358
|
const mockStoredValue = {
|
|
355
|
-
color: BUTTON_COLOR.
|
|
359
|
+
color: BUTTON_COLOR.BLUE,
|
|
356
360
|
shouldApplyRebrandedStyles: true,
|
|
357
361
|
sessionID: "old-session-123",
|
|
358
362
|
};
|
|
@@ -439,7 +443,7 @@ describe("getColorForABTest", () => {
|
|
|
439
443
|
});
|
|
440
444
|
|
|
441
445
|
describe("getColorForFullRedesign", () => {
|
|
442
|
-
it("should
|
|
446
|
+
it("should keep BLUE as BLUE", () => {
|
|
443
447
|
const result = getColorForFullRedesign({
|
|
444
448
|
// $FlowFixMe
|
|
445
449
|
style: { color: BUTTON_COLOR.BLUE },
|
|
@@ -447,13 +451,14 @@ describe("getColorForFullRedesign", () => {
|
|
|
447
451
|
});
|
|
448
452
|
|
|
449
453
|
expect(result).toEqual({
|
|
450
|
-
color: BUTTON_COLOR.
|
|
454
|
+
color: BUTTON_COLOR.BLUE,
|
|
451
455
|
shouldApplyRebrandedStyles: true,
|
|
452
456
|
isButtonColorABTestMerchant: false,
|
|
457
|
+
brandVersion: "v2",
|
|
453
458
|
});
|
|
454
459
|
});
|
|
455
460
|
|
|
456
|
-
it("should map DARKBLUE to
|
|
461
|
+
it("should map DARKBLUE to BLUE", () => {
|
|
457
462
|
const result = getColorForFullRedesign({
|
|
458
463
|
// $FlowFixMe
|
|
459
464
|
style: { color: BUTTON_COLOR.DARKBLUE },
|
|
@@ -461,13 +466,14 @@ describe("getColorForFullRedesign", () => {
|
|
|
461
466
|
});
|
|
462
467
|
|
|
463
468
|
expect(result).toEqual({
|
|
464
|
-
color: BUTTON_COLOR.
|
|
469
|
+
color: BUTTON_COLOR.BLUE,
|
|
465
470
|
shouldApplyRebrandedStyles: true,
|
|
466
471
|
isButtonColorABTestMerchant: false,
|
|
472
|
+
brandVersion: "v2",
|
|
467
473
|
});
|
|
468
474
|
});
|
|
469
475
|
|
|
470
|
-
it("should map GOLD to
|
|
476
|
+
it("should map GOLD to BLUE", () => {
|
|
471
477
|
const result = getColorForFullRedesign({
|
|
472
478
|
// $FlowFixMe
|
|
473
479
|
style: { color: BUTTON_COLOR.GOLD },
|
|
@@ -475,23 +481,25 @@ describe("getColorForFullRedesign", () => {
|
|
|
475
481
|
});
|
|
476
482
|
|
|
477
483
|
expect(result).toEqual({
|
|
478
|
-
color: BUTTON_COLOR.
|
|
484
|
+
color: BUTTON_COLOR.BLUE,
|
|
479
485
|
shouldApplyRebrandedStyles: true,
|
|
480
486
|
isButtonColorABTestMerchant: false,
|
|
487
|
+
brandVersion: "v2",
|
|
481
488
|
});
|
|
482
489
|
});
|
|
483
490
|
|
|
484
|
-
it("should
|
|
491
|
+
it("should map SILVER to WHITE", () => {
|
|
485
492
|
const result = getColorForFullRedesign({
|
|
486
493
|
// $FlowFixMe
|
|
487
|
-
style: { color: BUTTON_COLOR.
|
|
494
|
+
style: { color: BUTTON_COLOR.SILVER },
|
|
488
495
|
fundingSource: FUNDING.PAYPAL,
|
|
489
496
|
});
|
|
490
497
|
|
|
491
498
|
expect(result).toEqual({
|
|
492
|
-
color: BUTTON_COLOR.
|
|
499
|
+
color: BUTTON_COLOR.WHITE,
|
|
493
500
|
shouldApplyRebrandedStyles: true,
|
|
494
501
|
isButtonColorABTestMerchant: false,
|
|
502
|
+
brandVersion: "v2",
|
|
495
503
|
});
|
|
496
504
|
});
|
|
497
505
|
|
|
@@ -534,9 +542,10 @@ describe("getColorForFullRedesign", () => {
|
|
|
534
542
|
});
|
|
535
543
|
|
|
536
544
|
expect(result).toEqual({
|
|
537
|
-
color: BUTTON_COLOR.
|
|
545
|
+
color: BUTTON_COLOR.BLUE,
|
|
538
546
|
shouldApplyRebrandedStyles: true,
|
|
539
547
|
isButtonColorABTestMerchant: false,
|
|
548
|
+
brandVersion: "v2",
|
|
540
549
|
});
|
|
541
550
|
});
|
|
542
551
|
|
|
@@ -676,6 +685,7 @@ describe("getButtonColor", () => {
|
|
|
676
685
|
color: BUTTON_COLOR.GOLD,
|
|
677
686
|
shouldApplyRebrandedStyles: false,
|
|
678
687
|
isButtonColorABTestMerchant: false,
|
|
688
|
+
brandVersion: "v1",
|
|
679
689
|
});
|
|
680
690
|
});
|
|
681
691
|
|
|
@@ -699,9 +709,10 @@ describe("getButtonColor", () => {
|
|
|
699
709
|
});
|
|
700
710
|
|
|
701
711
|
expect(result).toEqual({
|
|
702
|
-
color: BUTTON_COLOR.
|
|
712
|
+
color: BUTTON_COLOR.BLUE,
|
|
703
713
|
shouldApplyRebrandedStyles: true,
|
|
704
714
|
isButtonColorABTestMerchant: false,
|
|
715
|
+
brandVersion: "v2",
|
|
705
716
|
});
|
|
706
717
|
});
|
|
707
718
|
|
|
@@ -754,6 +765,7 @@ describe("getButtonColor", () => {
|
|
|
754
765
|
color: BUTTON_COLOR.BLUE,
|
|
755
766
|
shouldApplyRebrandedStyles: false,
|
|
756
767
|
isButtonColorABTestMerchant: false,
|
|
768
|
+
brandVersion: "v1",
|
|
757
769
|
});
|
|
758
770
|
});
|
|
759
771
|
|
|
@@ -779,6 +791,7 @@ describe("getButtonColor", () => {
|
|
|
779
791
|
color: BUTTON_COLOR.WHITE,
|
|
780
792
|
shouldApplyRebrandedStyles: false,
|
|
781
793
|
isButtonColorABTestMerchant: false,
|
|
794
|
+
brandVersion: "v1",
|
|
782
795
|
});
|
|
783
796
|
});
|
|
784
797
|
|
|
@@ -791,6 +804,7 @@ describe("getButtonColor", () => {
|
|
|
791
804
|
color: BUTTON_COLOR.GOLD,
|
|
792
805
|
shouldApplyRebrandedStyles: false,
|
|
793
806
|
isButtonColorABTestMerchant: false,
|
|
807
|
+
brandVersion: "v1",
|
|
794
808
|
});
|
|
795
809
|
});
|
|
796
810
|
});
|
|
@@ -822,3 +836,51 @@ describe("HideSubmitButtonProps type validation", () => {
|
|
|
822
836
|
expect(validButtonProps.hideSubmitButtonForCardForm).toBe(false);
|
|
823
837
|
});
|
|
824
838
|
});
|
|
839
|
+
|
|
840
|
+
describe("normalizeButtonStyle requestedButtonColor", () => {
|
|
841
|
+
it("should preserve the merchant-provided color as requestedButtonColor when rebrand maps it to a different color", () => {
|
|
842
|
+
const result = normalizeButtonStyle(
|
|
843
|
+
// $FlowFixMe
|
|
844
|
+
{
|
|
845
|
+
fundingSource: FUNDING.PAYPAL,
|
|
846
|
+
buttonColor: {
|
|
847
|
+
color: BUTTON_COLOR.BLUE,
|
|
848
|
+
shouldApplyRebrandedStyles: true,
|
|
849
|
+
brandVersion: "v2",
|
|
850
|
+
isButtonColorABTestMerchant: false,
|
|
851
|
+
},
|
|
852
|
+
},
|
|
853
|
+
// $FlowFixMe
|
|
854
|
+
{ color: BUTTON_COLOR.GOLD }
|
|
855
|
+
);
|
|
856
|
+
|
|
857
|
+
// Merchant configured gold — rebrand maps it to blue
|
|
858
|
+
expect(result.requestedButtonColor).toBe(BUTTON_COLOR.GOLD);
|
|
859
|
+
expect(result.color).toBe(BUTTON_COLOR.BLUE);
|
|
860
|
+
expect(result.shouldApplyRebrandedStyles).toBe(true);
|
|
861
|
+
expect(result.brandVersion).toBe("v2");
|
|
862
|
+
});
|
|
863
|
+
|
|
864
|
+
it("should preserve merchant silver as requestedButtonColor when rebrand maps it to white", () => {
|
|
865
|
+
const result = normalizeButtonStyle(
|
|
866
|
+
// $FlowFixMe
|
|
867
|
+
{
|
|
868
|
+
fundingSource: FUNDING.PAYPAL,
|
|
869
|
+
buttonColor: {
|
|
870
|
+
color: BUTTON_COLOR.WHITE,
|
|
871
|
+
shouldApplyRebrandedStyles: true,
|
|
872
|
+
brandVersion: "v2",
|
|
873
|
+
isButtonColorABTestMerchant: false,
|
|
874
|
+
},
|
|
875
|
+
},
|
|
876
|
+
// $FlowFixMe
|
|
877
|
+
{ color: BUTTON_COLOR.SILVER }
|
|
878
|
+
);
|
|
879
|
+
|
|
880
|
+
// Merchant configured silver — rebrand maps it to white
|
|
881
|
+
expect(result.requestedButtonColor).toBe(BUTTON_COLOR.SILVER);
|
|
882
|
+
expect(result.color).toBe(BUTTON_COLOR.WHITE);
|
|
883
|
+
expect(result.shouldApplyRebrandedStyles).toBe(true);
|
|
884
|
+
expect(result.brandVersion).toBe("v2");
|
|
885
|
+
});
|
|
886
|
+
});
|
|
@@ -44,85 +44,85 @@ export const buttonColorStyle = `
|
|
|
44
44
|
border-top-color: transparent;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
48
|
-
.${CLASS.BUTTON_ROW}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
47
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.BLUE},
|
|
48
|
+
.${CLASS.BUTTON_ROW}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.BLUE} .menu-button {
|
|
49
49
|
background: #60CDFF;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
@media (hover:hover) {
|
|
53
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
53
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.BLUE}:hover {
|
|
54
54
|
background: #54B4E0;
|
|
55
55
|
overflow: inherit;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
.${CLASS.BUTTON_REBRAND}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.VENMO}].${CLASS.COLOR}-${BUTTON_COLOR.
|
|
58
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.VENMO}].${CLASS.COLOR}-${BUTTON_COLOR.BLUE}:hover {
|
|
59
59
|
background: #0073E0;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
@media (hover:hover) {
|
|
64
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
64
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.BLUE}:active {
|
|
65
65
|
background: #3DB5FF;
|
|
66
66
|
overflow: inherit;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
.${CLASS.BUTTON_REBRAND}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.VENMO}].${CLASS.COLOR}-${BUTTON_COLOR.
|
|
69
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.VENMO}].${CLASS.COLOR}-${BUTTON_COLOR.BLUE}:active {
|
|
70
70
|
background: #0074FF;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
75
|
-
.${CLASS.BUTTON_ROW}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
74
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.DARKBLUE},
|
|
75
|
+
.${CLASS.BUTTON_ROW}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.DARKBLUE} .menu-button {
|
|
76
76
|
background: #002991;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
@media (hover:hover) {
|
|
80
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
80
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.DARKBLUE}:hover {
|
|
81
81
|
background: #0038BA;
|
|
82
82
|
overflow: inherit;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
@media (hover:hover) {
|
|
87
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
87
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.DARKBLUE}:active {
|
|
88
88
|
background: #0057D9;
|
|
89
89
|
overflow: inherit;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
94
|
-
.${CLASS.BUTTON_ROW}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
93
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.BLACK},
|
|
94
|
+
.${CLASS.BUTTON_ROW}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.BLACK} .menu-button {
|
|
95
95
|
background: #000000;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
@media (hover:hover) {
|
|
99
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
99
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.BLACK}:hover {
|
|
100
100
|
background: #333333;
|
|
101
101
|
overflow: inherit;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
@media (hover:hover) {
|
|
106
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
106
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.BLACK}:active {
|
|
107
107
|
background: #696969;
|
|
108
108
|
overflow: inherit;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
113
|
-
.${CLASS.BUTTON_ROW}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
112
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.WHITE},
|
|
113
|
+
.${CLASS.BUTTON_ROW}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.WHITE} .menu-button {
|
|
114
114
|
background: #FFFFFF;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
@media (hover:hover) {
|
|
118
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
118
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.WHITE}:hover {
|
|
119
119
|
background: #F2F2F2;
|
|
120
120
|
overflow: inherit;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
@media (hover:hover) {
|
|
125
|
-
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.
|
|
125
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.WHITE}:active {
|
|
126
126
|
background: #E9E9E9;
|
|
127
127
|
overflow: inherit;
|
|
128
128
|
}
|
|
@@ -178,8 +178,8 @@ export const buttonColorStyle = `
|
|
|
178
178
|
background: #0070ba;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.VENMO}].${CLASS.COLOR}-${BUTTON_COLOR.BLUE},
|
|
182
|
-
.${CLASS.BUTTON_REBRAND}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.VENMO}].${CLASS.COLOR}-${BUTTON_COLOR.
|
|
181
|
+
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.VENMO}].${CLASS.COLOR}-${BUTTON_COLOR.BLUE},
|
|
182
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.VENMO}].${CLASS.COLOR}-${BUTTON_COLOR.BLUE} {
|
|
183
183
|
background: #008CFF;
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -188,6 +188,12 @@ export const buttonColorStyle = `
|
|
|
188
188
|
background: #2C2E2F;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.BLIK}].${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT},
|
|
192
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.BOLETO}].${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT},
|
|
193
|
+
.${CLASS.BUTTON}.${CLASS.BUTTON_REBRAND}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.IDEAL}].${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT} {
|
|
194
|
+
background: #000000;
|
|
195
|
+
}
|
|
196
|
+
|
|
191
197
|
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.BANCONTACT}].${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT} {
|
|
192
198
|
background: linear-gradient(to right, #1E3764, #005AB9);
|
|
193
199
|
}
|
|
@@ -457,8 +463,6 @@ export const buttonColorStyle = `
|
|
|
457
463
|
}
|
|
458
464
|
|
|
459
465
|
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.WHITE},
|
|
460
|
-
.${CLASS.BUTTON_REBRAND}.${CLASS.COLOR}-${BUTTON_COLOR.REBRAND_WHITE},
|
|
461
|
-
.${CLASS.BUTTON_ROW}.${CLASS.COLOR}-${BUTTON_COLOR.REBRAND_WHITE} .menu-button,
|
|
462
466
|
.${CLASS.BUTTON_ROW}.${CLASS.COLOR}-${BUTTON_COLOR.WHITE} .menu-button {
|
|
463
467
|
background: #fff;
|
|
464
468
|
border: 1px solid #555;
|
|
@@ -244,6 +244,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
|
|
|
244
244
|
},
|
|
245
245
|
|
|
246
246
|
eligible: ({ props }) => {
|
|
247
|
+
const buttonExperiments = props.experiment ?? getButtonExperiments();
|
|
247
248
|
const {
|
|
248
249
|
fundingSource,
|
|
249
250
|
onShippingChange,
|
|
@@ -256,15 +257,15 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
|
|
|
256
257
|
supportsPopups = userAgentSupportsPopups(),
|
|
257
258
|
supportedNativeBrowser = isSupportedNativeBrowser(),
|
|
258
259
|
supportsVenmoPopups = supportsVenmoPopupsUtil(
|
|
259
|
-
|
|
260
|
+
buttonExperiments,
|
|
260
261
|
userAgentSupportsPopups(),
|
|
261
262
|
getUserAgent()
|
|
262
263
|
),
|
|
263
264
|
supportedNativeVenmoBrowser = isSupportedNativeVenmoBrowser(
|
|
264
|
-
|
|
265
|
+
buttonExperiments,
|
|
265
266
|
getUserAgent()
|
|
266
267
|
),
|
|
267
|
-
experiment =
|
|
268
|
+
experiment = buttonExperiments,
|
|
268
269
|
createBillingAgreement,
|
|
269
270
|
createSubscription,
|
|
270
271
|
createVaultSetupToken,
|
|
@@ -66,6 +66,8 @@ export function PrerenderedButtons({
|
|
|
66
66
|
[FPTI_KEY.CONTEXT_ID]: props.buttonSessionID,
|
|
67
67
|
[FPTI_KEY.TRANSITION]: "process_button_prerender_click",
|
|
68
68
|
[FPTI_KEY.CHOSEN_FUNDING]: fundingSource,
|
|
69
|
+
[FPTI_KEY.BUTTON_COLOR]: props.buttonColor?.color,
|
|
70
|
+
[FPTI_KEY.BRAND_VERSION]: props.buttonColor?.brandVersion,
|
|
69
71
|
});
|
|
70
72
|
|
|
71
73
|
if (eagerOrderCreation) {
|