-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[social-share] fix title and canonical url being passed to share link (…
…#36751) added e2e test fixed shadow dom css
- Loading branch information
1 parent
c19c2b2
commit ce5decd
Showing
6 changed files
with
230 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
extensions/amp-social-share/1.0/test-e2e/test-bento-social-share.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
describes.endtoend( | ||
'bento-social-share', | ||
{ | ||
version: '1.0', | ||
fixture: 'bento/social-share.html', | ||
environments: ['single'], | ||
}, | ||
(env) => { | ||
let controller; | ||
|
||
beforeEach(() => { | ||
controller = env.controller; | ||
}); | ||
|
||
it('should open a window to a share page', async () => { | ||
const element = await controller.findElement('bento-social-share'); | ||
await controller.switchToShadowRoot(element); | ||
|
||
const shareBtn = await controller.findElement('[role="button"]'); | ||
|
||
let windows = await controller.getAllWindows(); | ||
await expect(windows.length).to.equal(1); | ||
|
||
await controller.click(shareBtn); | ||
|
||
windows = await controller.getAllWindows(); | ||
await expect(windows.length).to.equal(2); | ||
|
||
await controller.switchToWindow(windows[1]); | ||
|
||
await expect(controller.getCurrentUrl()).to.equal( | ||
'https://twitter.com/intent/tweet?text=Bento%20Social%20Share&url=http%3A%2F%2Fexample.com%2F' | ||
); | ||
}); | ||
|
||
it('should replace title and conanical url on the same share url', async () => { | ||
const element = await controller.findElement( | ||
'bento-social-share[type="whatsapp"]' | ||
); | ||
await controller.switchToShadowRoot(element); | ||
|
||
const shareBtn = await controller.findElement('[role="button"]'); | ||
|
||
let windows = await controller.getAllWindows(); | ||
await expect(windows.length).to.equal(1); | ||
|
||
await controller.click(shareBtn); | ||
|
||
windows = await controller.getAllWindows(); | ||
await expect(windows.length).to.equal(2); | ||
|
||
await controller.switchToWindow(windows[1]); | ||
|
||
await expect(controller.getCurrentUrl()).to.equal( | ||
'https://api.whatsapp.com/send?text=Bento%20Social%20Share%20-%20http%3A%2F%2Fexample.com%2F' | ||
); | ||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 93 additions & 15 deletions
108
test/fixtures/e2e/amp-social-share/amp-social-share.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,99 @@ | ||
<!doctype html> | ||
<!DOCTYPE html> | ||
<html ⚡ lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>amp-social-share</title> | ||
<link rel="canonical" href="//example.com" > | ||
<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> | ||
<link rel="canonical" href="//example.com" /> | ||
<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-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-latest.js"></script> | ||
</head> | ||
<script | ||
async | ||
custom-element="amp-social-share" | ||
src="https://cdn.ampproject.org/v0/amp-social-share-latest.js" | ||
></script> | ||
</head> | ||
|
||
<body> | ||
<body> | ||
<amp-social-share id="one" type="email"></amp-social-share> | ||
<amp-social-share id="two" type="twitter" ><div id='twoChild'>Child</div></amp-social-share> | ||
<amp-social-share id="three" height='400' width='400' type="tumblr"></amp-social-share> | ||
<amp-social-share id="four" type="meow" data-share-endpoint="endpoint" ></amp-social-share> | ||
<amp-social-share id="five" type="meow" ><div id='fiveChild'>Child</div></amp-social-share> | ||
<amp-social-share id="six"><div id='sixChild'>Child</div></amp-social-share> | ||
</body> | ||
<amp-social-share id="two" type="twitter" | ||
><div id="twoChild">Child</div></amp-social-share | ||
> | ||
<amp-social-share | ||
id="three" | ||
height="400" | ||
width="400" | ||
type="tumblr" | ||
></amp-social-share> | ||
<amp-social-share | ||
id="four" | ||
type="meow" | ||
data-share-endpoint="endpoint" | ||
></amp-social-share> | ||
<amp-social-share id="five" type="meow" | ||
><div id="fiveChild">Child</div></amp-social-share | ||
> | ||
<amp-social-share id="six"><div id="sixChild">Child</div></amp-social-share> | ||
<amp-social-share id="seven" type="facebook"></amp-social-share> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Bento Social Share</title> | ||
<meta | ||
name="viewport" | ||
content="width=device-width,minimum-scale=1,initial-scale=1" | ||
/> | ||
<link rel="canonical" href="//example.com" /> | ||
<script src="https://cdn.ampproject.org/bento.js"></script> | ||
<script | ||
async | ||
src="https://cdn.ampproject.org/v0/bento-social-share-1.0.js" | ||
></script> | ||
</head> | ||
<body> | ||
<h1>Social Share</h1> | ||
<p> | ||
<bento-social-share type="twitter"></bento-social-share> | ||
<bento-social-share type="facebook"></bento-social-share> | ||
<bento-social-share type="pinterest"></bento-social-share> | ||
<bento-social-share type="linkedin"></bento-social-share> | ||
<bento-social-share type="email"></bento-social-share> | ||
<bento-social-share type="tumblr"></bento-social-share> | ||
<bento-social-share type="whatsapp"></bento-social-share> | ||
<bento-social-share type="line"></bento-social-share> | ||
<bento-social-share type="sms"></bento-social-share> | ||
<bento-social-share type="system"></bento-social-share> | ||
</p> | ||
</body> | ||
</html> |