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
if (service === 'news') { | |
it('should have a visible image with a caption that is lazyloaded and has a noscript fallback image', () => { | |
cy.get('figure') | |
.eq(2) | |
.within(() => { | |
cy.get('div div div div').should( | |
'have.class', | |
'lazyload-placeholder', | |
); | |
}) | |
.scrollIntoView(); | |
cy.get('figure') | |
.eq(2) | |
.should('be.visible') | |
.should('to.have.descendants', 'img') | |
.should('to.have.descendants', 'figcaption') | |
// NB: If this test starts failing unexpectedly it's a good sign that the dom is being | |
// cleared during hydration. React won't render noscript tags on the client so if they | |
// get cleared during hydration, the following render wont re-add them. | |
// See https://github.com/facebook/react/issues/11423#issuecomment-341751071 or | |
// https://github.com/bbc/simorgh/pull/1872 for more infomation. | |
.within(() => { | |
cy.get('noscript').contains('<img '); | |
cy.get('div div').should( | |
'not.have.class', | |
'lazyload-placeholder', | |
); | |
}); | |
}); | |
} |