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

Split 'on tap' and 'on tap and swipe' education messages. #27565

Merged
merged 1 commit into from Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions extensions/amp-story-education/0.1/amp-story-education.js
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}
}

Expand Down
Expand Up @@ -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')
Expand Down