Skip to content

Commit 281999f

Browse files
hnguyen510Hai-Yen Nguyen
and
Hai-Yen Nguyen
authored
Feature/tests for rebrand buttons (#2481)
* start writing tests * adding first render test for rebrand buttons --------- Co-authored-by: Hai-Yen Nguyen <[email protected]>
1 parent cb4c897 commit 281999f

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

Diff for: test/integration/globals.js

+2
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,7 @@ window.__TEST_FUNDING_ELIGIBILITY__ = {
107107
};
108108

109109
window.__TEST_FIRST_RENDER_EXPERIMENTS__ = {
110+
isPaypalRebrandEnabled: false,
111+
defaultBlueButtonColor: "gold",
110112
venmoWebEnabled: false,
111113
};

Diff for: test/integration/tests/button/style.js

+105
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
getElementRecursive,
1212
assert,
1313
WEBVIEW_USER_AGENT,
14+
mockProp,
1415
} from "../common";
1516

1617
for (const flow of ["popup", "iframe"]) {
@@ -226,3 +227,107 @@ describe("paypal button aria-label", () => {
226227
});
227228
});
228229
});
230+
231+
describe("paypal rebrand button", () => {
232+
beforeEach(() => {
233+
createTestContainer();
234+
});
235+
236+
afterEach(() => {
237+
destroyTestContainer();
238+
});
239+
240+
it("should renders the legacy button when isPaypalRebrandEnabled is false", () => {
241+
const mockPaypalRebrandExperiment = mockProp(
242+
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
243+
"isPaypalRebrandEnabled",
244+
false
245+
);
246+
247+
const button = window.paypal.Buttons({});
248+
249+
return button.render("#testContainer").then(() => {
250+
assert.ok(getElementRecursive(".paypal-button-color-gold"));
251+
assert.ok(
252+
getElementRecursive(".paypal-logo-paypal.paypal-logo-color-blue")
253+
);
254+
mockPaypalRebrandExperiment.cancel();
255+
});
256+
});
257+
258+
it("should renders the legacy button when isPaypalRebrandEnabled is true and defaultBlueButtonColor is gold", () => {
259+
const mockPaypalRebrandExperiment = mockProp(
260+
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
261+
"isPaypalRebrandEnabled",
262+
true
263+
);
264+
265+
const button = window.paypal.Buttons({});
266+
267+
return button.render("#testContainer").then(() => {
268+
assert.ok(getElementRecursive(".paypal-button-color-gold"));
269+
assert.ok(
270+
getElementRecursive(".paypal-logo-paypal.paypal-logo-color-blue")
271+
);
272+
mockPaypalRebrandExperiment.cancel();
273+
});
274+
});
275+
276+
it("should renders the light-blue button when isPaypalRebrandEnabled is true and defaultBlueButtonColor is light-blue", () => {
277+
const mockPaypalRebrandExperiment = mockProp(
278+
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
279+
"isPaypalRebrandEnabled",
280+
true
281+
);
282+
283+
const mockDefaultBlueColorExperiment = mockProp(
284+
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
285+
"defaultBlueButtonColor",
286+
"defaultBlue_lightBlue"
287+
);
288+
289+
const button = window.paypal.Buttons({});
290+
291+
return button.render("#testContainer").then(() => {
292+
assert.ok(
293+
getElementRecursive(".paypal-button-color-defaultBlue_lightBlue")
294+
);
295+
assert.ok(
296+
getElementRecursive(
297+
".paypal-logo-paypal-rebrand.paypal-logo-color-black"
298+
)
299+
);
300+
mockPaypalRebrandExperiment.cancel();
301+
mockDefaultBlueColorExperiment.cancel();
302+
});
303+
});
304+
305+
it("should renders the dark-blue button when isPaypalRebrandEnabled is true and defaultBlueButtonColor is dark-blue", () => {
306+
const mockPaypalRebrandExperiment = mockProp(
307+
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
308+
"isPaypalRebrandEnabled",
309+
true
310+
);
311+
312+
const mockDefaultBlueColorExperiment = mockProp(
313+
window.__TEST_FIRST_RENDER_EXPERIMENTS__,
314+
"defaultBlueButtonColor",
315+
"defaultBlue_darkBlue"
316+
);
317+
318+
const button = window.paypal.Buttons({});
319+
320+
return button.render("#testContainer").then(() => {
321+
assert.ok(
322+
getElementRecursive(".paypal-button-color-defaultBlue_darkBlue")
323+
);
324+
assert.ok(
325+
getElementRecursive(
326+
".paypal-logo-paypal-rebrand.paypal-logo-color-blue"
327+
)
328+
);
329+
mockPaypalRebrandExperiment.cancel();
330+
mockDefaultBlueColorExperiment.cancel();
331+
});
332+
});
333+
});

0 commit comments

Comments
 (0)