Skip to content

Commit

Permalink
adds tests for optimizer bug
Browse files Browse the repository at this point in the history
  • Loading branch information
psorensen committed Feb 6, 2024
1 parent 8a05611 commit 708e9c1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"plugins": [".", "./tests/cypress/test-plugin"],
"plugins": [
".",
"./tests/cypress/test-plugin/e2e-test-plugin.php",
"./tests/cypress/test-plugin/e2e-test-plugin-optimizer.php"
],
"env": {
"tests": {
"mappings": {
Expand Down
9 changes: 9 additions & 0 deletions tests/cypress/e2e/safe-svg.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,13 @@ describe('Safe SVG Tests', () => {

cy.get('.media-item .error-div.error').should('exist').contains('has failed to upload');
});


// Test plugin doesn't break the block editor when no blocks are added
it('Plugin should not break the block editor when optimizer enabled', () => {
// Activate Test Plugin
cy.deactivatePlugin('safe-svg-cypress-test-plugin');
cy.activatePlugin('safe-svg-cypress-optimizer-test-plugin');
cy.createPost('Hello World');
});
});
12 changes: 12 additions & 0 deletions tests/cypress/test-plugin/e2e-test-plugin-optimizer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
/**
* Plugin name: Safe SVG Cypress Optimizer Test plugin
* Description: Test plugin for Safe SVG to test the optimizer.
*
* @package safe-svg
*/

/**
* Optimizer and allowed attributes can't be mutually enabled, hence the secondary testing plugin.
*/
add_filter('safe_svg_optimizer_enabled', '__return_true');

0 comments on commit 708e9c1

Please sign in to comment.