Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
uses: bahmutov/npm-install@v1
with:
useLockFile: false

# Just temporary, remove before merging
- name: LS deps
run: npm ls

- name: ▶️ Run Lint
run: npm run lint
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"@paypal/funding-components": "^1.0.31",
"@paypal/sdk-client": "^4.0.199",
"@paypal/sdk-constants": "^1.0.156",
"@paypal/sdk-logos": "^2.2.8"
"@paypal/sdk-logos": "^2.2.16"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
Expand Down
25 changes: 21 additions & 4 deletions src/funding/card/config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import {
GlyphCardExternalImage,
GlyphCardInlineSVG,
GlyphCardRebrandExternalImage,

Check failure on line 9 in src/funding/card/config.jsx

View workflow job for this annotation

GitHub Actions / main

GlyphCardRebrandExternalImage not found in '@paypal/sdk-logos/src'
GlyphCardRebrandInlineSVG,

Check failure on line 10 in src/funding/card/config.jsx

View workflow job for this annotation

GitHub Actions / main

GlyphCardRebrandInlineSVG not found in '@paypal/sdk-logos/src'
} from "@paypal/sdk-logos/src";

import {
Expand Down Expand Up @@ -129,7 +131,12 @@

vendors,

colors: [BUTTON_COLOR.BLACK, BUTTON_COLOR.WHITE],
colors: [
BUTTON_COLOR.BLACK,
BUTTON_COLOR.WHITE,
BUTTON_COLOR.REBRAND_WHITE,
BUTTON_COLOR.REBRAND_BLACK,
],

secondaryColors: {
...DEFAULT_FUNDING_CONFIG.secondaryColors,
Expand All @@ -138,6 +145,8 @@

logoColors: {
[BUTTON_COLOR.WHITE]: BUTTON_COLOR.BLACK,
[BUTTON_COLOR.REBRAND_WHITE]: BUTTON_COLOR.BLACK,
[BUTTON_COLOR.REBRAND_BLACK]: BUTTON_COLOR.WHITE,
[DEFAULT]: BUTTON_COLOR.WHITE,
},

Expand All @@ -148,11 +157,19 @@
return FUNDING.CARD;
},

Logo: ({ logoColor }) => {
Logo: ({ logoColor, shouldApplyRebrandedStyles }) => {
if (!shouldApplyRebrandedStyles) {
return __WEB__ ? (
<GlyphCardExternalImage logoColor={logoColor} />
) : (
<GlyphCardInlineSVG logoColor={logoColor} />
);
}

return __WEB__ ? (
<GlyphCardExternalImage logoColor={logoColor} />
<GlyphCardRebrandExternalImage logoColor={logoColor} />
) : (
<GlyphCardInlineSVG logoColor={logoColor} />
<GlyphCardRebrandInlineSVG logoColor={logoColor} />
);
},

Expand Down
24 changes: 23 additions & 1 deletion src/funding/card/config.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { describe, test, expect } from "vitest";
import { FUNDING, COMPONENTS } from "@paypal/sdk-constants/src";

import { BUTTON_FLOW } from "../../constants";
import { BUTTON_COLOR, BUTTON_FLOW } from "../../constants";

import { getCardConfig } from "./config";

Expand Down Expand Up @@ -140,3 +140,25 @@ describe("card eligibility", () => {
).toEqual(true);
});
});

describe("rebrand card config", () => {
test("should have rebrand colors", () => {
const colors = getCardConfig().colors;
expect(colors).toEqual(
expect.arrayContaining([
BUTTON_COLOR.REBRAND_WHITE,
BUTTON_COLOR.REBRAND_BLACK,
])
);
});

test("should have rebrand logo colors", () => {
const logoColors = getCardConfig().logoColors;
expect(logoColors).toEqual(
expect.objectContaining({
[BUTTON_COLOR.REBRAND_WHITE]: BUTTON_COLOR.BLACK,
[BUTTON_COLOR.REBRAND_BLACK]: BUTTON_COLOR.WHITE,
})
);
});
});
2 changes: 1 addition & 1 deletion src/ui/buttons/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ export function hasInvalidScriptOptionsForFullRedesign({
}: {|
fundingSource?: ?$Values<typeof FUNDING>,
|}): boolean {
const validFundingSourcesForRedesign = [FUNDING.PAYPAL];
const validFundingSourcesForRedesign = [FUNDING.PAYPAL, FUNDING.CARD];

if (validFundingSourcesForRedesign.includes(fundingSource)) {
return false;
Expand Down
3 changes: 1 addition & 2 deletions src/ui/buttons/props.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ describe("determineRandomButtonColor", () => {
});

describe("hasInvalidScriptOptionsForFullRedesign", () => {
const validFundingSources = [FUNDING.PAYPAL];
const validFundingSources = [FUNDING.PAYPAL, FUNDING.CARD];
const invalidFundingSources = [
FUNDING.CARD,
FUNDING.VENMO,
FUNDING.PAYLATER,
FUNDING.CREDIT,
Expand Down
1 change: 0 additions & 1 deletion src/ui/buttons/styles/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ export const buttonRebrandStyle = `
display: flex;
align-items: center;
line-height: 1.1;
flex-shrink: 1;
min-width: 0;
}

Expand Down
103 changes: 59 additions & 44 deletions test/integration/tests/button/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,78 +552,95 @@ describe("Button Redesign", () => {
});
});

describe("unsupported funding sources", () => {
describe("funding source = Venmo", () => {
const fundingSource = "venmo";
describe("funding source = Card", () => {
const fundingSource = "card";

beforeEach(() => {
enableFundingSource(fundingSource);
window.navigator.mockUserAgent = IPHONE6_USER_AGENT;
describe("supported rebranded colors", () => {
// This test fails because the sdk-logo card rebrand component does not append paypal-logo-color-white class currently.
it.skip("should render the rebranded black when color is black and isPaypalRebrandEnabled is true", () => {
const mockPaypalRebrandExperiment =
setMockPaypalRebrandExperiment(true);

const button = window.paypal.Buttons({
fundingSource,
style: {
color: "black",
},
});

return button.render("#testContainer").then(() => {
validateBlackRebrandButton(fundingSource);

mockPaypalRebrandExperiment.cancel();
});
});

it("should render the legacy venmo button when isPaypalRebrandEnabled is true", () => {
// This test fails because the sdk-logo card rebrand component does not append paypal-logo-color-black class currently.
it.skip("should render the rebranded white button when color is white and isPaypalRebrandEnabled is true", () => {
const mockPaypalRebrandExperiment =
setMockPaypalRebrandExperiment(true);

const button = window.paypal.Buttons({
fundingSource,
style: {
color: "white",
},
});

return button.render("#testContainer").then(() => {
// blue is the default color for Venmo
validateLegacyBlueButton(fundingSource);
validateWhiteRebrandButton();

mockPaypalRebrandExperiment.cancel();
});
});
});

it("should render the legacy venmo button when isPaypalRebrandEnabled is true & isPaypalRebrandABTestEnabled is true", () => {
describe("supported legacy colors", () => {
it("should render the legacy black card button when isPaypalRebrandEnabled is false", () => {
const mockPaypalRebrandExperiment =
setMockPaypalRebrandExperiment(true);
const mockPaypalRebrandABTestExperiment =
setMockPaypalRebrandABTestExperiment(true);
setMockPaypalRebrandExperiment(false);

const button = window.paypal.Buttons({
fundingSource,
});

return button.render("#testContainer").then(() => {
// blue is the default color for Venmo
validateLegacyBlackCardButton(fundingSource);

mockPaypalRebrandExperiment.cancel();
mockPaypalRebrandABTestExperiment.cancel();
});
});

it("should render the legacy venmo button in black color is black & when isPaypalRebrandEnabled is true & isPaypalRebrandABTestEnabled is true", () => {
it("should render the legacy white card button when color is white and isPaypalRebrandEnabled is false", () => {
const mockPaypalRebrandExperiment =
setMockPaypalRebrandExperiment(true);
const mockPaypalRebrandABTestExperiment =
setMockPaypalRebrandABTestExperiment(true);
setMockPaypalRebrandExperiment(false);

const button = window.paypal.Buttons({
fundingSource,
style: {
color: "black",
color: "white",
},
});

return button.render("#testContainer").then(() => {
validateLegacyBlackButton(fundingSource);
validateLegacyWhiteCardButton(fundingSource);

mockPaypalRebrandExperiment.cancel();
mockPaypalRebrandABTestExperiment.cancel();
});
});
});
});

describe("funding source = PayLater", () => {
const fundingSource = "paylater";
describe("unsupported funding sources", () => {
describe("funding source = Venmo", () => {
const fundingSource = "venmo";

beforeEach(() => {
enableFundingSource(fundingSource);
window.navigator.mockUserAgent = IPHONE6_USER_AGENT;
});

it("should render the legacy PayLater button when isPaypalRebrandEnabled is true", () => {
it("should render the legacy venmo button when isPaypalRebrandEnabled is true", () => {
const mockPaypalRebrandExperiment =
setMockPaypalRebrandExperiment(true);

Expand All @@ -632,14 +649,14 @@ describe("Button Redesign", () => {
});

return button.render("#testContainer").then(() => {
// white is the default color for Pay Later
validateLegacyWhiteButton("pp");
// blue is the default color for Venmo
validateLegacyBlueButton(fundingSource);

mockPaypalRebrandExperiment.cancel();
});
});

it("should render the legacy PayLater button when isPaypalRebrandEnabled is true & isPaypalRebrandABTestEnabled is true", () => {
it("should render the legacy venmo button when isPaypalRebrandEnabled is true & isPaypalRebrandABTestEnabled is true", () => {
const mockPaypalRebrandExperiment =
setMockPaypalRebrandExperiment(true);
const mockPaypalRebrandABTestExperiment =
Expand All @@ -650,15 +667,13 @@ describe("Button Redesign", () => {
});

return button.render("#testContainer").then(() => {
// white is the default color for Pay Later
validateLegacyWhiteButton("pp");

// blue is the default color for Venmo
mockPaypalRebrandExperiment.cancel();
mockPaypalRebrandABTestExperiment.cancel();
});
});

it("should render the legacy PayLater button in black color is black & when isPaypalRebrandEnabled is true & isPaypalRebrandABTestEnabled is true", () => {
it("should render the legacy venmo button in black color is black & when isPaypalRebrandEnabled is true & isPaypalRebrandABTestEnabled is true", () => {
const mockPaypalRebrandExperiment =
setMockPaypalRebrandExperiment(true);
const mockPaypalRebrandABTestExperiment =
Expand All @@ -672,22 +687,22 @@ describe("Button Redesign", () => {
});

return button.render("#testContainer").then(() => {
validateLegacyBlackButton("pp");
validateLegacyBlackButton(fundingSource);

mockPaypalRebrandExperiment.cancel();
mockPaypalRebrandABTestExperiment.cancel();
});
});
});

describe("funding source = Card", () => {
const fundingSource = "card";
describe("funding source = PayLater", () => {
const fundingSource = "paylater";

beforeEach(() => {
enableFundingSource(fundingSource);
});

it("should render the legacy card button when isPaypalRebrandEnabled is true", () => {
it("should render the legacy PayLater button when isPaypalRebrandEnabled is true", () => {
const mockPaypalRebrandExperiment =
setMockPaypalRebrandExperiment(true);

Expand All @@ -696,14 +711,14 @@ describe("Button Redesign", () => {
});

return button.render("#testContainer").then(() => {
// black is the default color for Card
validateLegacyBlackCardButton();
// white is the default color for Pay Later
validateLegacyWhiteButton("pp");

mockPaypalRebrandExperiment.cancel();
});
});

it("should render the legacy card button when isPaypalRebrandEnabled is true & isPaypalRebrandABTestEnabled is true", () => {
it("should render the legacy PayLater button when isPaypalRebrandEnabled is true & isPaypalRebrandABTestEnabled is true", () => {
const mockPaypalRebrandExperiment =
setMockPaypalRebrandExperiment(true);
const mockPaypalRebrandABTestExperiment =
Expand All @@ -714,15 +729,15 @@ describe("Button Redesign", () => {
});

return button.render("#testContainer").then(() => {
// black is the default color for Card
validateLegacyBlackCardButton();
// white is the default color for Pay Later
validateLegacyWhiteButton("pp");

mockPaypalRebrandExperiment.cancel();
mockPaypalRebrandABTestExperiment.cancel();
});
});

it("should render the legacy card button in white color is white & when isPaypalRebrandEnabled is true & isPaypalRebrandABTestEnabled is true", () => {
it("should render the legacy PayLater button in black color is black & when isPaypalRebrandEnabled is true & isPaypalRebrandABTestEnabled is true", () => {
const mockPaypalRebrandExperiment =
setMockPaypalRebrandExperiment(true);
const mockPaypalRebrandABTestExperiment =
Expand All @@ -731,12 +746,12 @@ describe("Button Redesign", () => {
const button = window.paypal.Buttons({
fundingSource,
style: {
color: "white",
color: "black",
},
});

return button.render("#testContainer").then(() => {
validateLegacyWhiteCardButton();
validateLegacyBlackButton("pp");

mockPaypalRebrandExperiment.cancel();
mockPaypalRebrandABTestExperiment.cancel();
Expand Down
Loading