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

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 16 11:45:03 UTC 2020


 cypress_test/integration_tests/mobile/writer/insert_object_spec.js |  155 ++++------
 1 file changed, 75 insertions(+), 80 deletions(-)

New commits:
commit cc107fa903a3f195554bee681844689eae1552fa
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Apr 16 13:23:40 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Thu Apr 16 13:44:45 2020 +0200

    cypress: mobile: kill waitUntil() in object insertion test.
    
    We can store the original position in a 'variable' and
    we can use that variable to assert on.
    
    Change-Id: I026c1f3adc445b94d7d7720608ca36a373678352
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92350
    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/writer/insert_object_spec.js b/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
index c7791307e..ac8213030 100644
--- a/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
@@ -1,7 +1,5 @@
 /* global describe it cy beforeEach require expect afterEach Cypress*/
 
-import 'cypress-wait-until';
-
 var helper = require('../../common/helper');
 var mobileHelper = require('../../common/mobile_helper');
 var writerHelper = require('./writer_helper');
@@ -126,12 +124,10 @@ describe('Insert objects via insertion wizard.', function() {
 		// Get the blinking cursor pos
 		cy.get('#document-container').type('xxxx');
 
-		var cursorOrigLeft = 0;
 		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1) ;
-				cursorOrigLeft = cursor[0].getBoundingClientRect().left;
-			});
+			.invoke('offset')
+			.its('left')
+			.as('cursorOrigLeft');
 
 		mobileHelper.openInsertionWizard();
 
@@ -149,25 +145,24 @@ describe('Insert objects via insertion wizard.', function() {
 		cy.contains('.menu-entry-no-icon', 'All')
 			.click();
 
-		// Check that the cursor was moved
-		cy.waitUntil(function() {
-			return cy.get('.blinking-cursor')
-				.then(function(cursor) {
-					expect(cursor).to.have.lengthOf(1);
-					return cursor[0].getBoundingClientRect().left < cursorOrigLeft;
-				});
-		});
+		cy.get('@cursorOrigLeft')
+			.then(function(cursorOrigLeft) {
+				cy.get('.blinking-cursor')
+					.invoke('offset')
+					.its('left')
+					.should('be.lessThan', cursorOrigLeft);
+			});
 	});
 
 	it('Insert footer.', function() {
 		// Get the blinking cursor pos
-		cy.get('#document-container').type('xxxx');
-		var cursorOrigTop = 0;
+		cy.get('#document-container')
+			.type('xxxx');
+
 		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1) ;
-				cursorOrigTop = cursor[0].getBoundingClientRect().top;
-			});
+			.invoke('offset')
+			.its('top')
+			.as('cursorOrigTop');
 
 		mobileHelper.openInsertionWizard();
 
@@ -186,24 +181,24 @@ describe('Insert objects via insertion wizard.', function() {
 			.click();
 
 		// Check that the cursor was moved
-		cy.waitUntil(function() {
-			return cy.get('.blinking-cursor')
-				.then(function(cursor) {
-					expect(cursor).to.have.lengthOf(1);
-					return cursor[0].getBoundingClientRect().top > cursorOrigTop;
-				});
-		});
+		cy.get('@cursorOrigTop')
+			.then(function(cursorOrigTop) {
+				cy.get('.blinking-cursor')
+					.invoke('offset')
+					.its('top')
+					.should('be.greaterThan', cursorOrigTop);
+			});
 	});
 
 	it('Insert footnote.', function() {
 		// Get the blinking cursor pos
-		cy.get('#document-container').type('xxxx');
-		var cursorOrigTop = 0;
+		cy.get('#document-container')
+			.type('xxxx');
+
 		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1);
-				cursorOrigTop = cursor[0].getBoundingClientRect().top;
-			});
+			.invoke('offset')
+			.its('top')
+			.as('cursorOrigTop');
 
 		mobileHelper.openInsertionWizard();
 
@@ -212,24 +207,24 @@ describe('Insert objects via insertion wizard.', function() {
 			.click();
 
 		// Check that the cursor was moved
-		cy.waitUntil(function() {
-			return cy.get('.blinking-cursor')
-				.then(function(cursor) {
-					expect(cursor).to.have.lengthOf(1);
-					return cursor[0].getBoundingClientRect().top > cursorOrigTop;
-				});
-		});
+		cy.get('@cursorOrigTop')
+			.then(function(cursorOrigTop) {
+				cy.get('.blinking-cursor')
+					.invoke('offset')
+					.its('top')
+					.should('be.greaterThan', cursorOrigTop);
+			});
 	});
 
 	it('Insert endnote.', function() {
 		// Get the blinking cursor pos
-		cy.get('#document-container').type('xxxx');
-		var cursorOrigTop = 0;
+		cy.get('#document-container')
+			.type('xxxx');
+
 		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1);
-				cursorOrigTop = cursor[0].getBoundingClientRect().top;
-			});
+			.invoke('offset')
+			.its('top')
+			.as('cursorOrigTop');
 
 		mobileHelper.openInsertionWizard();
 
@@ -238,24 +233,24 @@ describe('Insert objects via insertion wizard.', function() {
 			.click();
 
 		// Check that the cursor was moved
-		cy.waitUntil(function() {
-			return cy.get('.blinking-cursor')
-				.then(function(cursor) {
-					expect(cursor).to.have.lengthOf(1);
-					return cursor[0].getBoundingClientRect().top > cursorOrigTop;
-				});
-		});
+		cy.get('@cursorOrigTop')
+			.then(function(cursorOrigTop) {
+				cy.get('.blinking-cursor')
+					.invoke('offset')
+					.its('top')
+					.should('be.greaterThan', cursorOrigTop);
+			});
 	});
 
 	it('Insert page break.', function() {
 		// Get the blinking cursor pos
-		cy.get('#document-container').type('xxxx');
-		var cursorOrigTop = 0;
+		cy.get('#document-container')
+			.type('xxxx');
+
 		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1);
-				cursorOrigTop = cursor[0].getBoundingClientRect().top;
-			});
+			.invoke('offset')
+			.its('top')
+			.as('cursorOrigTop');
 
 		mobileHelper.openInsertionWizard();
 
@@ -264,24 +259,24 @@ describe('Insert objects via insertion wizard.', function() {
 			.click();
 
 		// Check that the cursor was moved
-		cy.waitUntil(function() {
-			return cy.get('.blinking-cursor')
-				.then(function(cursor) {
-					expect(cursor).to.have.lengthOf(1);
-					return cursor[0].getBoundingClientRect().top > cursorOrigTop;
-				});
-		});
+		cy.get('@cursorOrigTop')
+			.then(function(cursorOrigTop) {
+				cy.get('.blinking-cursor')
+					.invoke('offset')
+					.its('top')
+					.should('be.greaterThan', cursorOrigTop);
+			});
 	});
 
 	it('Insert column break.', function() {
 		// Get the blinking cursor pos
-		cy.get('#document-container').type('xxxx');
-		var cursorOrigTop = 0;
+		cy.get('#document-container')
+			.type('xxxx');
+
 		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1);
-				cursorOrigTop = cursor[0].getBoundingClientRect().top;
-			});
+			.invoke('offset')
+			.its('top')
+			.as('cursorOrigTop');
 
 		mobileHelper.openInsertionWizard();
 
@@ -290,13 +285,13 @@ describe('Insert objects via insertion wizard.', function() {
 			.click();
 
 		// Check that the cursor was moved
-		cy.waitUntil(function() {
-			return cy.get('.blinking-cursor')
-				.then(function(cursor) {
-					expect(cursor).to.have.lengthOf(1);
-					return cursor[0].getBoundingClientRect().top > cursorOrigTop;
-				});
-		});
+		cy.get('@cursorOrigTop')
+			.then(function(cursorOrigTop) {
+				cy.get('.blinking-cursor')
+					.invoke('offset')
+					.its('top')
+					.should('be.greaterThan', cursorOrigTop);
+			});
 	});
 
 	it('Insert hyperlink.', function() {


More information about the Libreoffice-commits mailing list