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

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 24 08:59:26 UTC 2020


 cypress_test/integration_tests/common/nextcloud_helper.js       |  123 ++++++++++
 cypress_test/integration_tests/mobile/calc/nextcloud_spec.js    |  110 --------
 cypress_test/integration_tests/mobile/impress/nextcloud_spec.js |  110 --------
 cypress_test/integration_tests/mobile/writer/nextcloud_spec.js  |  111 ---------
 4 files changed, 138 insertions(+), 316 deletions(-)

New commits:
commit 391b8b7fd7cc4ea42189782926472591d5934d4a
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Sep 24 09:02:58 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Thu Sep 24 10:59:07 2020 +0200

    cypress: NC: extract some helper methods for nextcloud specific features.
    
    Change-Id: I47b1811ce08888501733544eaa42b8b117a08a8c
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/103292
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/cypress_test/integration_tests/common/nextcloud_helper.js b/cypress_test/integration_tests/common/nextcloud_helper.js
new file mode 100644
index 000000000..304c814e9
--- /dev/null
+++ b/cypress_test/integration_tests/common/nextcloud_helper.js
@@ -0,0 +1,123 @@
+/* global cy Cypress require */
+
+var mobileHelper = require('./mobile_helper');
+
+function checkAndCloseRevisionHistory() {
+	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();
+		});
+
+	cy.get('#revViewerContainer .icon-close')
+		.then(function(item) {
+			Cypress.env('IFRAME_LEVEL', '2');
+			cy.wrap(item)
+				.click();
+		});
+}
+
+function checkAndCloseSharing() {
+	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();
+		});
+}
+
+function insertImageFromStorage(fileName) {
+	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=\'' + fileName + '\']')
+		.click();
+
+	cy.get('.oc-dialog-buttonrow .primary')
+		.then(function(item) {
+			Cypress.env('IFRAME_LEVEL', '2');
+			cy.wrap(item)
+				.click();
+		});
+}
+
+function saveFileAs(fileName) {
+	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(fileName);
+
+	cy.get('.oc-dialog-buttonrow .primary')
+		.then(function(item) {
+			Cypress.env('IFRAME_LEVEL', '2');
+			cy.wrap(item)
+				.click();
+		});
+}
+
+module.exports.checkAndCloseRevisionHistory = checkAndCloseRevisionHistory;
+module.exports.checkAndCloseSharing = checkAndCloseSharing;
+module.exports.insertImageFromStorage = insertImageFromStorage;
+module.exports.saveFileAs = saveFileAs;
diff --git a/cypress_test/integration_tests/mobile/calc/nextcloud_spec.js b/cypress_test/integration_tests/mobile/calc/nextcloud_spec.js
index 5423ec68c..a384e2c29 100644
--- a/cypress_test/integration_tests/mobile/calc/nextcloud_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/nextcloud_spec.js
@@ -2,6 +2,7 @@
 
 var helper = require('../../common/helper');
 var mobileHelper = require('../../common/mobile_helper');
+var nextcloudHelper = require('../../common/nextcloud_helper');
 
 describe('Nextcloud specific tests.', function() {
 	var testFileName = 'nextcloud.ods';
@@ -15,30 +16,9 @@ describe('Nextcloud specific tests.', function() {
 
 		helper.beforeAll(testFileName, 'calc', 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();
-			});
+		nextcloudHelper.insertImageFromStorage('image_to_insert.png');
 
 		// TOD
 		//cy.get('.leaflet-pane.leaflet-overlay-pane svg g.Graphic')
@@ -51,31 +31,7 @@ describe('Nextcloud specific tests.', function() {
 		// 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();
-			});
+		nextcloudHelper.saveFileAs('1' + testFileName);
 
 		// Close the document
 		cy.get('#mobile-edit-button')
@@ -98,73 +54,17 @@ describe('Nextcloud specific tests.', function() {
 	it('Share.', function() {
 		helper.beforeAll(testFileName, 'calc');
 
-		// 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();
-			});
+		nextcloudHelper.checkAndCloseSharing();
 	});
 
 	it('Revision history.', function() {
 		helper.beforeAll(testFileName, 'calc');
 
-		// 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();
-			});
-
-		cy.get('#revViewerContainer .icon-close')
-			.then(function(item) {
-				Cypress.env('IFRAME_LEVEL', '2');
-				cy.wrap(item)
-					.click();
-			});
+		nextcloudHelper.checkAndCloseRevisionHistory();
 	});
 });
 
diff --git a/cypress_test/integration_tests/mobile/impress/nextcloud_spec.js b/cypress_test/integration_tests/mobile/impress/nextcloud_spec.js
index ea2cc9e4b..b16398298 100644
--- a/cypress_test/integration_tests/mobile/impress/nextcloud_spec.js
+++ b/cypress_test/integration_tests/mobile/impress/nextcloud_spec.js
@@ -2,6 +2,7 @@
 
 var helper = require('../../common/helper');
 var mobileHelper = require('../../common/mobile_helper');
+var nextcloudHelper = require('../../common/nextcloud_helper');
 
 describe('Nextcloud specific tests.', function() {
 	var testFileName = 'nextcloud.odp';
@@ -15,30 +16,9 @@ describe('Nextcloud specific tests.', function() {
 
 		helper.beforeAll(testFileName, 'impress', 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();
-			});
+		nextcloudHelper.insertImageFromStorage('image_to_insert.png');
 
 		cy.get('.leaflet-pane.leaflet-overlay-pane svg g')
 			.should('exist');
@@ -50,31 +30,7 @@ describe('Nextcloud specific tests.', function() {
 		// 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();
-			});
+		nextcloudHelper.saveFileAs('1' + testFileName);
 
 		// Close the document
 		cy.get('#mobile-edit-button')
@@ -97,73 +53,17 @@ describe('Nextcloud specific tests.', function() {
 	it('Share.', function() {
 		helper.beforeAll(testFileName, 'impress');
 
-		// 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();
-			});
+		nextcloudHelper.checkAndCloseSharing();
 	});
 
 	it('Revision history.', function() {
 		helper.beforeAll(testFileName, 'impress');
 
-		// 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();
-			});
-
-		cy.get('#revViewerContainer .icon-close')
-			.then(function(item) {
-				Cypress.env('IFRAME_LEVEL', '2');
-				cy.wrap(item)
-					.click();
-			});
+		nextcloudHelper.checkAndCloseRevisionHistory();
 	});
 });
 
diff --git a/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js b/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js
index 717ea1e0d..5224cb090 100644
--- a/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/nextcloud_spec.js
@@ -2,6 +2,7 @@
 
 var helper = require('../../common/helper');
 var mobileHelper = require('../../common/mobile_helper');
+var nextcloudHelper = require('../../common/nextcloud_helper');
 
 describe('Nextcloud specific tests.', function() {
 	var testFileName = 'nextcloud.odt';
@@ -15,30 +16,9 @@ describe('Nextcloud specific tests.', function() {
 
 		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();
-			});
+		nextcloudHelper.insertImageFromStorage('image_to_insert.png');
 
 		cy.get('.leaflet-pane.leaflet-overlay-pane svg g.Graphic')
 			.should('exist');
@@ -47,34 +27,9 @@ describe('Nextcloud specific tests.', function() {
 	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();
-			});
+		nextcloudHelper.saveFileAs('1' + testFileName);
 
 		// Close the document
 		cy.get('#mobile-edit-button')
@@ -97,73 +52,17 @@ describe('Nextcloud specific tests.', function() {
 	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();
-			});
+		nextcloudHelper.checkAndCloseSharing();
 	});
 
 	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();
-			});
-
-		cy.get('#revViewerContainer .icon-close')
-			.then(function(item) {
-				Cypress.env('IFRAME_LEVEL', '2');
-				cy.wrap(item)
-					.click();
-			});
+		nextcloudHelper.checkAndCloseRevisionHistory();
 	});
 });
 


More information about the Libreoffice-commits mailing list