From 5e3d407f73b8fe92240656bd15e05529ea7c090e Mon Sep 17 00:00:00 2001 From: Ben Barnett Date: Tue, 30 Oct 2018 10:31:13 +0000 Subject: [PATCH] Tracking querystring is added to non-gift urls --- __tests__/__snapshots__/snapshots.test.js.snap | 2 +- components/x-gift-article/src/GiftArticle.jsx | 13 ++++++------- components/x-gift-article/src/lib/props-composer.js | 2 +- components/x-gift-article/stories/free-article.js | 3 ++- components/x-gift-article/stories/native-share.js | 3 ++- .../x-gift-article/stories/with-gift-credits.js | 3 ++- .../x-gift-article/stories/without-gift-credits.js | 3 ++- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/__tests__/__snapshots__/snapshots.test.js.snap b/__tests__/__snapshots__/snapshots.test.js.snap index 7185fc32e..5c68beeaf 100644 --- a/__tests__/__snapshots__/snapshots.test.js.snap +++ b/__tests__/__snapshots__/snapshots.test.js.snap @@ -44,7 +44,7 @@ exports[`@financial-times/x-gift-article renders a default Free article x-gift-a > ({ +const withGiftFormActions = withActions(({ articleId, sessionId, composer }) => ({ showGiftUrlSection() { return composer.showGiftUrlSection(); }, async showNonGiftUrlSection() { - if (composer.isNonGiftUrlShortened) { - return composer.showNonGiftUrlSection(); - } else { - const { url, isShortened } = await api.getShorterUrl(articleUrl); + if (!composer.isNonGiftUrlShortened) { + const { url, isShortened } = await api.getShorterUrl(composer.urls.nonGift); if (isShortened) { composer.setShortenedNonGiftUrl(url); } - return composer.showNonGiftUrlSection(); } + + return composer.showNonGiftUrlSection(); }, async createGiftUrl() { @@ -49,7 +48,7 @@ const withGiftFormActions = withActions(({ articleId, articleUrl, sessionId, com }, async getShorterNonGiftUrl() { - const { url, isShortened } = await api.getShorterUrl(articleUrl); + const { url, isShortened } = await api.getShorterUrl(composer.urls.nonGift); if (isShortened) { return composer.setShortenedNonGiftUrl(url); diff --git a/components/x-gift-article/src/lib/props-composer.js b/components/x-gift-article/src/lib/props-composer.js index b2ad0e1bc..38dec5759 100644 --- a/components/x-gift-article/src/lib/props-composer.js +++ b/components/x-gift-article/src/lib/props-composer.js @@ -41,7 +41,7 @@ export class GiftArticlePropsComposer { this.mailtoUrls = { gift: undefined, - nonGift: createMailtoUrl(this.articleTitle, this.articleUrl) + nonGift: createMailtoUrl(this.articleTitle, `${this.articleUrl}?shareType=nongift`) }; this.mobileShareLinks = this.showMobileShareLinks ? { diff --git a/components/x-gift-article/stories/free-article.js b/components/x-gift-article/stories/free-article.js index ff107990d..11c58a67a 100644 --- a/components/x-gift-article/stories/free-article.js +++ b/components/x-gift-article/stories/free-article.js @@ -1,4 +1,5 @@ const articleUrl = 'https://www.ft.com/content/blahblahblah'; +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift`; exports.title = 'Free article'; @@ -28,7 +29,7 @@ exports.fetchMock = fetchMock => { } ) .get( - `/article/shorten-url/${ encodeURIComponent(articleUrl) }`, + `/article/shorten-url/${ encodeURIComponent(nonGiftArticleUrl) }`, { shortenedUrl: 'https://shortened-non-gift-url' } ); }; diff --git a/components/x-gift-article/stories/native-share.js b/components/x-gift-article/stories/native-share.js index d847058f7..0cb11193c 100644 --- a/components/x-gift-article/stories/native-share.js +++ b/components/x-gift-article/stories/native-share.js @@ -1,5 +1,6 @@ const articleUrl = 'https://www.ft.com/content/blahblahblah'; const articleUrlRedeemed = 'https://gift-url-redeemed'; +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift`; exports.title = 'With native share on App'; @@ -36,7 +37,7 @@ exports.fetchMock = fetchMock => { { shortenedUrl: 'https://shortened-gift-url' } ) .get( - `/article/shorten-url/${ encodeURIComponent(articleUrl) }`, + `/article/shorten-url/${ encodeURIComponent(nonGiftArticleUrl) }`, { shortenedUrl: 'https://shortened-non-gift-url' } ) .post( diff --git a/components/x-gift-article/stories/with-gift-credits.js b/components/x-gift-article/stories/with-gift-credits.js index 2d8f1d1ca..d52b86500 100644 --- a/components/x-gift-article/stories/with-gift-credits.js +++ b/components/x-gift-article/stories/with-gift-credits.js @@ -1,5 +1,6 @@ const articleUrl = 'https://www.ft.com/content/blahblahblah'; const articleUrlRedeemed = 'https://gift-url-redeemed'; +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift`; exports.title = 'With gift credits'; @@ -36,7 +37,7 @@ exports.fetchMock = fetchMock => { { shortenedUrl: 'https://shortened-gift-url' } ) .get( - `/article/shorten-url/${ encodeURIComponent(articleUrl) }`, + `/article/shorten-url/${ encodeURIComponent(nonGiftArticleUrl) }`, { shortenedUrl: 'https://shortened-non-gift-url' } ) .post( diff --git a/components/x-gift-article/stories/without-gift-credits.js b/components/x-gift-article/stories/without-gift-credits.js index bb32aeea8..0a94e0a50 100644 --- a/components/x-gift-article/stories/without-gift-credits.js +++ b/components/x-gift-article/stories/without-gift-credits.js @@ -1,4 +1,5 @@ const articleUrl = 'https://www.ft.com/content/blahblahblah'; +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift`; exports.title = 'Without gift credits'; @@ -28,7 +29,7 @@ exports.fetchMock = fetchMock => { } ) .get( - `/article/shorten-url/${ encodeURIComponent(articleUrl) }`, + `/article/shorten-url/${ encodeURIComponent(nonGiftArticleUrl) }`, { shortenedUrl: 'https://shortened-non-gift-url' } ); };