Skip to content

Commit

Permalink
#9366 Resolve cypress issue with tinymce upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
blesildaramirez committed Jan 13, 2025
1 parent b9cec3c commit dee320d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
17 changes: 12 additions & 5 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
});
});
});
Expand Down
17 changes: 12 additions & 5 deletions cypress/support/commands_new_workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
});
});
});
Expand Down

0 comments on commit dee320d

Please sign in to comment.