[Libreoffice-commits] online.git: cypress_test/data cypress_test/integration_tests cypress_test/plugins

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 23 14:42:04 UTC 2020


 cypress_test/data/mobile/writer/nextcloud.odt                  |binary
 cypress_test/integration_tests/common/helper.js                |  192 +++++++---
 cypress_test/integration_tests/mobile/writer/nextcloud_spec.js |  170 ++++++++
 cypress_test/plugins/blacklists.js                             |    5 
 cypress_test/plugins/index.js                                  |    5 
 5 files changed, 319 insertions(+), 53 deletions(-)

New commits:
commit 11b384b195992dbffc6bb5ec9eeb25f4630caa9c
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Tue Sep 22 16:51:23 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Sep 23 16:41:44 2020 +0200

    cypress: NC: test nextcloud specific features.
    
    Change-Id: I52bc1709f29de1d69c2ae52c806bedad4eee8bc4
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/103254
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/cypress_test/data/mobile/writer/nextcloud.odt b/cypress_test/data/mobile/writer/nextcloud.odt
new file mode 100644
index 000000000..f7494e82f
Binary files /dev/null and b/cypress_test/data/mobile/writer/nextcloud.odt differ
diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js
index f748b9bde..b41cbdeff 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -59,7 +59,138 @@ function loadTestDocLocal(fileName, subFolder, noFileCopy) {
 	cy.log('Loading test document with a local build - end.');
 }
 
-function loadTestDocNextcloud(fileName, subFolder) {
+function loadTestDocNextcloud(fileName, subFolder, subsequentLoad) {
+	cy.log('Loading test document with nextcloud - start.');
+	cy.log('Param - fileName: ' + fileName);
+	cy.log('Param - subFolder: ' + subFolder);
+	cy.log('Param - subsequentLoad: ' + subsequentLoad);
+
+	// Open local nextcloud installation
+	cy.visit('http://localhost/nextcloud');
+
+	if (subsequentLoad !== true) {
+		// 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 all files
+		cy.get('#fileList')
+			.then(function(filelist) {
+				if (filelist.find('tr').length !== 0) {
+					cy.waitUntil(function() {
+						cy.get('#fileList tr:nth-of-type(1) .action-menu.permanent')
+							.click();
+
+						cy.get('.menuitem.action.action-delete.permanent')
+							.click();
+
+						cy.get('#uploadprogressbar')
+							.should('not.be.visible');
+
+						return cy.get('#fileList')
+							.then(function(filelist) {
+								return filelist.find('tr').length === 0;
+							});
+					}, {timeout: 60000});
+				}
+			});
+	} else {
+		// Wait for free space calculation before uploading document
+		cy.get('#free_space')
+			.should('not.have.attr', 'value', '');
+	}
+
+	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, level) {
+		if (level === 1) {
+			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});
+		} else if (level === 2) {
+			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('IFRAME_LEVEL', '2');
+		});
+
+	Cypress.Commands.overwrite('get', function(originalFn, selector, options) {
+		var iFrameLevel = Cypress.env('IFRAME_LEVEL');
+		if ((iFrameLevel === '1' || iFrameLevel === '2') && !selector.startsWith('@'))
+			if (selector === 'body')
+				return getIframeBody(originalFn, parseInt(iFrameLevel));
+			else
+				return getIframeBody(originalFn, parseInt(iFrameLevel)).find(selector, options);
+		else
+			return originalFn(selector, options);
+	});
+
+	Cypress.Commands.overwrite('contains', function(originalFn, selector, content, options) {
+		if (Cypress.env('IFRAME_LEVEL') === '2')
+			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 loadFileToNextCloud(fileName, subFolder) {
 	cy.log('Loading test document with nextcloud - start.');
 	cy.log('Param - fileName: ' + fileName);
 	cy.log('Param - subFolder: ' + subFolder);
@@ -86,7 +217,6 @@ function loadTestDocNextcloud(fileName, subFolder) {
 	cy.get('#free_space')
 		.should('not.have.attr', 'value', '');
 
-	// Remove all files
 	cy.get('#fileList')
 		.then(function(filelist) {
 			if (filelist.find('tr').length !== 0) {
@@ -130,52 +260,11 @@ function loadTestDocNextcloud(fileName, subFolder) {
 	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.');
+		.should('be.visible');
 }
 
-function loadTestDoc(fileName, subFolder, noFileCopy) {
+function loadTestDoc(fileName, subFolder, noFileCopy, subsequentLoad) {
 	cy.log('Loading test document - start.');
 	cy.log('Param - fileName: ' + fileName);
 	cy.log('Param - subFolder: ' + subFolder);
@@ -186,7 +275,7 @@ function loadTestDoc(fileName, subFolder, noFileCopy) {
 	});
 
 	if (Cypress.env('INTEGRATION') === 'nextcloud') {
-		loadTestDocNextcloud(fileName, subFolder);
+		loadTestDocNextcloud(fileName, subFolder, subsequentLoad);
 	} else {
 		loadTestDocLocal(fileName, subFolder, noFileCopy);
 	}
@@ -321,8 +410,8 @@ function matchClipboardText(regexp) {
 	});
 }
 
-function beforeAll(fileName, subFolder, noFileCopy) {
-	loadTestDoc(fileName, subFolder, noFileCopy);
+function beforeAll(fileName, subFolder, noFileCopy, subsequentLoad) {
+	loadTestDoc(fileName, subFolder, noFileCopy, subsequentLoad);
 }
 
 function afterAll(fileName) {
@@ -333,7 +422,7 @@ function afterAll(fileName) {
 		return;
 
 	if (Cypress.env('INTEGRATION') === 'nextcloud') {
-		if (Cypress.env('WITHIN_IFRAME') === 'TRUE') {
+		if (Cypress.env('IFRAME_LEVEL') === '2') {
 			// Close the document
 			doIfOnMobile(function() {
 				cy.get('#tb_actionbar_item_closemobile')
@@ -346,7 +435,7 @@ function afterAll(fileName) {
 					.then(function(item) {
 						cy.wrap(item)
 							.click();
-						Cypress.env('WITHIN_IFRAME', '');
+						Cypress.env('IFRAME_LEVEL', '');
 					});
 			});
 			doIfOnDesktop(function() {
@@ -354,7 +443,7 @@ function afterAll(fileName) {
 					.then(function(item) {
 						cy.wrap(item)
 							.click();
-						Cypress.env('WITHIN_IFRAME', '');
+						Cypress.env('IFRAME_LEVEL', '');
 					});
 			});
 
@@ -774,3 +863,4 @@ module.exports.doIfOnMobile = doIfOnMobile;
 module.exports.doIfOnDesktop = doIfOnDesktop;
 module.exports.moveCursor = moveCursor;
 module.exports.typeIntoDocument = typeIntoDocument;
+module.exports.loadFileToNextCloud = loadFileToNextCloud;
diff --git a/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js b/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js
new file mode 100644
index 000000000..8df27bd59
--- /dev/null
+++ b/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js
@@ -0,0 +1,170 @@
+/* global describe it cy require afterEach Cypress */
+
+var helper = require('../../common/helper');
+var mobileHelper = require('../../common/mobile_helper');
+
+describe('Nextcloud specific tests.', function() {
+	var testFileName = 'nextcloud.odt';
+
+	afterEach(function() {
+		helper.afterAll(testFileName);
+	});
+
+	it('Insert image from storage.', function() {
+		helper.loadFileToNextCloud('image_to_insert.png', 'writer');
+
+		helper.beforeAll(testFileName, 'writer', undefined, true);
+
+		// Click on edit button
+		mobileHelper.enableEditingMobile();
+
+		mobileHelper.openInsertionWizard();
+
+		cy.get('.insertgraphicremote')
+			.then(function(item) {
+				Cypress.env('IFRAME_LEVEL', '');
+				cy.wrap(item)
+					.click();
+			});
+
+		cy.get('.oc-dialog')
+			.should('be.visible');
+
+		cy.get('tr[data-entryname=\'image_to_insert.png\']')
+			.click();
+
+		cy.get('.oc-dialog-buttonrow .primary')
+			.then(function(item) {
+				Cypress.env('IFRAME_LEVEL', '2');
+				cy.wrap(item)
+					.click();
+			});
+
+		cy.get('.leaflet-pane.leaflet-overlay-pane svg g.Graphic')
+			.should('exist');
+	});
+
+	it('Save as.', function() {
+		helper.beforeAll(testFileName, 'writer');
+
+		// Click on edit button
+		mobileHelper.enableEditingMobile();
+
+		mobileHelper.openHamburgerMenu();
+
+		cy.contains('.menu-entry-with-icon', 'File')
+			.click();
+
+		cy.contains('.menu-entry-with-icon', 'Save As...')
+			.then(function(item) {
+				Cypress.env('IFRAME_LEVEL', '1');
+				cy.wrap(item)
+					.click();
+			});
+
+		cy.get('.oc-dialog')
+			.should('be.visible');
+
+		cy.get('.oc-dialog input')
+			.clear()
+			.type('1' + testFileName);
+
+		cy.get('.oc-dialog-buttonrow .primary')
+			.then(function(item) {
+				Cypress.env('IFRAME_LEVEL', '2');
+				cy.wrap(item)
+					.click();
+			});
+
+		// Close the document
+		cy.get('#mobile-edit-button')
+			.should('be.visible');
+
+		cy.get('#tb_actionbar_item_closemobile')
+			.then(function(item) {
+				cy.wrap(item)
+					.click();
+				Cypress.env('IFRAME_LEVEL', '');
+			});
+
+		cy.get('tr[data-file=\'1' + testFileName + '\']')
+			.should('be.visible');
+
+		cy.get('tr[data-file=\'' + testFileName + '\']')
+			.should('be.visible');
+	});
+
+	it('Share.', function() {
+		helper.beforeAll(testFileName, 'writer');
+
+		// Click on edit button
+		mobileHelper.enableEditingMobile();
+
+		mobileHelper.openHamburgerMenu();
+
+		cy.contains('.menu-entry-with-icon', 'File')
+			.click();
+
+		cy.contains('.menu-entry-with-icon', 'Share...')
+			.then(function(item) {
+				Cypress.env('IFRAME_LEVEL', '');
+				cy.wrap(item)
+					.click();
+			});
+
+		cy.get('#app-sidebar')
+			.should('be.visible');
+
+		// issue here
+		//cy.get('section#sharing')
+		//	.should('be.visible');
+
+		cy.get('.app-sidebar__close.icon-close')
+			.then(function(item) {
+				Cypress.env('IFRAME_LEVEL', '2');
+				cy.wrap(item)
+					.click();
+			});
+	});
+
+	it('Revision history.', function() {
+		helper.beforeAll(testFileName, 'writer');
+
+		// Click on edit button
+		mobileHelper.enableEditingMobile();
+
+		mobileHelper.openHamburgerMenu();
+
+		cy.contains('.menu-entry-with-icon', 'File')
+			.click();
+
+		cy.contains('.menu-entry-with-icon', 'See revision history')
+			.then(function(item) {
+				Cypress.env('IFRAME_LEVEL', '');
+				cy.wrap(item)
+					.click();
+			});
+
+		cy.get('#app-sidebar')
+			.should('be.visible');
+
+		cy.get('section#tab-versionsTabView')
+			.should('be.visible');
+
+		cy.get('.app-sidebar__close.icon-close')
+			.then(function(item) {
+				Cypress.env('IFRAME_LEVEL', '1');
+				cy.wrap(item)
+					.click();
+			});
+
+		// issue here
+		cy.get('#revViewerContainer .icon-close')
+			.then(function(item) {
+				Cypress.env('IFRAME_LEVEL', '2');
+				cy.wrap(item)
+					.click();
+			});
+	});
+});
+
diff --git a/cypress_test/plugins/blacklists.js b/cypress_test/plugins/blacklists.js
index cf2edb893..3fc54ba6b 100644
--- a/cypress_test/plugins/blacklists.js
+++ b/cypress_test/plugins/blacklists.js
@@ -163,6 +163,11 @@ var phpProxyBlackList = [
 	],
 ];
 
+var nextcloudOnlyList = [
+	['mobile/writer/nextcloud_spec.js', []],
+];
+
 module.exports.coreBlackLists = coreBlackLists;
 module.exports.nextcloudBlackList = nextcloudBlackList;
+module.exports.nextcloudOnlyList = nextcloudOnlyList;
 module.exports.phpProxyBlackList = phpProxyBlackList;
diff --git a/cypress_test/plugins/index.js b/cypress_test/plugins/index.js
index 4547a88ba..83eccb2b6 100644
--- a/cypress_test/plugins/index.js
+++ b/cypress_test/plugins/index.js
@@ -79,8 +79,9 @@ function pickTests(filename, foundTests, config) {
 	testsToRun = removeBlacklistedTest(filename, testsToRun, coreblackList);
 
 	if (process.env.CYPRESS_INTEGRATION === 'nextcloud') {
-		var NCblackList = blacklists.nextcloudBlackList;
-		testsToRun = removeBlacklistedTest(filename, testsToRun, NCblackList);
+		testsToRun = removeBlacklistedTest(filename, testsToRun, blacklists.nextcloudBlackList);
+	} else {
+		testsToRun = removeBlacklistedTest(filename, testsToRun, blacklists.nextcloudOnlyList);
 	}
 
 	if (process.env.CYPRESS_INTEGRATION === 'php-proxy') {


More information about the Libreoffice-commits mailing list