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

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Wed May 20 13:07:33 UTC 2020


 cypress_test/integration_tests/common/calc.js                        |   33 ++++-
 cypress_test/integration_tests/mobile/calc/alignment_options_spec.js |   22 ---
 cypress_test/integration_tests/mobile/calc/apply_font_spec.js        |    3 
 cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js    |   25 ----
 cypress_test/integration_tests/mobile/calc/calc_helper.js            |   62 +++-------
 cypress_test/integration_tests/mobile/calc/cell_appearance_spec.js   |    3 
 cypress_test/integration_tests/mobile/calc/focus_spec.js             |    7 -
 cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js  |    3 
 cypress_test/integration_tests/mobile/calc/number_format_spec.js     |    5 
 cypress_test/integration_tests/mobile/calc/spellchecking_spec.js     |    8 -
 10 files changed, 73 insertions(+), 98 deletions(-)

New commits:
commit f1296cdf1970d021a99fe67add9681c89a5a5f72
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed May 20 14:32:45 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed May 20 15:07:22 2020 +0200

    cypress: extract selectFirstRow() method (calc)
    
    Change-Id: I1e7c9769249169986f411a7d5139ff6b0e9f751c
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94572
    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/mobile/calc/alignment_options_spec.js b/cypress_test/integration_tests/mobile/calc/alignment_options_spec.js
index 1208b90a1..178aaf25e 100644
--- a/cypress_test/integration_tests/mobile/calc/alignment_options_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/alignment_options_spec.js
@@ -324,18 +324,7 @@ describe('Change alignment settings.', function() {
 
 	it('Merge cells.', function() {
 		// Select the full row
-		cy.get('.spreadsheet-header-rows')
-			.then(function(items) {
-				expect(items).to.have.lengthOf(1);
-
-				var XPos = (items[0].getBoundingClientRect().right + items[0].getBoundingClientRect().left) / 2;
-				var YPos = items[0].getBoundingClientRect().top + 10;
-				cy.get('body')
-					.click(XPos, YPos);
-			});
-
-		cy.get('.spreadsheet-cell-resize-marker')
-			.should('exist');
+		calcHelper.selectFirstRow();
 
 		// Even after we get the cell row selection the merge cell options is still disabled
 		// So we open mobile wizard again and again until merge cells get the right state
diff --git a/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js b/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js
index 83b8ce4f4..48141adf1 100644
--- a/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js
@@ -127,21 +127,7 @@ describe('Interact with bottom toolbar.', function() {
 		before('bottom_toolbar.ods', 'calc');
 
 		// Select the full row
-		cy.get('.spreadsheet-header-rows')
-			.then(function(items) {
-				expect(items).to.have.lengthOf(1);
-
-				var XPos = (items[0].getBoundingClientRect().right + items[0].getBoundingClientRect().left) / 2;
-				var YPos = items[0].getBoundingClientRect().top + 10;
-				cy.get('body')
-					.click(XPos, YPos);
-			});
-
-		cy.get('.spreadsheet-cell-resize-marker')
-			.should('exist');
-
-		cy.get('.spreadsheet-cell-resize-marker:nth-of-type(2)')
-			.should('not.be.visible');
+		calcHelper.selectFirstRow();
 
 		cy.get('.w2ui-tb-image.w2ui-icon.togglemergecells')
 			.click();
diff --git a/cypress_test/integration_tests/mobile/calc/calc_helper.js b/cypress_test/integration_tests/mobile/calc/calc_helper.js
index f6f1c6ae1..cd24896ce 100644
--- a/cypress_test/integration_tests/mobile/calc/calc_helper.js
+++ b/cypress_test/integration_tests/mobile/calc/calc_helper.js
@@ -1,4 +1,4 @@
-/* global cy Cypress*/
+/* global cy Cypress expect*/
 
 function removeTextSelection() {
 	cy.log('Removing text selection - start.');
@@ -42,5 +42,24 @@ function selectAllMobile(removeSelection = true) {
 	cy.log('Selecting all text - end.');
 }
 
+function selectFirstRow() {
+	cy.get('.spreadsheet-header-rows')
+		.then(function(items) {
+			expect(items).to.have.lengthOf(1);
+
+			var XPos = (items[0].getBoundingClientRect().right + items[0].getBoundingClientRect().left) / 2;
+			var YPos = items[0].getBoundingClientRect().top + 10;
+			cy.get('body')
+				.click(XPos, YPos);
+		});
+
+	cy.get('.spreadsheet-cell-resize-marker:nth-of-type(1)')
+		.should('be.visible');
+
+	cy.get('.spreadsheet-cell-resize-marker:nth-of-type(2)')
+		.should('not.be.visible');
+}
+
 module.exports.removeTextSelection = removeTextSelection;
 module.exports.selectAllMobile = selectAllMobile;
+module.exports.selectFirstRow = selectFirstRow;
commit 5de4f9842448c960434ccc626d4f4fbe66768dd9
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed May 20 12:34:37 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed May 20 15:07:14 2020 +0200

    cypress: deduplicate clickOnFirstCell() method.
    
    Change-Id: I359d2f5a12ae83e598e1d61dfd2c4b943ef31f0e
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/94568
    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/calc.js b/cypress_test/integration_tests/common/calc.js
index 1e148d2fa..3c9c86d1e 100644
--- a/cypress_test/integration_tests/common/calc.js
+++ b/cypress_test/integration_tests/common/calc.js
@@ -23,23 +23,40 @@ function clickFormulaBar() {
 	cy.get('body').trigger('mouseover');
 }
 
-// Click on the first cell.
-function clickOnFirstCell() {
-	cy.get('.leaflet-container')
+function clickOnFirstCell(firstClick = true, dblClick = false) {
+	cy.log('Clicking on first cell - start.');
+	cy.log('Param - firstClick: ' + firstClick);
+	cy.log('Param - dblClick: ' + dblClick);
+
+	// Use the tile's edge to find the first cell's position
+	cy.get('#map')
 		.then(function(items) {
 			expect(items).to.have.lengthOf(1);
 			var XPos = items[0].getBoundingClientRect().left + 10;
 			var YPos = items[0].getBoundingClientRect().top + 10;
-			cy.get('body')
-				.click(XPos, YPos);
+			if (dblClick) {
+				cy.get('body')
+					.dblclick(XPos, YPos);
+			} else {
+				cy.get('body')
+					.click(XPos, YPos);
+			}
 		});
 
-	cy.wait(500);
+	if (firstClick && !dblClick)
+		cy.get('.spreadsheet-cell-resize-marker')
+			.should('be.visible');
+	else
+		cy.get('.leaflet-cursor.blinking-cursor')
+			.should('be.visible');
 
-	cy.get('.leaflet-marker-icon')
-		.should('be.visible');
+	cy.log('Clicking on first cell - end.');
+}
 
+function dblClickOnFirstCell() {
+	clickOnFirstCell(false, true);
 }
 
 module.exports.clickOnFirstCell = clickOnFirstCell;
+module.exports.dblClickOnFirstCell = dblClickOnFirstCell;
 module.exports.clickFormulaBar = clickFormulaBar;
diff --git a/cypress_test/integration_tests/mobile/calc/alignment_options_spec.js b/cypress_test/integration_tests/mobile/calc/alignment_options_spec.js
index fd4f2123f..1208b90a1 100644
--- a/cypress_test/integration_tests/mobile/calc/alignment_options_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/alignment_options_spec.js
@@ -1,6 +1,7 @@
 /* global describe it cy beforeEach require afterEach expect*/
 
 var helper = require('../../common/helper');
+var calc = require('../../common/calc');
 var mobileHelper = require('../../common/mobile_helper');
 var calcHelper = require('./calc_helper');
 
@@ -17,7 +18,7 @@ describe('Change alignment settings.', function() {
 	});
 
 	function getTextPosForFirstCell() {
-		calcHelper.dblClickOnFirstCell();
+		calc.dblClickOnFirstCell();
 
 		// Select text content
 		cy.get('textarea.clipboard')
@@ -37,7 +38,7 @@ describe('Change alignment settings.', function() {
 	}
 
 	function openAlignmentPaneForFirstCell() {
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		mobileHelper.openMobileWizard();
 
@@ -61,7 +62,7 @@ describe('Change alignment settings.', function() {
 			.should('have.attr', 'align', 'right');
 
 		// Change alignment back
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		mobileHelper.openMobileWizard();
 
@@ -130,7 +131,7 @@ describe('Change alignment settings.', function() {
 			.should('have.attr', 'valign', 'top');
 
 		// Change alignment back
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		mobileHelper.openMobileWizard();
 
diff --git a/cypress_test/integration_tests/mobile/calc/apply_font_spec.js b/cypress_test/integration_tests/mobile/calc/apply_font_spec.js
index ae93defdc..da662c6cc 100644
--- a/cypress_test/integration_tests/mobile/calc/apply_font_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/apply_font_spec.js
@@ -1,6 +1,7 @@
 /* global describe it cy beforeEach require afterEach Cypress*/
 
 var helper = require('../../common/helper');
+var calc = require('../../common/calc');
 var mobileHelper = require('../../common/mobile_helper');
 var calcHelper = require('./calc_helper');
 
@@ -11,7 +12,7 @@ describe('Apply font changes.', function() {
 		// Click on edit button
 		mobileHelper.enableEditingMobile();
 
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		cy.get('.leaflet-marker-icon')
 			.should('be.visible');
diff --git a/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js b/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js
index 4bae5c170..83b8ce4f4 100644
--- a/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js
@@ -1,6 +1,7 @@
 /* global describe it cy require afterEach expect */
 
 var helper = require('../../common/helper');
+var calc = require('../../common/calc');
 var mobileHelper = require('../../common/mobile_helper');
 var calcHelper = require('./calc_helper');
 
@@ -11,7 +12,7 @@ describe('Interact with bottom toolbar.', function() {
 		// Click on edit button
 		mobileHelper.enableEditingMobile();
 
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 	}
 
 	afterEach(function() {
@@ -19,7 +20,7 @@ describe('Interact with bottom toolbar.', function() {
 	});
 
 	function getTextPosForFirstCell() {
-		calcHelper.dblClickOnFirstCell();
+		calc.dblClickOnFirstCell();
 
 		// Select text content
 		cy.get('textarea.clipboard')
@@ -164,7 +165,7 @@ describe('Interact with bottom toolbar.', function() {
 			.should('have.attr', 'align', 'right');
 
 		// Change alignment back
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		cy.get('.w2ui-tb-image.w2ui-icon.alignleft')
 			.click();
@@ -211,7 +212,7 @@ describe('Interact with bottom toolbar.', function() {
 		cy.get('@currentTextPos')
 			.should('be.greaterThan', 0);
 
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		cy.get('.w2ui-tb-image.w2ui-icon.wraptext')
 			.click();
diff --git a/cypress_test/integration_tests/mobile/calc/calc_helper.js b/cypress_test/integration_tests/mobile/calc/calc_helper.js
index aaa517029..f6f1c6ae1 100644
--- a/cypress_test/integration_tests/mobile/calc/calc_helper.js
+++ b/cypress_test/integration_tests/mobile/calc/calc_helper.js
@@ -1,43 +1,4 @@
-/* global cy expect require Cypress*/
-
-var mobileHelper = require('../../common/mobile_helper');
-
-function clickOnFirstCell(firstClick = true, dblClick = false) {
-	cy.log('Clicking on first cell - start.');
-	cy.log('Param - firstClick: ' + firstClick);
-	cy.log('Param - dblClick: ' + dblClick);
-
-	// Enable editing if it's in read-only mode
-	mobileHelper.enableEditingMobile();
-
-	// Use the tile's edge to find the first cell's position
-	cy.get('.leaflet-tile-container')
-		.then(function(items) {
-			expect(items).to.have.lengthOf(1);
-			var XPos = items[0].getBoundingClientRect().right + 10;
-			var YPos = items[0].getBoundingClientRect().top + 10;
-			if (dblClick) {
-				cy.get('body')
-					.dblclick(XPos, YPos);
-			} else {
-				cy.get('body')
-					.click(XPos, YPos);
-			}
-		});
-
-	if (firstClick && !dblClick)
-		cy.get('.spreadsheet-cell-resize-marker')
-			.should('exist');
-	else
-		cy.get('.leaflet-cursor.blinking-cursor')
-			.should('exist');
-
-	cy.log('Clicking on first cell - end.');
-}
-
-function dblClickOnFirstCell() {
-	clickOnFirstCell(false, true);
-}
+/* global cy Cypress*/
 
 function removeTextSelection() {
 	cy.log('Removing text selection - start.');
@@ -83,5 +44,3 @@ function selectAllMobile(removeSelection = true) {
 
 module.exports.removeTextSelection = removeTextSelection;
 module.exports.selectAllMobile = selectAllMobile;
-module.exports.clickOnFirstCell = clickOnFirstCell;
-module.exports.dblClickOnFirstCell = dblClickOnFirstCell;
diff --git a/cypress_test/integration_tests/mobile/calc/cell_appearance_spec.js b/cypress_test/integration_tests/mobile/calc/cell_appearance_spec.js
index 80bf94ad1..c15157457 100644
--- a/cypress_test/integration_tests/mobile/calc/cell_appearance_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/cell_appearance_spec.js
@@ -1,6 +1,7 @@
 /* global describe it cy beforeEach require afterEach expect*/
 
 var helper = require('../../common/helper');
+var calc = require('../../common/calc');
 var mobileHelper = require('../../common/mobile_helper');
 var calcHelper = require('./calc_helper');
 
@@ -27,7 +28,7 @@ describe('Change cell appearance.', function() {
 	}
 
 	function openAppearencePanelOnFirtsCell() {
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		openAppearencePanel();
 	}
diff --git a/cypress_test/integration_tests/mobile/calc/focus_spec.js b/cypress_test/integration_tests/mobile/calc/focus_spec.js
index 7320bd331..1e63dd189 100644
--- a/cypress_test/integration_tests/mobile/calc/focus_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/focus_spec.js
@@ -3,7 +3,6 @@
 var helper = require('../../common/helper');
 var mobileHelper = require('../../common/mobile_helper');
 var calc = require('../../common/calc');
-var calcHelper = require('./calc_helper');
 
 describe('Calc focus tests', function() {
 	beforeEach(function() {
@@ -26,7 +25,7 @@ describe('Calc focus tests', function() {
 			.should('be.eq', 'BODY');
 
 		// One tap on an other cell -> no focus on the document
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		cy.get('.leaflet-marker-icon')
 			.should('be.visible');
@@ -59,7 +58,7 @@ describe('Calc focus tests', function() {
 			.should('be.eq', 'BODY');
 
 		// One tap on a cell -> no document focus
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		cy.get('.leaflet-marker-icon')
 			.should('be.visible');
@@ -69,7 +68,7 @@ describe('Calc focus tests', function() {
 			.should('be.eq', 'BODY');
 
 		// Second tap on the same cell
-		calcHelper.clickOnFirstCell(false);
+		calc.clickOnFirstCell(false);
 
 		// Document has the focus
 		cy.document().its('activeElement.className')
diff --git a/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js b/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js
index 59c2c41e0..b742d855d 100644
--- a/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js
@@ -1,6 +1,7 @@
 /* global describe it cy beforeEach require afterEach expect*/
 
 var helper = require('../../common/helper');
+var calc = require('../../common/calc');
 var mobileHelper = require('../../common/mobile_helper');
 var calcHelper = require('./calc_helper');
 
@@ -11,7 +12,7 @@ describe('Calc insertion wizard.', function() {
 		// Click on edit button
 		mobileHelper.enableEditingMobile();
 
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		cy.get('.leaflet-marker-icon')
 			.should('be.visible');
diff --git a/cypress_test/integration_tests/mobile/calc/number_format_spec.js b/cypress_test/integration_tests/mobile/calc/number_format_spec.js
index efd7576d7..6dadd5ba7 100644
--- a/cypress_test/integration_tests/mobile/calc/number_format_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/number_format_spec.js
@@ -1,6 +1,7 @@
 /* global describe it cy beforeEach require afterEach Cypress*/
 
 var helper = require('../../common/helper');
+var calc = require('../../common/calc');
 var mobileHelper = require('../../common/mobile_helper');
 var calcHelper = require('./calc_helper');
 
@@ -11,7 +12,7 @@ describe('Apply number formatting.', function() {
 		// Click on edit button
 		mobileHelper.enableEditingMobile();
 
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		cy.get('.leaflet-marker-icon')
 			.should('be.visible');
@@ -185,7 +186,7 @@ describe('Apply number formatting.', function() {
 		cy.get('#copy-paste-container table td')
 			.should('have.text', '$1,000.00');
 
-		calcHelper.clickOnFirstCell();
+		calc.clickOnFirstCell();
 
 		mobileHelper.openMobileWizard();
 
diff --git a/cypress_test/integration_tests/mobile/calc/spellchecking_spec.js b/cypress_test/integration_tests/mobile/calc/spellchecking_spec.js
index 155584a3a..91ea24987 100644
--- a/cypress_test/integration_tests/mobile/calc/spellchecking_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/spellchecking_spec.js
@@ -1,6 +1,7 @@
 /* global describe it cy beforeEach require afterEach expect*/
 
 var helper = require('../../common/helper');
+var calc = require('../../common/calc');
 var mobileHelper = require('../../common/mobile_helper');
 var calcHelper = require('./calc_helper');
 
@@ -9,8 +10,7 @@ describe('Calc spell checking menu.', function() {
 		mobileHelper.beforeAllMobile('spellchecking.ods', 'calc');
 
 		// Click on edit button
-		cy.get('#mobile-edit-button')
-			.click();
+		mobileHelper.enableEditingMobile();
 	});
 
 	afterEach(function() {
@@ -19,7 +19,7 @@ describe('Calc spell checking menu.', function() {
 
 	function openContextMenu() {
 		// Step into edit mode
-		calcHelper.dblClickOnFirstCell();
+		calc.dblClickOnFirstCell();
 
 		// Select text content
 		cy.get('textarea.clipboard')
@@ -43,7 +43,7 @@ describe('Calc spell checking menu.', function() {
 				calcHelper.removeTextSelection();
 
 				// Step into edit mode again
-				calcHelper.dblClickOnFirstCell();
+				calc.dblClickOnFirstCell();
 
 				mobileHelper.longPressOnDocument(XPos, YPos);
 			});


More information about the Libreoffice-commits mailing list