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 13c95076d088..07b218efc90b 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 @@ -148,7 +148,7 @@ const renderOutlinkUI = (pageEl, attachmentEl) => { class="i-amphtml-story-outlink-page-attachment-img" style={{backgroundImage: `url(${openImgAttr}) !important`}} > - ) : ( + ) : openImgAttr ? null : ( renderOutlinkLinkIconElement() )} {openLabel} diff --git a/extensions/amp-story-page-attachment/0.1/test/test-amp-story-open-page-attachment.js b/extensions/amp-story-page-attachment/0.1/test/test-amp-story-open-page-attachment.js index ff51ee8d43ed..6c81b06e4230 100644 --- a/extensions/amp-story-page-attachment/0.1/test/test-amp-story-open-page-attachment.js +++ b/extensions/amp-story-page-attachment/0.1/test/test-amp-story-open-page-attachment.js @@ -244,5 +244,32 @@ describes.realWin( expect(openAttachmentLabelEl.textContent).to.equal('CTA text'); }); + + it('should build the open attachment UI with link icon', async () => { + outlinkEl.setAttribute('layout', 'nodisplay'); + outlinkEl.setAttribute('cta-text', 'Outlink with icon'); + + await outlink.buildCallback(); + await outlink.layoutCallback(); + + const openAttachmentLinkIcon = page.querySelector( + '.i-amphtml-story-page-open-attachment .i-amphtml-story-page-open-attachment-link-icon' + ); + expect(openAttachmentLinkIcon).to.exist; + }); + + it('should build the open attachment UI with no icon if cta-image=none', async () => { + outlinkEl.setAttribute('layout', 'nodisplay'); + outlinkEl.setAttribute('cta-text', 'Outlink without icon'); + outlinkEl.setAttribute('cta-image', 'none'); + + await outlink.buildCallback(); + await outlink.layoutCallback(); + + const openAttachmentLinkIcon = page.querySelector( + '.i-amphtml-story-page-open-attachment .i-amphtml-story-page-open-attachment-link-icon' + ); + expect(openAttachmentLinkIcon).to.not.exist; + }); } );