cypress_test/integration_tests/common/helper.js        |   55 ++++++++++++-----
 cypress_test/integration_tests/common/mobile_helper.js |   11 +--
 2 files changed, 44 insertions(+), 22 deletions(-)

New commits:
commit cfb803961cb6944b4919181c59028c2072a17986
Author:     Tamás Zolnai <tamas.zol...@collabora.com>
AuthorDate: Mon Jun 22 12:34:06 2020 +0200
Commit:     Tamás Zolnai <tamas.zol...@collabora.com>
CommitDate: Mon Jun 22 13:26:29 2020 +0200

    cypress: better way of adding conditional code based on doc type.
    
    Change-Id: I8001eec9732a445830db81502446e675acc20304
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96841
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com>

diff --git a/cypress_test/integration_tests/common/helper.js 
b/cypress_test/integration_tests/common/helper.js
index 00490c9bd..baafe49fb 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -124,25 +124,35 @@ function clearAllText() {
 
 // Check that the clipboard text matches with the specified text.
 function expectTextForClipboard(expectedPlainText) {
-       if (isWriter()) {
+       doIfInWriter(function() {
                cy.get('#copy-paste-container p font')
                        .should('have.text', expectedPlainText);
-       } else {
+       });
+       doIfInCalc(function() {
                cy.get('#copy-paste-container pre')
                        .should('have.text', expectedPlainText);
-       }
+       });
+       doIfInImpress(function() {
+               cy.get('#copy-paste-container pre')
+                       .should('have.text', expectedPlainText);
+       });
 }
 
 // Check that the clipboard text matches with the
 // passed regular expression.
 function matchClipboardText(regexp) {
-       if (isWriter()) {
+       doIfInWriter(function() {
                cy.contains('#copy-paste-container p font', regexp)
                        .should('exist');
-       } else {
+       });
+       doIfInCalc(function() {
                cy.contains('#copy-paste-container pre', regexp)
                        .should('exist');
-       }
+       });
+       doIfInImpress(function() {
+               cy.contains('#copy-paste-container pre', regexp)
+                       .should('exist');
+       });
 }
 
 function beforeAllDesktop(fileName, subFolder) {
@@ -206,16 +216,31 @@ function initAliasToEmptyString(aliasName) {
        cy.log('Initializing alias to empty string - end.');
 }
 
-function isCalc() {
-       return Cypress.$('.spreadsheet-header-columns').length != 0;
+function doIfInCalc(callback) {
+       cy.get('#document-container')
+               .then(function(doc) {
+                       if (doc.hasClass('spreadsheet-doctype')) {
+                               callback();
+                       }
+               });
 }
 
-function isImpress() {
-       return Cypress.$('#slide-sorter').length != 0;
+function doIfInImpress(callback) {
+       cy.get('#document-container')
+               .then(function(doc) {
+                       if (doc.hasClass('presentation-doctype')) {
+                               callback();
+                       }
+               });
 }
 
-function isWriter() {
-       return !isCalc() && !isImpress();
+function doIfInWriter(callback) {
+       cy.get('#document-container')
+               .then(function(doc) {
+                       if (doc.hasClass('text-doctype')) {
+                               callback();
+                       }
+               });
 }
 
 // Types text into elem with a delay in between characters.
@@ -282,9 +307,9 @@ module.exports.matchClipboardText = matchClipboardText;
 module.exports.afterAll = afterAll;
 module.exports.initAliasToNegative = initAliasToNegative;
 module.exports.initAliasToEmptyString = initAliasToEmptyString;
-module.exports.isCalc = isCalc;
-module.exports.isImpress = isImpress;
-module.exports.isWriter = isWriter;
+module.exports.doIfInCalc = doIfInCalc;
+module.exports.doIfInImpress = doIfInImpress;
+module.exports.doIfInWriter = doIfInWriter;
 module.exports.beforeAllDesktop = beforeAllDesktop;
 module.exports.typeText = typeText;
 module.exports.getLOVersion = getLOVersion;
diff --git a/cypress_test/integration_tests/common/mobile_helper.js 
b/cypress_test/integration_tests/common/mobile_helper.js
index ca8ec398f..56c790b94 100644
--- a/cypress_test/integration_tests/common/mobile_helper.js
+++ b/cypress_test/integration_tests/common/mobile_helper.js
@@ -21,13 +21,10 @@ function enableEditingMobile() {
        cy.get('#toolbar-down')
                .should('be.visible');
 
-       cy.get('#document-container')
-               .then(function(doc) {
-                       if (doc.hasClass('spreadsheet-document')) {
-                               cy.get('#formulabar')
-                                       .should('be.visible');
-                       }
-               });
+       helper.doIfInCalc(function() {
+               cy.get('#formulabar')
+                       .should('be.visible');
+       });
 
        cy.log('Enabling editing mode - end.');
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to