[Libreoffice-commits] online.git: cypress_test/integration_tests
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 15 13:48:46 UTC 2020
cypress_test/integration_tests/common/helper.js | 31 +++++++++++++-----------
1 file changed, 17 insertions(+), 14 deletions(-)
New commits:
commit 3cefcd26654ccf7a24b5d5983ee842faa9b79b26
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Tue Jul 14 15:25:19 2020 +0200
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jul 15 15:48:26 2020 +0200
cypress: improve waitUntilIdle() method.
Use smaller time intervals to check how long the item is
idle. Use a smaller (e.g. 1000) time for making a decision
about the item's idle state to make tests faster.
We can increase this time for those use cases where this
time is not enough.
Change-Id: Ibf03197c7bccc3cd718b67b73d52d9b9b54e875e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98733
Tested-by: Jenkins
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/helper.js b/cypress_test/integration_tests/common/helper.js
index 1578b70d6..c31ebd64a 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -298,11 +298,12 @@ function imageShouldBeFullWhiteOrNot(selector, fullWhite = true) {
});
}
-function waitUntilIdle(selector, content) {
+function waitUntilIdle(selector, content, waitingTime = 1000) {
cy.log('Waiting item to be idle - start.');
var item;
- var waitingTime = 2000;
+ var waitOnce = 250;
+ var idleSince = 0;
if (content) {
cy.contains(selector, content, { log: false })
.then(function(itemToIdle) {
@@ -310,17 +311,18 @@ function waitUntilIdle(selector, content) {
});
cy.waitUntil(function() {
- cy.wait(waitingTime);
+ cy.wait(waitOnce, { log: false });
return cy.contains(selector, content, { log: false })
.then(function(itemToIdle) {
if (Cypress.dom.isDetached(item[0])) {
- cy.log('Item is detached.');
+ cy.log('Item is detached after ' + (idleSince + waitOnce).toString() + ' ms.');
item = itemToIdle;
- return false;
+ idleSince = 0;
} else {
- return true;
+ idleSince += waitOnce;
}
+ return idleSince > waitingTime;
});
});
} else {
@@ -330,17 +332,18 @@ function waitUntilIdle(selector, content) {
});
cy.waitUntil(function() {
- cy.wait(waitingTime);
+ cy.wait(waitOnce, { log: false });
return cy.get(selector, { log: false })
.then(function(itemToIdle) {
if (Cypress.dom.isDetached(item[0])) {
- cy.log('Item is detached.');
+ cy.log('Item is detached after ' + (idleSince + waitOnce).toString() + ' ms.');
item = itemToIdle;
- return false;
+ idleSince = 0;
} else {
- return true;
+ idleSince += waitOnce;
}
+ return idleSince > waitingTime;
});
});
}
@@ -357,10 +360,10 @@ function waitUntilIdle(selector, content) {
// IMPORTANT: don't use this if there is no
// flickering. Use simple click() instead. This method
// is much slower.
-function clickOnIdle(selector, content) {
+function clickOnIdle(selector, content, waitingTime = 1000) {
cy.log('Clicking on item when idle - start.');
- waitUntilIdle(selector, content);
+ waitUntilIdle(selector, content, waitingTime);
if (content) {
cy.contains(selector, content)
.click();
@@ -373,10 +376,10 @@ function clickOnIdle(selector, content) {
}
// See comments at clickOnIdle() method.
-function inputOnIdle(selector, input) {
+function inputOnIdle(selector, input, waitingTime = 1000) {
cy.log('Type into an input item when idle - start.');
- waitUntilIdle(selector);
+ waitUntilIdle(selector, undefined, waitingTime);
cy.get(selector)
.clear()
More information about the Libreoffice-commits
mailing list