diff --git a/extensions/amp-story-page-attachment/0.1/amp-story-open-page-attachment.js b/extensions/amp-story-page-attachment/0.1/amp-story-open-page-attachment.js index 9d146ee44198..ac67c9c624ef 100644 --- a/extensions/amp-story-page-attachment/0.1/amp-story-open-page-attachment.js +++ b/extensions/amp-story-page-attachment/0.1/amp-story-open-page-attachment.js @@ -99,11 +99,6 @@ const ctaLabelFromAttr = (element) => */ const openLabelOrFallback = (element, attachmentEl, label) => { const localizationService = Services.localizationForDoc(element); - if (attachmentEl.parentElement.tagName === 'AMP-STORY-SHOPPING-ATTACHMENT') { - return localizationService.getLocalizedString( - LocalizedStringId_Enum.AMP_STORY_SHOPPING_CTA_LABEL - ); - } return ( label?.trim() || localizationService.getLocalizedString( diff --git a/extensions/amp-story-shopping/0.1/amp-story-shopping-attachment.js b/extensions/amp-story-shopping/0.1/amp-story-shopping-attachment.js index d9c6894763aa..efea6aa700f2 100644 --- a/extensions/amp-story-shopping/0.1/amp-story-shopping-attachment.js +++ b/extensions/amp-story-shopping/0.1/amp-story-shopping-attachment.js @@ -54,14 +54,6 @@ export class AmpStoryShoppingAttachment extends AMP.BaseElement { /** @override */ buildCallback() { loadFonts(this.win, FONTS_TO_LOAD); - this.attachmentEl_ = ( - - ); - this.element.appendChild(this.attachmentEl_); - this.attachmentEl_.appendChild(this.plpContainer_); return Promise.all([ Services.storyStoreServiceForOrNull(this.win), @@ -69,6 +61,18 @@ export class AmpStoryShoppingAttachment extends AMP.BaseElement { ]).then(([storeService, localizationService]) => { this.storeService_ = storeService; this.localizationService_ = localizationService; + + this.attachmentEl_ = ( + + ); + this.element.appendChild(this.attachmentEl_); + this.attachmentEl_.appendChild(this.plpContainer_); }); } diff --git a/extensions/amp-story-shopping/0.1/test/test-amp-story-shopping-attachment.js b/extensions/amp-story-shopping/0.1/test/test-amp-story-shopping-attachment.js index 680e5fd9e51a..a7cdc34026b2 100644 --- a/extensions/amp-story-shopping/0.1/test/test-amp-story-shopping-attachment.js +++ b/extensions/amp-story-shopping/0.1/test/test-amp-story-shopping-attachment.js @@ -89,6 +89,14 @@ describes.realWin( expect(() => shoppingImpl.layoutCallback()).to.not.throw(); }); + it('should build CTA with i18n shopping label text', async () => { + await dispatchTestShoppingData(); + const attachmentChildEl = shoppingEl.querySelector( + 'amp-story-page-attachment' + ); + expect(attachmentChildEl.getAttribute('cta-text')).to.equal('Shop Now'); + }); + it('should open attachment', async () => { await dispatchTestShoppingData(); const attachmentChildEl = shoppingEl.querySelector(