Skip to content

Feature/tests for rebrand buttons #2481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 13, 2025
Merged
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
2 changes: 2 additions & 0 deletions test/integration/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,7 @@ window.__TEST_FUNDING_ELIGIBILITY__ = {
};

window.__TEST_FIRST_RENDER_EXPERIMENTS__ = {
isPaypalRebrandEnabled: false,
defaultBlueButtonColor: "gold",
venmoWebEnabled: false,
};
105 changes: 105 additions & 0 deletions test/integration/tests/button/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getElementRecursive,
assert,
WEBVIEW_USER_AGENT,
mockProp,
} from "../common";

for (const flow of ["popup", "iframe"]) {
Expand Down Expand Up @@ -226,3 +227,107 @@ describe("paypal button aria-label", () => {
});
});
});

describe("paypal rebrand button", () => {
beforeEach(() => {
createTestContainer();
});

afterEach(() => {
destroyTestContainer();
});

it("should renders the legacy button when isPaypalRebrandEnabled is false", () => {
const mockPaypalRebrandExperiment = mockProp(
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
"isPaypalRebrandEnabled",
false
);

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

return button.render("#testContainer").then(() => {
assert.ok(getElementRecursive(".paypal-button-color-gold"));
assert.ok(
getElementRecursive(".paypal-logo-paypal.paypal-logo-color-blue")
);
mockPaypalRebrandExperiment.cancel();
});
});

it("should renders the legacy button when isPaypalRebrandEnabled is true and defaultBlueButtonColor is gold", () => {
const mockPaypalRebrandExperiment = mockProp(
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
"isPaypalRebrandEnabled",
true
);

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

return button.render("#testContainer").then(() => {
assert.ok(getElementRecursive(".paypal-button-color-gold"));
assert.ok(
getElementRecursive(".paypal-logo-paypal.paypal-logo-color-blue")
);
mockPaypalRebrandExperiment.cancel();
});
});

it("should renders the light-blue button when isPaypalRebrandEnabled is true and defaultBlueButtonColor is light-blue", () => {
const mockPaypalRebrandExperiment = mockProp(
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
"isPaypalRebrandEnabled",
true
);

const mockDefaultBlueColorExperiment = mockProp(
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
"defaultBlueButtonColor",
"defaultBlue_lightBlue"
);

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

return button.render("#testContainer").then(() => {
assert.ok(
getElementRecursive(".paypal-button-color-defaultBlue_lightBlue")
);
assert.ok(
getElementRecursive(
".paypal-logo-paypal-rebrand.paypal-logo-color-black"
)
);
mockPaypalRebrandExperiment.cancel();
mockDefaultBlueColorExperiment.cancel();
});
});

it("should renders the dark-blue button when isPaypalRebrandEnabled is true and defaultBlueButtonColor is dark-blue", () => {
const mockPaypalRebrandExperiment = mockProp(
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
"isPaypalRebrandEnabled",
true
);

const mockDefaultBlueColorExperiment = mockProp(
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
"defaultBlueButtonColor",
"defaultBlue_darkBlue"
);

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

return button.render("#testContainer").then(() => {
assert.ok(
getElementRecursive(".paypal-button-color-defaultBlue_darkBlue")
);
assert.ok(
getElementRecursive(
".paypal-logo-paypal-rebrand.paypal-logo-color-blue"
)
);
mockPaypalRebrandExperiment.cancel();
mockDefaultBlueColorExperiment.cancel();
});
});
});