[Libreoffice-commits] online.git: cypress_test/.gitignore cypress_test/integration_tests cypress_test/package.json cypress_test/support

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 2 11:50:24 UTC 2020


 cypress_test/.gitignore                                            |    1 
 cypress_test/integration_tests/mobile/writer/insert_object_spec.js |   92 +++++-----
 cypress_test/package.json                                          |    1 
 cypress_test/support/commands.js                                   |    1 
 cypress_test/support/index.js                                      |    1 
 5 files changed, 49 insertions(+), 47 deletions(-)

New commits:
commit e814adfb2876748b06e3d21145aa4d18db52ed0d
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Apr 2 11:35:07 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Thu Apr 2 13:50:06 2020 +0200

    cypress: integrate cypress-wait-until package.
    
    There are cases sometimes, where we can't use cypress'
    nice retry feature for waiting to an assumption to
    be true. A workaround for this issue is the cypress-wait-until
    package, which makes us able to use the retry feature for
    any use case.
    An example is the position of an element. I don't know
    a way to wait on the position to get changed in the cypress
    test framework. So we can use cy.waitUntil() here instead.
    
    Please use this new package when it's really necessary,
    do not replace the better cypress calls with it.
    
    Change-Id: I8c553456e351664e30043b8ccd5ace51f1c0298d
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91554
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/cypress_test/.gitignore b/cypress_test/.gitignore
index 0b6b5b539..3e5e8dbd2 100644
--- a/cypress_test/.gitignore
+++ b/cypress_test/.gitignore
@@ -2,4 +2,3 @@ node_modules
 cypress
 package-lock.json
 workdir
-support/commands.js
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 7a01c8824..64794d649 100644
--- a/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
@@ -171,14 +171,14 @@ describe('Insert objects via insertion wizard.', function() {
 			.contains('All')
 			.click();
 
-		cy.wait(100);
-
 		// Check that the cursor was moved
-		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1);
-				expect(cursor[0].getBoundingClientRect().left).to.be.lessThan(cursorOrigLeft);
-			});
+		cy.waitUntil(function() {
+			return cy.get('.blinking-cursor')
+				.then(function(cursor) {
+					expect(cursor).to.have.lengthOf(1);
+					return cursor[0].getBoundingClientRect().left < cursorOrigLeft;
+				});
+		});
 	});
 
 	it('Insert footer.', function() {
@@ -214,14 +214,14 @@ describe('Insert objects via insertion wizard.', function() {
 			.contains('All')
 			.click();
 
-		cy.wait(100);
-
 		// Check that the cursor was moved
-		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1);
-				expect(cursor[0].getBoundingClientRect().top).to.be.greaterThan(cursorOrigTop);
-			});
+		cy.waitUntil(function() {
+			return cy.get('.blinking-cursor')
+				.then(function(cursor) {
+					expect(cursor).to.have.lengthOf(1);
+					return cursor[0].getBoundingClientRect().top > cursorOrigTop;
+				});
+		});
 	});
 
 	it('Insert footnote.', function() {
@@ -245,14 +245,14 @@ describe('Insert objects via insertion wizard.', function() {
 			.contains('Footnote')
 			.click();
 
-		cy.wait(100);
-
-		// Check that the cursor was moved down
-		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1);
-				expect(cursor[0].getBoundingClientRect().top).to.be.greaterThan(cursorOrigTop);
-			});
+		// 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;
+				});
+		});
 	});
 
 	it('Insert endnote.', function() {
@@ -276,14 +276,14 @@ describe('Insert objects via insertion wizard.', function() {
 			.contains('Endnote')
 			.click();
 
-		cy.wait(100);
-
-		// Check that the cursor was moved down
-		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1);
-				expect(cursor[0].getBoundingClientRect().top).to.be.greaterThan(cursorOrigTop);
-			});
+		// 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;
+				});
+		});
 	});
 
 	it('Insert page break.', function() {
@@ -307,14 +307,14 @@ describe('Insert objects via insertion wizard.', function() {
 			.contains('Page Break')
 			.click();
 
-		cy.wait(100);
-
-		// Check that the cursor was moved down
-		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1);
-				expect(cursor[0].getBoundingClientRect().top).to.be.greaterThan(cursorOrigTop);
-			});
+		// 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;
+				});
+		});
 	});
 
 	it('Insert column break.', function() {
@@ -338,14 +338,14 @@ describe('Insert objects via insertion wizard.', function() {
 			.contains('Column Break')
 			.click();
 
-		cy.wait(100);
-
-		// Check that the cursor was moved down
-		cy.get('.blinking-cursor')
-			.then(function(cursor) {
-				expect(cursor).to.have.lengthOf(1);
-				expect(cursor[0].getBoundingClientRect().top).to.be.greaterThan(cursorOrigTop);
-			});
+		// 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;
+				});
+		});
 	});
 
 	it('Insert hyperlink.', function() {
diff --git a/cypress_test/package.json b/cypress_test/package.json
index cfdad5618..a49df3820 100644
--- a/cypress_test/package.json
+++ b/cypress_test/package.json
@@ -6,6 +6,7 @@
   "dependencies": {
     "cypress": "4.3.0",
     "cypress-failed-log": "2.6.2",
+    "cypress-wait-until": "1.6.1",
     "eslint": "6.8.0",
     "get-port-cli": "2.0.0",
     "wait-on": "4.0.0"
diff --git a/cypress_test/support/commands.js b/cypress_test/support/commands.js
new file mode 100644
index 000000000..5c6c3cd80
--- /dev/null
+++ b/cypress_test/support/commands.js
@@ -0,0 +1 @@
+import 'cypress-wait-until';
diff --git a/cypress_test/support/index.js b/cypress_test/support/index.js
index 8f683db34..2a2b1f1d5 100644
--- a/cypress_test/support/index.js
+++ b/cypress_test/support/index.js
@@ -1,3 +1,4 @@
 /* global require */
 
 require('cypress-failed-log');
+require('./commands');


More information about the Libreoffice-commits mailing list