mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-19 18:54:07 +00:00
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:
parent
bfa834e840
commit
8418802c7e
@ -193,58 +193,60 @@ function checkFilter(filterDetails) {
|
|||||||
const entriesForDeeperCheck = 5;
|
const entriesForDeeperCheck = 5;
|
||||||
|
|
||||||
it(`checking the filter: ${filter}`, function () {
|
it(`checking the filter: ${filter}`, function () {
|
||||||
waitForFetch50AndPause();
|
waitForFetch();
|
||||||
|
|
||||||
cy.get('#total-entries').should('not.have.text', '0').then(number => {
|
cy.get(`#list [id^=entry]`).last().then(elem => {
|
||||||
const totalEntries = number.text();
|
const element = elem[0];
|
||||||
|
const entryId = getEntryId(element.id);
|
||||||
|
// checks the hover on the last entry (the only one in DOM at the beginning)
|
||||||
|
leftOnHoverCheck(entryId, leftSidePath, filter);
|
||||||
|
|
||||||
cy.get(`#list [id^=entry]`).last().then(elem => {
|
cy.get('.w-tc-editor-text').clear();
|
||||||
const element = elem[0];
|
// applying the filter with alt+enter or with the button
|
||||||
const entryId = getEntryId(element.id);
|
cy.get('.w-tc-editor-text').type(`${filter}${applyByCtrlEnter ? '{ctrl+enter}' : ''}`);
|
||||||
// checks the hover on the last entry (the only one in DOM at the beginning)
|
cy.get('.w-tc-editor').should('have.attr', 'style').and('include', Cypress.env('greenFilterColor'));
|
||||||
leftOnHoverCheck(entryId, leftSidePath, filter);
|
if (!applyByCtrlEnter)
|
||||||
|
cy.get('[type="submit"]').click();
|
||||||
|
|
||||||
cy.get('.w-tc-editor-text').clear();
|
waitForFetch();
|
||||||
// applying the filter with alt+enter or with the button
|
pauseStream();
|
||||||
cy.get('.w-tc-editor-text').type(`${filter}${applyByCtrlEnter ? '{ctrl+enter}' : ''}`);
|
|
||||||
cy.get('.w-tc-editor').should('have.attr', 'style').and('include', Cypress.env('greenFilterColor'));
|
|
||||||
if (!applyByCtrlEnter)
|
|
||||||
cy.get('[type="submit"]').click();
|
|
||||||
|
|
||||||
waitForFetch50AndPause();
|
// only one entry in DOM after filtering, checking all checks on it
|
||||||
|
leftTextCheck(entryId, leftSidePath, leftSideExpectedText);
|
||||||
|
leftOnHoverCheck(entryId, leftSidePath, filter);
|
||||||
|
|
||||||
// only one entry in DOM after filtering, checking all checks on it
|
rightTextCheck(rightSidePath, rightSideExpectedText);
|
||||||
leftTextCheck(entryId, leftSidePath, leftSideExpectedText);
|
rightOnHoverCheck(rightSidePath, filter);
|
||||||
leftOnHoverCheck(entryId, leftSidePath, filter);
|
checkRightSideResponseBody();
|
||||||
|
});
|
||||||
|
|
||||||
rightTextCheck(rightSidePath, rightSideExpectedText);
|
resizeToHugeMizu();
|
||||||
rightOnHoverCheck(rightSidePath, filter);
|
|
||||||
checkRightSideResponseBody();
|
|
||||||
});
|
|
||||||
|
|
||||||
resizeToHugeMizu();
|
// checking only 'leftTextCheck' on all entries because the rest of the checks require more time
|
||||||
|
cy.get(`#list [id^=entry]`).each(elem => {
|
||||||
|
const element = elem[0];
|
||||||
|
let entryId = getEntryId(element.id);
|
||||||
|
leftTextCheck(entryId, leftSidePath, leftSideExpectedText);
|
||||||
|
});
|
||||||
|
|
||||||
// checking only 'leftTextCheck' on all entries because the rest of the checks require more time
|
// making the other 3 checks on the first X entries (longer time for each check)
|
||||||
cy.get(`#list [id^=entry]`).each(elem => {
|
deeperCheck(leftSidePath, rightSidePath, filter, rightSideExpectedText, entriesForDeeperCheck);
|
||||||
const element = elem[0];
|
|
||||||
let entryId = getEntryId(element.id);
|
|
||||||
leftTextCheck(entryId, leftSidePath, leftSideExpectedText);
|
|
||||||
});
|
|
||||||
|
|
||||||
// making the other 3 checks on the first X entries (longer time for each check)
|
// reloading then waiting for the entries number to load
|
||||||
deeperCheck(leftSidePath, rightSidePath, filter, rightSideExpectedText, entriesForDeeperCheck);
|
resizeToNormalMizu();
|
||||||
|
cy.reload();
|
||||||
// reloading then waiting for the entries number to load
|
waitForFetch();
|
||||||
resizeToNormalMizu();
|
pauseStream();
|
||||||
cy.reload();
|
|
||||||
cy.get('#total-entries', {timeout: refreshWaitTimeout}).should('have.text', totalEntries);
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForFetch50AndPause() {
|
function waitForFetch() {
|
||||||
// wait half a second and pause the stream to preserve the DOM
|
cy.get('#entries-length', {timeout: refreshWaitTimeout}).should((el) => {
|
||||||
cy.wait(500);
|
expect(parseInt(el.text().trim(), 10)).to.be.greaterThan(20);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function pauseStream() {
|
||||||
cy.get('#pause-icon').click();
|
cy.get('#pause-icon').click();
|
||||||
cy.get('#pause-icon').should('not.be.visible');
|
cy.get('#pause-icon').should('not.be.visible');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user