-
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.
- Loading branch information
Micajuine Ho
committed
May 10, 2021
1 parent
ff2d14b
commit 2a03843
Showing
5 changed files
with
142 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
65 changes: 65 additions & 0 deletions
65
extensions/amp-lightbox-gallery/0.1/test-e2e/test-carousel-0.2-declared.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,65 @@ | ||
/** | ||
* Copyright 2021 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. | ||
*/ | ||
|
||
const pageWidth = 800; | ||
const pageHeight = 600; | ||
|
||
describes.endtoend( | ||
'AMP Lightbox Gallery with AMP Carousel 2.0', | ||
{ | ||
fixture: 'amp-lightbox/amp-lightbox-with-carousel-0.2.amp.html', | ||
initialRect: {width: pageWidth, height: pageHeight}, | ||
environments: ['single'], | ||
}, | ||
async (env) => { | ||
let controller; | ||
|
||
function css(handle, name) { | ||
return controller.getElementCssValue(handle, name); | ||
} | ||
|
||
function prop(el, name) { | ||
return controller.getElementProperty(el, name); | ||
} | ||
|
||
beforeEach(async () => { | ||
controller = env.controller; | ||
}); | ||
|
||
it('should open/close lightbox', async () => { | ||
// First open the gallery. | ||
const firstAmpImg = await controller.findElement('amp-img'); | ||
await controller.click(firstAmpImg); | ||
|
||
// Verify it opened. | ||
const overlay = await controller.findElement('.i-amphtml-lbg-overlay'); | ||
const galleryButton = await controller.findElement( | ||
'[data-action="gallery"]' | ||
); | ||
const closeButton = await controller.findElement('[data-action="close"]'); | ||
await expect(css(overlay, 'opacity')).to.equal('1'); | ||
await expect(css(galleryButton, 'opacity')).to.equal('1'); | ||
await expect(css(closeButton, 'opacity')).to.equal('1'); | ||
|
||
// Wait for the first slide's image to load | ||
const firstSlideImg = await controller.findElement( | ||
'amp-lightbox-gallery img' | ||
); | ||
await expect(prop(firstSlideImg, 'naturalWidth')).to.be.gt(0); | ||
}); | ||
} | ||
); | ||
|
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
57 changes: 57 additions & 0 deletions
57
test/fixtures/e2e/amp-lightbox/amp-lightbox-with-carousel-0.2.amp.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,57 @@ | ||
<!doctype html> | ||
<html ⚡> | ||
<head> | ||
<meta charset="utf-8"> | ||
<link rel="canonical" href="/components/amp-lightbox-gallery/"> | ||
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> | ||
<script async src="https://cdn.ampproject.org/v0.js"></script> | ||
<title>amp-lightbox-gallery with amp-carousel 0.2</title> | ||
<script async custom-element="amp-lightbox-gallery" src="https://cdn.ampproject.org/v0/amp-lightbox-gallery-0.1.js"></script> | ||
<script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.2.js"></script> | ||
|
||
<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> | ||
<style amp-custom> | ||
.overlay-text { | ||
position: absolute; | ||
bottom: 16px; | ||
left: 16px; | ||
z-index: 1; | ||
pointer-events: none; | ||
background-color: #494A4D; | ||
color: white; | ||
padding: 2px 6px 2px 6px; | ||
border-radius: 2px; | ||
opacity: 0.7; | ||
font-family: Roboto, sans-serif; | ||
font-size: 1em; | ||
} | ||
|
||
figure { | ||
margin: 0; | ||
} | ||
|
||
amp-img[lightbox] { | ||
cursor: pointer; | ||
} | ||
|
||
.container { | ||
margin: 0 6% 0 6%; | ||
} | ||
|
||
.paragraph { | ||
padding: 10px 0 10px 0; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<amp-img lightbox src="../../../manual/img/bluegradient.png" width="300" height="200" layout="responsive"></amp-img> | ||
<p class="paragraph">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
<amp-img lightbox src="../../../manual/img/redgradient.png" width="300" height="200" layout="responsive"></amp-img> | ||
<p class="paragraph">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
<amp-img lightbox src="../../../manual/img/lemonyellowgradient.png" width="300" height="200" layout="responsive"></amp-img> | ||
<p class="paragraph">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
</div> | ||
</body> | ||
</html> |