-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Lightbox for Masonry block (#2565)
* fix lightbox and add tests to catch this issue * tests are false positive. Correct tests add helper * fix comment spacing
- Loading branch information
1 parent
3158f96
commit 8e5701c
Showing
8 changed files
with
134 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,8 @@ | |
"json2po": "cd languages && find . -name '*.json' ! -name 'coblocks*.json' -execdir /bin/bash -c 'FROM=\"$0\" && TO=\"coblocks-`basename $0 .json`.po\" && echo \"$FROM > $TO\" && ../vendor/bin/json2po coblocks.json $FROM $TO && msgmerge --previous $TO coblocks.pot > $TO-msgmerge && mv $TO-msgmerge $TO && if [[ \"$OSTYPE\" == \"darwin\"* ]]; then sed -i \"\" -e \"/^#, fuzzy$/d\" $TO; else sed -i -e \"/^#, fuzzy$/d\" $TO; fi;' '{}' \\;", | ||
"lint:css": "wp-scripts lint-style", | ||
"lint:js": "wp-scripts lint-js", | ||
"lint:php": "wp-env run tests-cli --env-cwd=/var/www/html composer run lint -d /var/www/html/wp-content/plugins/coblocks/; #we use phpunit container because composer container only use php 8;", | ||
"lint:php:fix": "wp-env run tests-cli --env-cwd=/var/www/html composer run lint:fix -d /var/www/html/wp-content/plugins/coblocks/; #we use phpunit container because composer container only use php 8;", | ||
"lint:php": "wp-env run tests-cli --env-cwd=/var/www/html composer run lint -- -d /var/www/html/wp-content/plugins/coblocks/; #we use phpunit container because composer container only use php 8;", | ||
"lint:php:fix": "wp-env run tests-cli --env-cwd=/var/www/html composer run lint:fix -- -d /var/www/html/wp-content/plugins/coblocks/; #we use phpunit container because composer container only use php 8;", | ||
"makepot": "./vendor/bin/wp i18n make-pot . --skip-audit --exclude=\".dev,.github,.wordpress-org,build,docs,dist,node_modules,vendor,wordpress\" --headers='{\"Last-Translator\":\"[email protected]\",\"Report-Msgid-Bugs-To\":\"https://github.com/godaddy-wordpress/coblocks/issues\"}' --file-comment=\"Copyright (c) $(date +'%Y') GoDaddy Operating Company, LLC. All Rights Reserved.\" languages/coblocks.pot && yarn run pot2json", | ||
"po2jed": "cd languages && find . -name '*.po' -execdir /bin/bash -c 'FROM=\"$0\" && TO=\"`basename $0 .po`-coblocks-editor.json\" && echo \"$FROM > $TO\" && po2json $FROM $TO -f jed' '{}' \\;", | ||
"po2mo": "cd languages && find . -name '*.po' -execdir /bin/bash -c 'FROM=\"$0\" && TO=\"`basename $0 .po`.mo\" && echo \"$FROM > $TO\" && msgfmt $FROM -o $TO' '{}' \\;", | ||
|
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
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
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
72 changes: 72 additions & 0 deletions
72
src/extensions/lightbox-controls/test/lightbox-controls-masonry.cypress.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Include our constants | ||
*/ | ||
import * as helpers from '../../../../.dev/tests/cypress/helpers'; | ||
|
||
describe( 'Test CoBlocks Lightbox Controls extension on core/masonry', function() { | ||
/** | ||
* Test that we can add a image block to the content add image, | ||
* and alter image using the Lightbox Controls extension | ||
*/ | ||
it( 'Test coblocks/gallery-masonry block extends with Lightbox Controls component.', function() { | ||
const { imageBase } = helpers.upload.spec; | ||
helpers.addBlockToPost( 'coblocks/gallery-masonry', true ); | ||
|
||
helpers.upload.imageToBlock( 'coblocks/gallery-masonry' ); | ||
|
||
cy.get( '.has-lightbox' ).should( 'not.exist' ); | ||
|
||
helpers.savePage(); | ||
|
||
helpers.selectBlock( 'coblocks/gallery-masonry' ); | ||
|
||
helpers.toggleSettingCheckbox( /Lightbox/ ); | ||
|
||
cy.get( '.has-lightbox' ).should( 'exist' ); | ||
|
||
cy.get( 'figure.wp-block-image img[src*="http"]' ).should( 'have.attr', 'src' ).should( 'include', imageBase ); | ||
|
||
helpers.savePage(); | ||
|
||
helpers.checkForBlockErrors( 'core/image' ); | ||
|
||
helpers.viewPage(); | ||
|
||
cy.get( 'figure.wp-block-image img[src*="http"]' ).should( 'have.attr', 'src' ).should( 'include', imageBase ); | ||
|
||
cy.get( '.has-lightbox' ).should( 'exist' ); | ||
|
||
helpers.editPage(); | ||
} ); | ||
|
||
/** | ||
* Test that we can add a image block to the content add image, | ||
* and open Lightbox on Front-end when aligned | ||
*/ | ||
[ 'wide', 'full' ].forEach( ( alignment ) => { | ||
return it( `Test ${ alignment } alignment coblocks/gallery-masonry block with Lightbox Controls component.`, function() { | ||
const { imageBase } = helpers.upload.spec; | ||
helpers.addBlockToPost( 'coblocks/gallery-masonry', true ); | ||
|
||
helpers.upload.imageToBlock( 'coblocks/gallery-masonry' ); | ||
|
||
helpers.setBlockAlignment( alignment ); | ||
|
||
helpers.toggleSettingCheckbox( /Lightbox/ ); | ||
|
||
helpers.savePage(); | ||
|
||
helpers.viewPage(); | ||
|
||
cy.get( `figure[class*="align${ alignment }"] img[src*="http"][class^="wp-image-"]` ).should( 'have.attr', 'src' ).should( 'include', imageBase ); | ||
|
||
cy.get( '.coblocks-lightbox' ).should( 'be.hidden' ); | ||
|
||
cy.get( `figure[class*="align${ alignment }"] img[src*="http"][class^="wp-image-"]` ).click( { force: true } ); | ||
|
||
cy.get( '.coblocks-lightbox' ).should( 'be.visible' ); | ||
|
||
helpers.editPage(); | ||
} ); | ||
} ); | ||
} ); |