From 080417717470dd8faba51ac3efe05acce7098c95 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Wed, 7 Aug 2024 16:04:09 -0300 Subject: [PATCH] post password in WP 6.6 --- tests/cypress/support/commands.js | 46 +++++++++++++++++++------------ 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index a97135c136..f18b1411eb 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -1,3 +1,5 @@ +/* global wpVersion */ + // *********************************************** // This example commands.js shows you how to // create various custom commands and overwrite @@ -136,19 +138,31 @@ Cypress.Commands.add('publishPost', (postData, viewPost) => { if (newPostData.password && newPostData.password !== '') { cy.get('h1.editor-post-title__input').click(); - cy.get('body').then(($body) => { - const $button = $body.find('.edit-post-post-visibility__toggle'); - if (!$button.is(':visible')) { - cy.get('.edit-post-header__settings button[aria-label="Settings"]').click(); - } - }); - cy.get('.edit-post-post-visibility__toggle').click(); - cy.get('.editor-post-visibility__dialog-radio, .editor-post-visibility__radio').check( - 'password', - ); - cy.get( - '.editor-post-visibility__dialog-password-input, .editor-post-visibility__password-input', - ).type(newPostData.password); + if (wpVersion === '6.0') { + cy.get('body').then(($body) => { + const $button = $body.find('.edit-post-post-visibility__toggle'); + if (!$button.is(':visible')) { + cy.get('.edit-post-header__settings button[aria-label="Settings"]').click(); + } + }); + cy.get('.edit-post-post-visibility__toggle').click(); + cy.get('.editor-post-visibility__dialog-radio, .editor-post-visibility__radio').check( + 'password', + ); + cy.get( + '.editor-post-visibility__dialog-password-input, .editor-post-visibility__password-input', + ).type(newPostData.password); + } else { + cy.get('body').then(($body) => { + const $button = $body.find('.components-dropdown.editor-post-status'); + if (!$button.is(':visible')) { + cy.get('.editor-header__settings button[aria-label="Settings"]').click(); + } + }); + cy.get('.components-dropdown.editor-post-status').click(); + cy.get('.editor-change-status__password-fieldset input[type="checkbox"]').click(); + cy.get('.editor-change-status__password-input input').type(newPostData.password); + } } if (newPostData.status && newPostData.status === 'draft') { @@ -463,10 +477,8 @@ Cypress.Commands.add('createUser', (userData) => { if (newUserDate.login) { cy.visit('wp-login.php'); - cy.get('#user_login').clear(); - cy.get('#user_login').type(newUserDate.username); - cy.get('#user_pass').clear(); - cy.get('#user_pass').type(`${newUserDate.password}{enter}`); + cy.get('#user_login').clearThenType(newUserDate.username); + cy.get('#user_pass').clearThenType(`${newUserDate.password}{enter}`); } });