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

✅ Add an e2e test for amp-subscriptions-google. #23665

Merged
merged 11 commits into from Aug 9, 2019
@@ -0,0 +1,65 @@
/**
* Copyright 2018 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

describes.endtoend(
'amp-subscriptions-google',
{
testUrl:
'http://localhost:8000/test/fixtures/e2e/amp-subscriptions-google/swg.amp.html',
environments: ['single'],
},
env => {
let controller;

beforeEach(() => {
controller = env.controller;
});

it('Subscription offers should render correctly', async () => {
const btn = await controller.findElement('#swg_button');
await controller.click(btn);

// Switch to SwG's outer iFrame
const outerFrame = await controller.findElement('iframe.swg-dialog');
await controller.switchToFrame(outerFrame);

// Switch to SwG's inner iFrame
const innerFrame = await controller.findElement('iframe');
await controller.switchToFrame(innerFrame);

const text = await controller.findElement('.K2Fgzb');
await expect(text).to.exist;
await expect(controller.getElementText(text)).to.equal(
'Subscribe with your Google Account'
);

const basicAccessText = await controller.findElement('.amekj');
await expect(controller.getElementText(basicAccessText)).to.equal(
'Basic Access'
);

const basicAccessDesc = await controller.findElement('.a02uaf');
await expect(controller.getElementText(basicAccessDesc)).to.equal(
'Basic access charged weekly'
);

const basicAccessPrice = await controller.findElement('.mojnzf');
await expect(controller.getElementText(basicAccessPrice)).to.equal(
'$1.99/week*'
);
});
}
);
120 changes: 120 additions & 0 deletions test/fixtures/e2e/amp-subscriptions-google/swg.amp.html
@@ -0,0 +1,120 @@
<!doctype html>
<html ⚡>
<header>
<meta charset="utf-8">
<title>16 Top Spots for Hiking - The Scenic - USA</title>
<link rel="canonical" href="amps.html">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-subscriptions" src="https://cdn.ampproject.org/v0/amp-subscriptions-0.1.js"></script>
<script async custom-element="amp-subscriptions-google" src="https://cdn.ampproject.org/v0/amp-subscriptions-google-0.1.js"></script>

<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"headline": "16 Top Spots for Hiking",
"image": "https://scenic-2017.appspot.com/examples/sample-pub/icons/icon-2x.png",
"datePublished": "2025-02-05T08:00:00+08:00",
"dateModified": "2025-02-05T09:20:00+08:00",
"author": {
"@type": "Person",
"name": "John Doe"
},
"publisher": {
"name": "The Scenic",
"@type": "Organization",
"@id": "scenic-2017.appspot.com",
"logo": {
"@type": "ImageObject",
"url": "https://scenic-2017.appspot.com/examples/sample-pub/icons/icon-2x.png"
}
},
"description": "A most wonderful article",
"isAccessibleForFree": "False",
"isPartOf": {
"@type": ["CreativeWork", "Product"],
"name" : "Scenic News",
"productID": "scenic-2017.appspot.com:news"
}
}
</script>

<script type="application/json" id="amp-subscriptions">
{
"services": [
{
"authorizationUrl": "//localhost:8000/examples/sample-pub/amp-entitlements?pubid=com.appspot.scenic-2017&meter=1",
"pingbackUrl": "//localhost:8000/examples/sample-pub/amp-pingback?pubid=com.appspot.scenic-2017",
"actions": {
"login": "//localhost:8000/examples/sample-pub/signin",
"subscribe": "//localhost:8000/examples/sample-pub/subscribe"
}
},
{
"serviceId": "subscribe.google.com"
}
]
}
</script>

</header>
<body>
<div class="main-body">
<main role="main">
<div class="container">
<h2 class="category">Top Spots</h2>
<h1 class="heading">16 Top Spots for Hiking</h1>
<p class="kicker">Don&#39;t forget your walking stick</p>
<p class="byline">By Demetria T. Edwards on Sep 24, 2016 10:04 AM</p>
<div class="hr"></div>

<p class="text">
Jelly jujubes marshmallow donut. Wafer cheesecake lollipop fruitcake danish powder. Pudding croissant biscuit icing. Gummi bears fruitcake cake wafer cake cookie caramels marshmallow bonbon.
</p>

<p class="text">
Gingerbread biscuit gummies cupcake. Powder sugar plum chocolate cake chocolate cake cake. Marzipan brownie halvah. Marzipan soufflé bear claw gummi bears muffin.
</p>

<section subscriptions-section="content">
<p class="text">
Muffin jelly-o wafer ice cream brownie dessert chocolate bar. Candy canes cotton candy apple pie cake. Chupa chups bonbon dragée bear claw dessert. Oat cake croissant sweet roll apple pie pie.
</p>
<p class="text">
Cookie fruitcake toffee lemon drops. Gummies caramels topping wafer tootsie roll cake. Halvah pastry gingerbread liquorice. Dragée topping toffee chupa chups.
</p>
<p class="text">
Halvah bear claw cake fruitcake chocolate topping. Cookie topping chocolate cake chocolate topping biscuit caramels lollipop danish. Jelly-o pastry topping candy. Cotton candy oat cake pastry lemon drops chocolate.
</p>
<p class="text">
Pastry cupcake icing. Gummies lollipop sweet carrot cake tootsie roll. Brownie apple pie sweet roll soufflé.
</p>
</section>

<section subscriptions-section="content-not-granted">
<p class="text">
<strong>Please go through subscribe flow to see more content.</strong>
</p>
</section>
</div>
</main>
</div>

<template type="amp-mustache" subscriptions-dialog subscriptions-display="subscribed">
<div class="subs-dialog">
You are a Scenic subscriber.
</div>
</template>
<template type="amp-mustache" subscriptions-dialog subscriptions-display="metered">
<div class="subs-dialog">
You have {{entitlement.metering.left}} articles left.
</div>
</template>

<button id="swg_button" subscriptions-display="NOT (data.showContent)"
subscriptions-action="subscribe" subscriptions-display="TRUE"
subscriptions-service="subscribe.google.com">subscribe</button>
</body>
</html>
120 changes: 120 additions & 0 deletions test/manual/amp-subscriptions-google/swg.amp.html
@@ -0,0 +1,120 @@
<!doctype html>
<html ⚡>
<header>
<meta charset="utf-8">
<title>16 Top Spots for Hiking - The Scenic - USA</title>
<link rel="canonical" href="amps.html">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-subscriptions" src="https://cdn.ampproject.org/v0/amp-subscriptions-0.1.js"></script>
<script async custom-element="amp-subscriptions-google" src="https://cdn.ampproject.org/v0/amp-subscriptions-google-0.1.js"></script>

<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"headline": "16 Top Spots for Hiking",
"image": "https://scenic-2017.appspot.com/examples/sample-pub/icons/icon-2x.png",
"datePublished": "2025-02-05T08:00:00+08:00",
"dateModified": "2025-02-05T09:20:00+08:00",
"author": {
"@type": "Person",
"name": "John Doe"
},
"publisher": {
"name": "The Scenic",
"@type": "Organization",
"@id": "scenic-2017.appspot.com",
"logo": {
"@type": "ImageObject",
"url": "https://scenic-2017.appspot.com/examples/sample-pub/icons/icon-2x.png"
}
},
"description": "A most wonderful article",
"isAccessibleForFree": "False",
"isPartOf": {
"@type": ["CreativeWork", "Product"],
"name" : "Scenic News",
"productID": "scenic-2017.appspot.com:news"
}
}
</script>

<script type="application/json" id="amp-subscriptions">
{
"services": [
{
"authorizationUrl": "//localhost:8000/examples/sample-pub/amp-entitlements?pubid=com.appspot.scenic-2017&meter=1",
"pingbackUrl": "//localhost:8000/examples/sample-pub/amp-pingback?pubid=com.appspot.scenic-2017",
"actions": {
"login": "//localhost:8000/examples/sample-pub/signin",
"subscribe": "//localhost:8000/examples/sample-pub/subscribe"
}
},
{
"serviceId": "subscribe.google.com"
}
]
}
</script>

</header>
<body>
<div class="main-body">
<main role="main">
<div class="container">
<h2 class="category">Top Spots</h2>
<h1 class="heading">16 Top Spots for Hiking</h1>
<p class="kicker">Don&#39;t forget your walking stick</p>
<p class="byline">By Demetria T. Edwards on Sep 24, 2016 10:04 AM</p>
<div class="hr"></div>

<p class="text">
Jelly jujubes marshmallow donut. Wafer cheesecake lollipop fruitcake danish powder. Pudding croissant biscuit icing. Gummi bears fruitcake cake wafer cake cookie caramels marshmallow bonbon.
</p>

<p class="text">
Gingerbread biscuit gummies cupcake. Powder sugar plum chocolate cake chocolate cake cake. Marzipan brownie halvah. Marzipan soufflé bear claw gummi bears muffin.
</p>

<section id="premium_content" subscriptions-section="content">
<p class="text">
Muffin jelly-o wafer ice cream brownie dessert chocolate bar. Candy canes cotton candy apple pie cake. Chupa chups bonbon dragée bear claw dessert. Oat cake croissant sweet roll apple pie pie.
</p>
<p class="text">
Cookie fruitcake toffee lemon drops. Gummies caramels topping wafer tootsie roll cake. Halvah pastry gingerbread liquorice. Dragée topping toffee chupa chups.
</p>
<p class="text">
Halvah bear claw cake fruitcake chocolate topping. Cookie topping chocolate cake chocolate topping biscuit caramels lollipop danish. Jelly-o pastry topping candy. Cotton candy oat cake pastry lemon drops chocolate.
</p>
<p class="text">
Pastry cupcake icing. Gummies lollipop sweet carrot cake tootsie roll. Brownie apple pie sweet roll soufflé.
</p>
</section>

<section subscriptions-section="content-not-granted">
<p class="text">
<strong>Please go through subscribe flow to see more content.</strong>
</p>
</section>
</div>
</main>
</div>

<template type="amp-mustache" subscriptions-dialog subscriptions-display="subscribed">
<div class="subs-dialog">
You are a Scenic subscriber.
</div>
</template>
<template type="amp-mustache" subscriptions-dialog subscriptions-display="metered">
<div class="subs-dialog">
You have {{entitlement.metering.left}} articles left.
</div>
</template>

<button id="swg_button" subscriptions-display="NOT (data.showContent)"
subscriptions-action="subscribe" subscriptions-display="TRUE"
subscriptions-service="subscribe.google.com">subscribe</button>
</body>
</html>