diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 24766cf1d87..41e3e166a5c 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -13,10 +13,14 @@ import 'cypress-wait-until'; Cypress.Commands.add('setTinyMceContent', (tinyMceId, content) => { cy.window().then((win) => { - cy.waitUntil(() => win.tinymce?.editors[tinyMceId]?.initialized, {timeout: 10000}).then(() => { + let currentEditor; + cy.waitUntil(() => { + currentEditor = win.tinymce.get(tinyMceId); + return currentEditor?.initialized; + }, {timeout: 10000}).then(() => { // Clear any pre-existing content in the editor - const editor = win.tinymce.editors[tinyMceId].setContent(''); + currentEditor.setContent(''); // The .type() command does not accept an empty string, // so we simulate interaction with the field that leaves @@ -37,9 +41,12 @@ Cypress.Commands.add('setTinyMceContent', (tinyMceId, content) => { Cypress.Commands.add('getTinyMceContent', (tinyMceId, content) => { return cy.window().then((win) => { - return cy.waitUntil(() => win.tinymce?.editors[tinyMceId]?.initialized, {timeout: 10000}).then(() => { - const editor = win.tinymce.editors[tinyMceId]; - return editor.getContent(); + let currentEditor; + return cy.waitUntil(() => { + currentEditor = win.tinymce.get(tinyMceId); + return currentEditor?.initialized + }, {timeout: 10000}).then(() => { + return currentEditor.getContent(); }); }); }); diff --git a/cypress/support/commands_new_workflow.js b/cypress/support/commands_new_workflow.js index c2bf43b7d76..53ee4d3c633 100644 --- a/cypress/support/commands_new_workflow.js +++ b/cypress/support/commands_new_workflow.js @@ -14,10 +14,14 @@ import 'cypress-iframe' Cypress.Commands.add('setTinyMceContent', (tinyMceId, content) => { cy.window().then((win) => { - cy.waitUntil(() => win.tinymce?.editors[tinyMceId]?.initialized, {timeout: 10000}).then(() => { + let currentEditor; + cy.waitUntil(() => { + currentEditor = win.tinymce.get(tinyMceId); + return currentEditor?.initialized; + }, {timeout: 10000}).then(() => { // Clear any pre-existing content in the editor - const editor = win.tinymce.editors[tinyMceId].setContent(''); + currentEditor.setContent(''); // The .type() command does not accept an empty string, // so we simulate interaction with the field that leaves @@ -38,9 +42,12 @@ Cypress.Commands.add('setTinyMceContent', (tinyMceId, content) => { Cypress.Commands.add('getTinyMceContent', (tinyMceId, content) => { return cy.window().then((win) => { - return cy.waitUntil(() => win.tinymce?.editors[tinyMceId]?.initialized, {timeout: 10000}).then(() => { - const editor = win.tinymce.editors[tinyMceId]; - return editor.getContent(); + let currentEditor; + return cy.waitUntil(() => { + currentEditor = win.tinymce.get(tinyMceId); + return currentEditor?.initialized + }, {timeout: 10000}).then(() => { + return currentEditor.getContent(); }); }); });