-
Notifications
You must be signed in to change notification settings - Fork 29
Use destination field in choice cards #14621
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -338,6 +338,7 @@ const withBannerData = | |
| tracking, | ||
| submitComponentEvent, | ||
| design, | ||
| promoCodes, | ||
| }; | ||
|
|
||
| return ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ import { | |
| } from '../../../../lib/useMatchMedia'; | ||
| import { getChoiceCards } from '../../lib/choiceCards'; | ||
| import type { ReactComponent } from '../../lib/ReactComponent'; | ||
| import { getChoiceCardUrl } from '../../lib/tracking'; | ||
| import { enrichSupportUrl, getChoiceCardUrl } from '../../lib/tracking'; | ||
| import { ThreeTierChoiceCards } from '../../shared/ThreeTierChoiceCards'; | ||
| import { bannerWrapper, validatedBannerWrapper } from '../common/BannerWrapper'; | ||
| import type { BannerRenderProps } from '../common/types'; | ||
|
|
@@ -132,6 +132,8 @@ const DesignableBanner: ReactComponent<BannerRenderProps> = ({ | |
| submitComponentEvent, | ||
| tracking, | ||
| design, | ||
| countryCode, | ||
| promoCodes, | ||
| }: BannerRenderProps): JSX.Element => { | ||
| const isTabletOrAbove = useMatchMedia(removeMediaRulePrefix(from.tablet)); | ||
|
|
||
|
|
@@ -480,10 +482,15 @@ const DesignableBanner: ReactComponent<BannerRenderProps> = ({ | |
| )} | ||
| <div css={styles.ctaContainer(isCollapsed)}> | ||
| <LinkButton | ||
| href={getChoiceCardUrl( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously we were not adding tracking params to the url if the choice card had |
||
| selectedChoiceCard, | ||
| mainOrMobileContent.primaryCta.ctaUrl, | ||
| )} | ||
| href={enrichSupportUrl({ | ||
| baseUrl: | ||
| getChoiceCardUrl( | ||
| selectedChoiceCard, | ||
| ), | ||
| tracking, | ||
| promoCodes: promoCodes ?? [], | ||
| countryCode, | ||
| })} | ||
| onClick={onCtaClick} | ||
| priority="primary" | ||
| cssOverrides={styles.linkButtonStyles} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,5 @@ | ||
| import type { Tracking } from '@guardian/support-dotcom-components/dist/shared/types'; | ||
| import { addChoiceCardsParams, enrichSupportUrl } from './tracking'; | ||
|
|
||
| describe('addChoiceCardsParams', () => { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed tests for an unused function |
||
| it('adds choice cards params to url without existing querystring', () => { | ||
| const result = addChoiceCardsParams( | ||
| 'https://support.theguardian.com/contribute', | ||
| 'ONE_OFF', | ||
| 5, | ||
| ); | ||
| expect(result).toEqual( | ||
| 'https://support.theguardian.com/contribute?selected-contribution-type=ONE_OFF&selected-amount=5', | ||
| ); | ||
| }); | ||
|
|
||
| it('adds choice cards params to url with existing querystring', () => { | ||
| const result = addChoiceCardsParams( | ||
| 'https://support.theguardian.com/contribute?test=test', | ||
| 'ONE_OFF', | ||
| 5, | ||
| ); | ||
| expect(result).toEqual( | ||
| 'https://support.theguardian.com/contribute?test=test&selected-contribution-type=ONE_OFF&selected-amount=5', | ||
| ); | ||
| }); | ||
| }); | ||
| import { enrichSupportUrl, getChoiceCardUrl } from './tracking'; | ||
|
|
||
| describe('enrichSupportUrl', () => { | ||
| const tracking: Tracking = { | ||
|
|
@@ -81,3 +57,99 @@ describe('enrichSupportUrl', () => { | |
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getChoiceCardUrl', () => { | ||
| // One-time | ||
| it('builds landing page url for one-time choice', () => { | ||
| const url = getChoiceCardUrl({ | ||
| benefits: [], | ||
| isDefault: false, | ||
| label: 'label', | ||
| product: { | ||
| supportTier: 'OneOff', | ||
| }, | ||
| destination: 'LandingPage', | ||
| }); | ||
| expect(url).toEqual( | ||
| 'https://support.theguardian.com/contribute?oneTime', | ||
| ); | ||
| }); | ||
| it('builds checkout page url for one-time choice', () => { | ||
| const url = getChoiceCardUrl({ | ||
| benefits: [], | ||
| isDefault: false, | ||
| label: 'label', | ||
| product: { | ||
| supportTier: 'OneOff', | ||
| }, | ||
| destination: 'Checkout', | ||
| }); | ||
| expect(url).toEqual( | ||
| 'https://support.theguardian.com/one-time-checkout', | ||
| ); | ||
| }); | ||
|
|
||
| // Recurring contribution | ||
| it('builds landing page url for one-time choice', () => { | ||
| const url = getChoiceCardUrl({ | ||
| benefits: [], | ||
| isDefault: false, | ||
| label: 'label', | ||
| product: { | ||
| supportTier: 'Contribution', | ||
| ratePlan: 'Monthly', | ||
| }, | ||
| destination: 'LandingPage', | ||
| }); | ||
| expect(url).toEqual( | ||
| 'https://support.theguardian.com/contribute?product=Contribution&ratePlan=Monthly', | ||
| ); | ||
| }); | ||
| it('builds checkout page url for one-time choice', () => { | ||
| const url = getChoiceCardUrl({ | ||
| benefits: [], | ||
| isDefault: false, | ||
| label: 'label', | ||
| product: { | ||
| supportTier: 'Contribution', | ||
| ratePlan: 'Monthly', | ||
| }, | ||
| destination: 'Checkout', | ||
| }); | ||
| expect(url).toEqual( | ||
| 'https://support.theguardian.com/checkout?product=Contribution&ratePlan=Monthly', | ||
| ); | ||
| }); | ||
|
|
||
| // SupporterPlus | ||
| it('builds landing page url for one-time choice', () => { | ||
| const url = getChoiceCardUrl({ | ||
| benefits: [], | ||
| isDefault: false, | ||
| label: 'label', | ||
| product: { | ||
| supportTier: 'SupporterPlus', | ||
| ratePlan: 'Annual', | ||
| }, | ||
| destination: 'LandingPage', | ||
| }); | ||
| expect(url).toEqual( | ||
| 'https://support.theguardian.com/contribute?product=SupporterPlus&ratePlan=Annual', | ||
| ); | ||
| }); | ||
| it('builds checkout page url for one-time choice', () => { | ||
| const url = getChoiceCardUrl({ | ||
| benefits: [], | ||
| isDefault: false, | ||
| label: 'label', | ||
| product: { | ||
| supportTier: 'SupporterPlus', | ||
| ratePlan: 'Annual', | ||
| }, | ||
| destination: 'Checkout', | ||
| }); | ||
| expect(url).toEqual( | ||
| 'https://support.theguardian.com/checkout?product=SupporterPlus&ratePlan=Annual', | ||
| ); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we now have to pass this field through to the banner component for use by
enrichSupportUrl