|
| 1 | +describe('ImageKit React SDK', () => { |
| 2 | + const APP_HOST = Cypress.env().APP_HOST; |
| 3 | + describe('Lazyload', () => { |
| 4 | + it('should have empty src before reaching lazyload threshold', () => { |
| 5 | + cy.visit(APP_HOST); |
| 6 | + |
| 7 | + cy.get('.lazyload').should('have.attr', 'src').and('equal', ''); |
| 8 | + }); |
| 9 | + |
| 10 | + it('should have actual src after reaching lazyload threshold', () => { |
| 11 | + cy.visit(APP_HOST); |
| 12 | + |
| 13 | + cy.get('.lazyload').scrollIntoView(); |
| 14 | + |
| 15 | + cy.wait(500); |
| 16 | + |
| 17 | + cy.get('.lazyload') |
| 18 | + .should('have.attr', 'src') |
| 19 | + .and('include', 'tr:h-200,w-200/default-image.jpg'); |
| 20 | + }); |
| 21 | + }); |
| 22 | + |
| 23 | + describe('Lazyload with LQIP', () => { |
| 24 | + it('should have lqip src before reaching threshold', () => { |
| 25 | + cy.visit(APP_HOST); |
| 26 | + |
| 27 | + cy.get('.lazyload-lqip') |
| 28 | + .should('have.attr', 'src') |
| 29 | + .and('include', 'tr:h-200,w-200:q-20,bl-30/default-image.jpg'); |
| 30 | + }); |
| 31 | + |
| 32 | + it('should have actual src after reaching element', () => { |
| 33 | + cy.visit(APP_HOST); |
| 34 | + |
| 35 | + cy.get('.lazyload-lqip').scrollIntoView(); |
| 36 | + |
| 37 | + cy.wait(1000); |
| 38 | + |
| 39 | + cy.get('.lazyload-lqip') |
| 40 | + .should('have.attr', 'src') |
| 41 | + .and('include', 'tr:h-200,w-200/default-image.jpg'); |
| 42 | + }); |
| 43 | + }); |
| 44 | + |
| 45 | + describe('LQIP', () => { |
| 46 | + // unable to test this because actual image load always finishes too quickly |
| 47 | + it.skip('should have lqip src before image is loaded', () => { |
| 48 | + cy.visit(APP_HOST); |
| 49 | + |
| 50 | + cy.get('.lqip') |
| 51 | + .should('have.attr', 'src') |
| 52 | + .and('include', 'tr:h-200,w-200:q-20,bl-30/default-image.jpg'); |
| 53 | + }); |
| 54 | + |
| 55 | + it('should have actual src after image is loaded', () => { |
| 56 | + cy.visit(APP_HOST); |
| 57 | + |
| 58 | + cy.get('.lqip').scrollIntoView(); |
| 59 | + |
| 60 | + cy.wait(500); |
| 61 | + |
| 62 | + cy.get('.lqip') |
| 63 | + .should('have.attr', 'src') |
| 64 | + .and('include', 'tr:h-200,w-200/default-image.jpg'); |
| 65 | + }); |
| 66 | + }); |
| 67 | +}); |
0 commit comments