From 4b3c4f5ba8f9b7720dd1a9e7c08bb7fed6d8490c Mon Sep 17 00:00:00 2001 From: gmajoulet Date: Fri, 3 Apr 2020 18:04:17 -0400 Subject: [PATCH] Split 'on tap' and 'on tap and swipe' education messages. --- .../0.1/amp-story-education.js | 11 ++++++----- .../0.1/test/test-amp-story-education.js | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/extensions/amp-story-education/0.1/amp-story-education.js b/extensions/amp-story-education/0.1/amp-story-education.js index b4af0dd10412..29c9c3183dd7 100644 --- a/extensions/amp-story-education/0.1/amp-story-education.js +++ b/extensions/amp-story-education/0.1/amp-story-education.js @@ -55,7 +55,8 @@ const buildNavigationEl = (element) => { /** @enum {string} */ const Screen = { - ONBOARDING_NAVIGATION_TAP_AND_SWIPE: 'ontas', + ONBOARDING_NAVIGATION_TAP: 'ont', // Sent on page load if no "swipe" capability. + ONBOARDING_NAVIGATION_TAP_AND_SWIPE: 'ontas', // Sent on page load if "swipe" capability. }; /** @enum */ @@ -106,10 +107,10 @@ export class AmpStoryEducation extends AMP.BaseElement { const isMobileUI = this.storeService_.get(StateProperty.UI_STATE) === UIType.MOBILE; if (this.viewer_.isEmbedded() && isMobileUI) { - this.maybeShowScreen_( - Screen.ONBOARDING_NAVIGATION_TAP_AND_SWIPE, - State.NAVIGATION_TAP - ); + const screen = this.viewer_.hasCapability('swipe') + ? Screen.ONBOARDING_NAVIGATION_TAP_AND_SWIPE + : Screen.ONBOARDING_NAVIGATION_TAP; + this.maybeShowScreen_(screen, State.NAVIGATION_TAP); } } diff --git a/extensions/amp-story-education/0.1/test/test-amp-story-education.js b/extensions/amp-story-education/0.1/test/test-amp-story-education.js index fc510d0ccde4..e2461e43e121 100644 --- a/extensions/amp-story-education/0.1/test/test-amp-story-education.js +++ b/extensions/amp-story-education/0.1/test/test-amp-story-education.js @@ -216,7 +216,22 @@ describes.realWin('amp-story-education', {amp: true}, (env) => { expect(sendStub).to.not.have.been.called; }); - it('should send canShowScreens for navigation on build', async () => { + it('should send canShowScreens ont for navigation on build', async () => { + const sendStub = env.sandbox.stub(viewer, 'sendMessageAwaitResponse'); + env.sandbox + .stub(storyEducation.getAmpDoc(), 'whenFirstVisible') + .resolves(); + + storyEducation.buildCallback(); + await Promise.resolve(); // Microtask tick. + + expect(sendStub).to.have.been.calledOnceWith('canShowScreens', { + screens: [{screen: 'ont'}], + }); + }); + + it('should send canShowScreens ontas for navigation on build', async () => { + hasSwipeCap = true; const sendStub = env.sandbox.stub(viewer, 'sendMessageAwaitResponse'); env.sandbox .stub(storyEducation.getAmpDoc(), 'whenFirstVisible')