diff --git a/extensions/amp-lightbox-gallery/0.1/amp-lightbox-gallery.js b/extensions/amp-lightbox-gallery/0.1/amp-lightbox-gallery.js index 5a960dabfc19..76a75b9ed673 100644 --- a/extensions/amp-lightbox-gallery/0.1/amp-lightbox-gallery.js +++ b/extensions/amp-lightbox-gallery/0.1/amp-lightbox-gallery.js @@ -58,6 +58,7 @@ import {triggerAnalyticsEvent} from '../../../src/analytics'; /** @const */ const TAG = 'amp-lightbox-gallery'; +const AMP_CAROUSEL_TAG = 'amp-carousel'; const DEFAULT_GALLERY_ID = 'amp-lightbox-gallery'; const SLIDE_ITEM_SELECTOR = '.i-amphtml-slide-item, .i-amphtml-carousel-slotted'; @@ -370,17 +371,21 @@ export class AmpLightboxGallery extends AMP.BaseElement { * @private */ buildCarousel_(lightboxGroupId) { - const carouselVersion = isExperimentOn( + const extensionVersion = this.getAmpDoc().getExtensionVersion( + AMP_CAROUSEL_TAG + ); + const experimentVersion = isExperimentOn( this.win, 'amp-lightbox-gallery-carousel-0-2' ) ? '0.2' : '0.1'; + const carouselVersion = extensionVersion ?? experimentVersion; return Promise.all([ Services.extensionsFor(this.win).installExtensionForDoc( this.getAmpDoc(), - 'amp-carousel', + AMP_CAROUSEL_TAG, carouselVersion ), Services.extensionsFor(this.win).installExtensionForDoc( diff --git a/extensions/amp-lightbox-gallery/0.1/test-e2e/test-carousel-0.2-declared.js b/extensions/amp-lightbox-gallery/0.1/test-e2e/test-carousel-0.2-declared.js new file mode 100644 index 000000000000..a2a4257e0ae8 --- /dev/null +++ b/extensions/amp-lightbox-gallery/0.1/test-e2e/test-carousel-0.2-declared.js @@ -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); + }); + } + ); + \ No newline at end of file diff --git a/extensions/amp-lightbox-gallery/0.1/test-e2e/test-open-close.js b/extensions/amp-lightbox-gallery/0.1/test-e2e/test-open-close.js index d07bb811bc87..0ffb59182121 100644 --- a/extensions/amp-lightbox-gallery/0.1/test-e2e/test-open-close.js +++ b/extensions/amp-lightbox-gallery/0.1/test-e2e/test-open-close.js @@ -20,7 +20,7 @@ const pageHeight = 600; describes.endtoend( 'AMP Lightbox Gallery Open/Close', { - fixture: 'amp-lightbox-gallery-launch.amp.html', + fixture: 'amp-lightbox/amp-lightbox-gallery-launch.amp.html', initialRect: {width: pageWidth, height: pageHeight}, // TODO(sparhami) Get this working in other environments. environments: ['single'], diff --git a/test/fixtures/e2e/amp-lightbox/amp-lightbox-gallery-launch.amp.html b/test/fixtures/e2e/amp-lightbox/amp-lightbox-gallery-launch.amp.html index 414a557c397b..a16511baaa58 100644 --- a/test/fixtures/e2e/amp-lightbox/amp-lightbox-gallery-launch.amp.html +++ b/test/fixtures/e2e/amp-lightbox/amp-lightbox-gallery-launch.amp.html @@ -17,9 +17,6 @@ - - - + + + +
+ +

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.

+ +

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.

+ +

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.

+
+ +