Skip to content

Commit

Permalink
fix: disable rest api replacement when we are in the edit context
Browse files Browse the repository at this point in the history
  • Loading branch information
selul committed Jun 25, 2019
1 parent 161cb1a commit 58d83b0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
31 changes: 31 additions & 0 deletions cypress/integration/test_elementor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
describe( 'Check Homepage', function () {
it( 'successfully loads', function () {
cy.visit( '/' )
} );
it( 'Header should not have lazyload applied', function () {
cy.get( 'header img' ).should( 'not.have.attr', 'data-opt-src' );
} );
it( 'Elementor images should have replaced srcs', function () {
cy.get( '.elementor-image > img' ).should( 'have.attr', 'src' ).and( 'include', 'i.optimole.com' );
} );
it( 'Elementor images should data-opt-src attribute', function () {
cy.get( '.elementor-image > img' ).should( 'have.attr', 'data-opt-src' ).and( 'include', 'i.optimole.com' );
} );
it( 'Elementor images should have no script tag', function () {
cy.get( '.elementor-image > noscript' ).should( 'exist' );
cy.get( '.elementor-image > noscript' ).should( 'contain', 'img' ).should( 'contain', 'i.optimole.com' )
} );
it( 'Custom crop should have rt fill resize', function () {

cy.get( '.custom-crop .elementor-image > img' ).should( 'have.attr', 'data-opt-src' ).and( 'include', 'i.optimole.com' ).and( 'include', 'rt:fill' );
} );

it( 'Elementor gallery should be properly replaced', function () {
cy.get( '.elementor-image-gallery a ' ).should( 'have.attr', 'href' ).and( 'include', 'i.optimole.com' );
cy.get( '.elementor-image-gallery a > img' ).should( 'have.attr', 'src' ).and( 'include', 'i.optimole.com' );
} );
it( 'Elementor background image should be properly replaced', function () {
cy.get( '.div-with-background .elementor-column-wrap ' ).should( 'have.css','background-image' ).and( 'include', 'i.optimole.com' );
} );

} );
7 changes: 0 additions & 7 deletions cypress/integration/test_replacement.js

This file was deleted.

3 changes: 3 additions & 0 deletions inc/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public function should_replace() {
if ( array_key_exists( 'ct_builder', $_GET ) && $_GET['ct_builder'] == 'true' ) {
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'context', $_GET ) && $_GET['context'] == 'edit' ) {
return false; // @codeCoverageIgnore
}
if ( array_key_exists( 'tve', $_GET ) && $_GET['tve'] == 'true' ) {
return false; // @codeCoverageIgnore
}
Expand Down

0 comments on commit 58d83b0

Please sign in to comment.