Skip to content
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

fix: handle tagline field on ncps hosted buttons #2384

Merged
merged 7 commits into from
May 2, 2024
Merged

Conversation

imbrian
Copy link
Contributor

@imbrian imbrian commented May 1, 2024

Description

Hosted Buttons are not able to disable the tagline on horizontal layout buttons. This change uses the tagline value from /ncp/api/form-fields. Defaulting to false if the field is not provided.

Why are we making these changes?

Bug fix: LI-45315

Screenshots

Before:
tagline-before-screenshot

With fix:
tagline-screenshot

@@ -97,6 +97,7 @@ export const getHostedButtonDetails: HostedButtonDetailsParams = async ({
shape: getButtonVariable(variables, "shape"),
color: getButtonVariable(variables, "color"),
label: getButtonVariable(variables, "button_text"),
tagline: getButtonVariable(variables, "tagline") === "true",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing this QUERY_BOOL constant in sdk-contants. Not sure if this is an appropriate case to use that.

Copy link
Contributor

@spencersablan spencersablan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🚀

@imbrian imbrian marked this pull request as ready for review May 1, 2024 20:34
@imbrian imbrian requested a review from a team as a code owner May 1, 2024 20:34
Copy link
Member

@jshawl jshawl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! A few small non-blocking suggestions

// $FlowIssue
request.mockImplementationOnce(() =>
// eslint-disable-next-line compat/compat
Promise.resolve({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this reuse the previous response from

const getHostedButtonDetailsResponse = {
?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thought about it, but the tests are changing the value for tagline (true, false, undefined). Felt a new object was cleaner than nested spreads and mapping over the array to change one value.

);
await HostedButtons({
hostedButtonId: "B1234567890",
fundingSources: ["paypal", "venmo"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think fundingSources can be removed here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I would remove these. This is how we are temporarily rendering the v2 experience but will remove the fundingSources in this ticket that's currently in the sprint.

The tagline only gets rendered in the horizontal smart stack and the v2 experience is rendering 2 standalone buttons.

);
expect(Buttons).toHaveBeenCalledTimes(2);
expect(renderMock).toHaveBeenCalledTimes(0);
expect.assertions(3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome test coverage!

{
name: "button_text",
value: "paypal",
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ similar comment about reusing the previous response variables

);
await getHostedButtonDetails({
hostedButtonId,
fundingSources: [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think fundingSources can be removed here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I would remove these. This is how we are temporarily rendering the v2 experience but will remove the fundingSources in this ticket that's currently in the sprint.

The tagline only gets rendered in the horizontal smart stack and the v2 experience is rendering 2 standalone buttons.

Copy link
Contributor Author

@imbrian imbrian May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's currently required on the type. Are we removing it completely in that ticket? Might make it optional for now, and @nbierdeman can address in that ticket?

There are other tests that included this field.

@imbrian imbrian merged commit 4a46749 into main May 2, 2024
3 checks passed
@imbrian imbrian deleted the fix-ncps-show-tagline branch May 2, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants