Handle the wait for fetch in acceptance tests better (#1088)

* Handle the wait for fetch in acceptance tests better

* #run_acceptance_tests

* Fix the error #run_acceptance_tests

* Fix `waitForFetchAndPause` and `checkFilter` #run_acceptance_tests

* Fix the tests #run_acceptance_tests
This commit is contained in:
M. Mert Yıldıran 2022-05-17 01:01:47 -07:00 committed by GitHub
parent bfa834e840
commit 8418802c7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -193,10 +193,7 @@ function checkFilter(filterDetails) {
const entriesForDeeperCheck = 5;
it(`checking the filter: ${filter}`, function () {
waitForFetch50AndPause();
cy.get('#total-entries').should('not.have.text', '0').then(number => {
const totalEntries = number.text();
waitForFetch();
cy.get(`#list [id^=entry]`).last().then(elem => {
const element = elem[0];
@ -211,7 +208,8 @@ function checkFilter(filterDetails) {
if (!applyByCtrlEnter)
cy.get('[type="submit"]').click();
waitForFetch50AndPause();
waitForFetch();
pauseStream();
// only one entry in DOM after filtering, checking all checks on it
leftTextCheck(entryId, leftSidePath, leftSideExpectedText);
@ -237,14 +235,18 @@ function checkFilter(filterDetails) {
// reloading then waiting for the entries number to load
resizeToNormalMizu();
cy.reload();
cy.get('#total-entries', {timeout: refreshWaitTimeout}).should('have.text', totalEntries);
})
waitForFetch();
pauseStream();
});
}
function waitForFetch50AndPause() {
// wait half a second and pause the stream to preserve the DOM
cy.wait(500);
function waitForFetch() {
cy.get('#entries-length', {timeout: refreshWaitTimeout}).should((el) => {
expect(parseInt(el.text().trim(), 10)).to.be.greaterThan(20);
});
}
function pauseStream() {
cy.get('#pause-icon').click();
cy.get('#pause-icon').should('not.be.visible');
}