Skip to content

Commit

Permalink
Fix open document settings tests in WP 6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Jul 5, 2024
1 parent d5e33a9 commit a708eaf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/commands/wp-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* ```
*/
export const wpCli = (command: string, ignoreFailures = false): void => {
const escapedCommand = command.replace(/"/g, '\\"');
const escapedCommand = command.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
const options = {
failOnNonZeroExit: !ignoreFailures,
};
Expand Down
7 changes: 1 addition & 6 deletions tests/cypress/e2e/create-post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ describe('Command: createPost', () => {
.find('input[type="checkbox"]')
.should('be.checked');
} else {
cy.get(
'.editor-post-sticky__toggle-control input[type="checkbox"]'
).check();
cy.get(
'.editor-post-sticky__toggle-control input[type="checkbox"]'
).should('be.checked');
cy.get('.editor-post-sticky__toggle-control').should('be.visible');
}
});
},
Expand Down
28 changes: 19 additions & 9 deletions tests/cypress/e2e/open-document-settings.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { compare } from 'compare-versions';
const { randomName } = require('../support/functions');
import { getIframe } from '../../../lib/functions/get-iframe';

Expand Down Expand Up @@ -50,15 +51,19 @@ describe('Commands: openDocumentSettings*', () => {
) {
name = 'Summary';
}
cy.openDocumentSettingsPanel(name);

// Assertion: Stick to the top checkbox should be visible
cy.get('.components-panel__body .components-panel__body-title button')
.contains(name, { matchCase: false })
.then($button => {
const $panel = $button.parents('.components-panel__body');
cy.wrap($panel).should('contain', 'Stick to the top of the blog');
});
// WP 6.6 handling.
if ($body.find('.editor-post-summary').length === 0) {
cy.openDocumentSettingsPanel(name);
// Assertion: Stick to the top checkbox should be visible
cy.get('.components-panel__body .components-panel__body-title button')
.contains(name, { matchCase: false })
.then($button => {
const $panel = $button.parents('.components-panel__body');
cy.wrap($panel).should('contain', 'Stick to the top of the blog');
});
} else {
cy.get('.editor-post-sticky__toggle-control').should('be.visible');
}
});
});

Expand All @@ -83,6 +88,11 @@ describe('Commands: openDocumentSettings*', () => {
});

it('Should be able to open Discussion panel on the existing page', () => {
if (compare(Cypress.env('WORDPRESS_CORE').toString(), '6.6', '>=')) {
assert(true, 'Skipping test');
return;
}

cy.createPost({
title: randomName(),
postType: 'page',
Expand Down

0 comments on commit a708eaf

Please sign in to comment.