Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,29 @@
"jQuery": "readonly",
"tinyMCE": "readonly",
"insecureContentAdmin": "readonly"
},
"settings": {
"import/core-modules": [
"@wordpress/api-fetch",
"@wordpress/api-request",
"@wordpress/blob",
"@wordpress/block-editor",
"@wordpress/blocks",
"@wordpress/components",
"@wordpress/compose",
"@wordpress/data",
"@wordpress/date",
"@wordpress/dom-ready",
"@wordpress/dom",
"@wordpress/edit-post",
"@wordpress/element",
"@wordpress/hooks",
"@wordpress/i18n",
"@wordpress/keyboard-shortcuts",
"@wordpress/keycodes",
"@wordpress/plugins",
"@wordpress/primitives",
"@wordpress/rich-text"
]
}
}
21,115 changes: 11,806 additions & 9,309 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
},
"devDependencies": {
"@10up/cypress-wp-utils": "^0.6.0",
"@wordpress/env": "^10.22.0",
"@wordpress/scripts": "^30.6.0",
"cypress": "^14.3.2",
"@wordpress/env": "^10.38.0",
"@wordpress/scripts": "^31.3.0",
"cypress": "^15.9.0",
"husky": "^3.1.0"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/js/gutenberg.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const RedefineSaveShortcut = () => {
character: 's',
},
} );
}, [] );
}, [ unregisterShortcut, registerShortcut ] );

useShortcut( newSaveShortcutId, ( event ) => {
event.preventDefault();
Expand Down
90 changes: 52 additions & 38 deletions tests/cypress/e2e/block-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ describe("Block Editor Tests", () => {
cy.createPost({
title: title,
beforeSave: () => {
cy.insertInsecureBlock();
cy.insertInsecureBlock(() => {
cy.openDocumentSettingsSidebar("Post");
cy.clickPublish();

cy.openDocumentSettingsSidebar("Post");
cy.clickPublish();
cy.get(".components-notice").should(
"contain.text",
"1 insecure element found"
);

cy.get(".components-notice").should(
"contain.text",
"1 insecure element found"
);
cy.get(".components-checkbox-control__label")
.contains("Publish with insecure assets")
.click();
} );

cy.get(".components-checkbox-control__label")
.contains("Publish with insecure assets")
.click();
},
});
});
Expand All @@ -37,23 +38,36 @@ describe("Block Editor Tests", () => {
cy.createPost({
title: title,
beforeSave: () => {
cy.insertInsecureBlock();
cy.insertBlock("core/paragraph").then((id) => {
cy.getBlockEditor().find(`#${id}`).click().type(randomName());
});
cy.insertInsecureBlock();

cy.openDocumentSettingsSidebar("Post");
cy.clickPublish();

cy.get(".components-notice").should(
"contain.text",
"2 insecure elements found"
);

cy.get(".components-checkbox-control__label")
.contains("Publish with insecure assets")
.click();
cy.insertInsecureBlock(() => {
cy.insertBlock("core/html").then((id) => {
cy.getBlockEditor().find(`#${id}`).then(($block) => {
const $button = $block.find('.components-placeholder__fieldset button');
// WP 7.0+ uses a modal with a button, older versions use a textarea directly
if ($button.length > 0) {
cy.wrap($button).click();
cy.get('.block-editor-plain-text')
.type(randomName());
cy.get('.block-library-html__modal-footer button.is-primary').click();
} else {
// Older WordPress versions - textarea is directly available
cy.wrap($block.find('textarea')).type(randomName());
}
});
});
cy.insertInsecureBlock(() => {
cy.openDocumentSettingsSidebar("Post");
cy.clickPublish();

cy.get(".components-notice").should(
"contain.text",
"2 insecure elements found"
);

cy.get(".components-checkbox-control__label")
.contains("Publish with insecure assets")
.click();
} );
} );
},
});
});
Expand Down Expand Up @@ -90,19 +104,19 @@ describe("Block Editor Tests", () => {
cy.createPost({
title: title,
beforeSave: () => {
cy.insertInsecureHTMLBlock();

cy.openDocumentSettingsSidebar("Post");
cy.clickPublish();
cy.insertInsecureHTMLBlock( () => {
cy.openDocumentSettingsSidebar( 'Post' );
cy.clickPublish();

cy.get(".components-notice").should(
"contain.text",
"1 insecure element found"
);
cy.get( '.components-notice' ).should(
'contain.text',
'1 insecure element found'
);

cy.get(".components-checkbox-control__label")
.contains("Publish with insecure assets")
.click();
cy.get( '.components-checkbox-control__label' )
.contains( 'Publish with insecure assets' )
.click();
} );
},
});
});
Expand Down
11 changes: 9 additions & 2 deletions tests/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

const { loadConfig } = require('@wordpress/env/lib/config');
const getCacheDirectory = require('@wordpress/env/lib/config/get-cache-directory');
const path = require('path');

// Resolve the package directory
const wpEnvPackagePath = require.resolve('@wordpress/env/package.json');
const wpEnvLibPath = path.join(path.dirname(wpEnvPackagePath), 'lib');

// Directly require the files using their resolved paths
const { loadConfig } = require(path.join(wpEnvLibPath, 'config', 'index.js'));
const getCacheDirectory = require(path.join(wpEnvLibPath, 'config', 'get-cache-directory.js'));

/**
* @type {Cypress.PluginConfig}
Expand Down
17 changes: 15 additions & 2 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,21 @@ Cypress.Commands.add("insertInsecureBlock", (after) => {

Cypress.Commands.add("insertInsecureHTMLBlock", (after) => {
cy.insertBlock("core/html").then((id) => {
cy.getBlockEditor().find(`#${id} textarea`)
.type('<img src="http://google.com/dummy1.jpg" />', { force: true })
cy.getBlockEditor().find(`#${id}`).then(($block) => {
const $button = $block.find('.components-placeholder__fieldset button');
// WP 7.0+ uses a modal with a button, older versions use a textarea directly
if ($button.length > 0) {
// WordPress 7.0+ - click button to open modal
cy.wrap($button).click();
cy.get('.block-editor-plain-text')
.type('<img src="http://google.com/dummy1.jpg" />', { force: true });
cy.get('.block-library-html__modal-footer button.is-primary').click();
} else {
// Older WordPress versions - textarea is directly available
cy.wrap($block.find('textarea'))
.type('<img src="http://google.com/dummy1.jpg" />', { force: true });
}
});
if (after) {
after(id);
}
Expand Down