[Libreoffice-commits] online.git: cypress_test/cypress.json cypress_test/integration_tests cypress_test/Makefile.am
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 10 12:03:43 UTC 2020
cypress_test/Makefile.am | 10 -
cypress_test/cypress.json | 3
cypress_test/integration_tests/common/helper.js | 201 ++++++++++++++++++++++--
3 files changed, 194 insertions(+), 20 deletions(-)
New commits:
commit ebd040cacbd674bfbb38e952c73dfa2334968d31
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Sep 3 15:52:40 2020 +0200
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Thu Sep 10 14:03:24 2020 +0200
cypress: support running test with nextcloud integration.
Change-Id: I0b2255225a6c0eca5317559df33bb12b841dac08
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102260
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am
index 78ab24784..821886137 100644
--- a/cypress_test/Makefile.am
+++ b/cypress_test/Makefile.am
@@ -233,7 +233,9 @@ define run_JS_error_check
endef
define start_loolwsd
- $(eval FREE_PORT:=$(shell $(GET_PORT_BINARY) --host=127.0.0.1 $(ALLOWED_PORTS)))
+ $(if $(findstring nextcloud, $(CYPRESS_INTEGRATION)),\
+ $(eval FREE_PORT:=9980),\
+ $(eval FREE_PORT:=$(shell $(GET_PORT_BINARY) --host=127.0.0.1 $(ALLOWED_PORTS))))
@echo "Found available port for testing: $(FREE_PORT)"
@echo
@echo "Launching loolwsd..."
@@ -263,19 +265,19 @@ DESKTOP_CONFIG = \
integrationFolder=$(DESKTOP_TEST_FOLDER),supportFile=$(SUPPORT_FILE),userAgent=$(DESKTOP_USER_AGENT)
DESKTOP_ENV = \
- DATA_FOLDER=$(DESKTOP_DATA_FOLDER),WORKDIR=$(DESKTOP_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT),LO_CORE_VERSION="$(CORE_VERSION)"
+ DATA_FOLDER=$(DESKTOP_DATA_FOLDER),WORKDIR=$(DESKTOP_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT),LO_CORE_VERSION="$(CORE_VERSION)",INTEGRATION=$(CYPRESS_INTEGRATION)
MOBILE_CONFIG = \
integrationFolder=$(MOBILE_TEST_FOLDER),supportFile=$(SUPPORT_FILE),userAgent=$(MOBILE_USER_AGENT)
MOBILE_ENV = \
- DATA_FOLDER=$(MOBILE_DATA_FOLDER),WORKDIR=$(MOBILE_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT),LO_CORE_VERSION="$(CORE_VERSION)"
+ DATA_FOLDER=$(MOBILE_DATA_FOLDER),WORKDIR=$(MOBILE_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT),LO_CORE_VERSION="$(CORE_VERSION)",INTEGRATION=$(CYPRESS_INTEGRATION)
MULTIUSER_CONFIG = \
integrationFolder=$(MULTIUSER_TEST_FOLDER),supportFile=$(SUPPORT_FILE),userAgent=$(DESKTOP_USER_AGENT),defaultCommandTimeout=30000
MULTIUSER_ENV = \
- DATA_FOLDER=$(MULTIUSER_DATA_FOLDER),WORKDIR=$(MULTIUSER_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT),LO_CORE_VERSION="$(CORE_VERSION)"
+ DATA_FOLDER=$(MULTIUSER_DATA_FOLDER),WORKDIR=$(MULTIUSER_WORKDIR),WSD_VERSION_HASH=$(LOOLWSD_VERSION_HASH),SERVER_PORT=$(FREE_PORT),LO_CORE_VERSION="$(CORE_VERSION)",INTEGRATION=$(CYPRESS_INTEGRATION)
define run_interactive_desktop
$(if $(1),\
diff --git a/cypress_test/cypress.json b/cypress_test/cypress.json
index 30ae76ce1..2feecac35 100644
--- a/cypress_test/cypress.json
+++ b/cypress_test/cypress.json
@@ -5,5 +5,6 @@
"defaultCommandTimeout" : 6000,
"testFiles" : "**/*_spec.js",
"modifyObstructiveCode": false,
- "fixturesFolder" : "data"
+ "fixturesFolder" : "data",
+ "chromeWebSecurity": false
}
diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js
index f461f90cc..ce08fe87f 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -1,9 +1,10 @@
/* global cy Cypress expect require */
require('cypress-wait-until');
+require('cypress-file-upload');
-function loadTestDoc(fileName, subFolder, noFileCopy) {
- cy.log('Loading test document - start.');
+function loadTestDocLocal(fileName, subFolder, noFileCopy) {
+ cy.log('Loading test document with a local build - start.');
cy.log('Param - fileName: ' + fileName);
cy.log('Param - subFolder: ' + subFolder);
cy.log('Param - noFileCopy: ' + noFileCopy);
@@ -53,6 +54,131 @@ function loadTestDoc(fileName, subFolder, noFileCopy) {
win.onerror = cy.onUncaughtException;
}});
+ cy.log('Loading test document with a local build - end.');
+}
+
+function loadTestDocNextcloud(fileName, subFolder) {
+ cy.log('Loading test document with nextcloud - start.');
+ cy.log('Param - fileName: ' + fileName);
+ cy.log('Param - subFolder: ' + subFolder);
+
+ // Open local nextcloud installation
+ cy.visit('http://localhost/nextcloud');
+
+ // Log in with cypress test user / password
+ cy.get('input#user')
+ .clear()
+ .type('cypress_test');
+
+ cy.get('input#password')
+ .clear()
+ .type('cypress_test');
+
+ cy.get('input#submit-form')
+ .click();
+
+ cy.get('.button.new')
+ .should('be.visible');
+
+ // Wait for free space calculation before uploading document
+ cy.get('#free_space')
+ .should('not.have.attr', 'value', '');
+
+ // Remove file if exists
+ cy.get('#fileList')
+ .then(function(filelist) {
+ if (filelist.find('tr[data-file=\'' + fileName + '\']').length !== 0) {
+ cy.get('tr[data-file=\'' + fileName + '\'] .action-menu.permanent')
+ .click();
+
+ cy.get('.menuitem.action.action-delete.permanent')
+ .click();
+ }
+ });
+
+ cy.get('tr[data-file=\'' + fileName + '\']')
+ .should('not.exist');
+
+ // Upload test document
+ var fileURI = '';
+ if (subFolder === undefined) {
+ fileURI += fileName;
+ } else {
+ fileURI += subFolder + '/' + fileName;
+ }
+ doIfOnDesktop(function() {
+ cy.get('input#file_upload_start')
+ .attachFile({ filePath: 'desktop/' + fileURI, encoding: 'binary' });
+ });
+ doIfOnMobile(function() {
+ cy.get('input#file_upload_start')
+ .attachFile({ filePath: 'mobile/' + fileURI, encoding: 'binary' });
+ });
+
+ cy.get('#uploadprogressbar')
+ .should('not.be.visible');
+
+ // Open test document
+ cy.get('tr[data-file=\'' + fileName + '\']')
+ .click();
+
+ cy.get('iframe#richdocumentsframe')
+ .should('be.visible', {timeout : Cypress.config('defaultCommandTimeout') * 2.0});
+
+ var getIframeBody = function(originalGet) {
+ return cy.wrap(originalGet('iframe#richdocumentsframe'))
+ .its('0.contentDocument', {log: false}).should('exist')
+ .its('body', {log: false}).should('not.be.undefined')
+ .then(cy.wrap, {log: false})
+ .find('iframe#loleafletframe', {log: false})
+ .its('0.contentDocument', {log: false}).should('exist')
+ .its('body', {log: false}).should('not.be.undefined')
+ .then(cy.wrap, {log: false});
+ };
+
+ cy.get('iframe#richdocumentsframe')
+ .then(function() {
+ Cypress.env('WITHIN_IFRAME', 'TRUE');
+ });
+
+ Cypress.Commands.overwrite('get', function(originalFn, selector, options) {
+ if (Cypress.env('WITHIN_IFRAME') === 'TRUE' && !selector.startsWith('@'))
+ if (selector === 'body')
+ return getIframeBody(originalFn);
+ else
+ return getIframeBody(originalFn).find(selector, options);
+ else
+ return originalFn(selector, options);
+ });
+
+ Cypress.Commands.overwrite('contains', function(originalFn, selector, content, options) {
+ if (Cypress.env('WITHIN_IFRAME') === 'TRUE')
+ return cy.get('#document-container').parent().wrap(originalFn(selector, content, options));
+ else
+ return originalFn(selector, content, options);
+ });
+
+ cy.wait(10000);
+
+ cy.log('Loading test document with nextcloud - end.');
+}
+
+function loadTestDoc(fileName, subFolder, noFileCopy) {
+ cy.log('Loading test document - start.');
+ cy.log('Param - fileName: ' + fileName);
+ cy.log('Param - subFolder: ' + subFolder);
+ cy.log('Param - noFileCopy: ' + noFileCopy);
+
+ doIfOnMobile(function() {
+ cy.viewport('iphone-6');
+ });
+
+ if (Cypress.env('INTEGRATION') === 'nextcloud') {
+ loadTestDocNextcloud(fileName, subFolder);
+ } else {
+ loadTestDocLocal(fileName, subFolder, noFileCopy);
+ }
+
// Wait for the document to fully load
cy.get('.leaflet-tile-loaded', {timeout : Cypress.config('defaultCommandTimeout') * 2.0});
@@ -181,16 +307,59 @@ function beforeAll(fileName, subFolder, noFileCopy) {
function afterAll(fileName) {
cy.log('Waiting for closing the document - start.');
- cy.log('Param - fileName: ' + fileName);
- // Make sure that the document is closed
- cy.visit('http://admin:admin@localhost:' +
+ if (Cypress.env('INTEGRATION') === 'nextcloud') {
+ if (Cypress.env('WITHIN_IFRAME') === 'TRUE') {
+ // Close the document
+ doIfOnMobile(function() {
+ cy.get('#tb_actionbar_item_closemobile')
+ .then(function(item) {
+ cy.wrap(item)
+ .click();
+ Cypress.env('WITHIN_IFRAME', '');
+ });
+ });
+ doIfOnDesktop(function() {
+ cy.get('#closebutton')
+ .then(function(item) {
+ cy.wrap(item)
+ .click();
+ Cypress.env('WITHIN_IFRAME', '');
+ });
+ });
+
+ cy.get('#filestable')
+ .should('be.visible');
+
+ cy.get('#filestable')
+ .should('not.have.class', 'hidden');
+
+ cy.wait(3000);
+
+ // Remove the document
+ cy.get('tr[data-file=\'' + fileName + '\'] .action-menu.permanent')
+ .click();
+
+ cy.get('.menuitem.action.action-delete.permanent')
+ .click();
+
+ cy.get('tr[data-file=\'' + fileName + '\']')
+ .should('not.exist');
+
+ }
+ } else if (Cypress.env('SERVER_PORT') === 9979) {
+ // Make sure that the document is closed
+ cy.visit('http://admin:admin@localhost:' +
Cypress.env('SERVER_PORT') +
'/loleaflet/dist/admin/admin.html');
- if (Cypress.env('SERVER_PORT') === 9979) {
cy.wait(5000);
} else {
+ // Make sure that the document is closed
+ cy.visit('http://admin:admin@localhost:' +
+ Cypress.env('SERVER_PORT') +
+ '/loleaflet/dist/admin/admin.html');
+
cy.get('#uptime')
.should('not.have.text', '0');
@@ -515,16 +684,18 @@ function moveCursor(direction) {
function typeIntoDocument(text) {
cy.log('Typing into document - start.');
- cy.document()
- .then(function(doc) {
- if (doc.activeElement.className !== 'clipboard') {
- cy.get('textarea.clipboard')
- .focus();
+ if (Cypress.env('INTEGRATION') !== 'nextcloud') {
+ cy.document()
+ .then(function(doc) {
+ if (doc.activeElement.className !== 'clipboard') {
+ cy.get('textarea.clipboard')
+ .focus();
- cy.document().its('activeElement.className')
- .should('be.eq', 'clipboard');
- }
- });
+ cy.document().its('activeElement.className')
+ .should('be.eq', 'clipboard');
+ }
+ });
+ }
cy.get('textarea.clipboard')
.type(text, {force: true});
More information about the Libreoffice-commits
mailing list