Skip to content

Commit

Permalink
pkp#7709 Added setTinyMceContent/getTinyMceContent to Cypress commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Nov 25, 2022
1 parent 25117c2 commit 0627869
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@
import 'cypress-file-upload';
import 'cypress-wait-until';

Cypress.Commands.add('setTinyMceContent', (tinyMceId, content) => {
cy.window().then((win) => {
cy.waitUntil(() => win.tinymce?.editors[tinyMceId]?.initialized, {timeout: 10000}).then(() => {
const editor = win.tinymce.editors[tinyMceId];
editor.setContent(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();
});
});
});

// See https://stackoverflow.com/questions/58657895/is-there-a-reliable-way-to-have-cypress-exit-as-soon-as-a-test-fails/58660504#58660504
Cypress.Commands.add('abortEarly', (self) => {
if (self.currentTest.state === 'failed') {
Expand Down

0 comments on commit 0627869

Please sign in to comment.