mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-11 13:23:03 +00:00
Fix acceptance tests entry id is string and not number (#1000)
This commit is contained in:
parent
32d473ea26
commit
8f3b0e8fee
@ -39,13 +39,13 @@ export function verifyMinimumEntries() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function leftTextCheck(entryNum, path, expectedText) {
|
export function leftTextCheck(entryId, path, expectedText) {
|
||||||
cy.get(`#list #entry-${entryNum} ${path}`).invoke('text').should('eq', expectedText);
|
cy.get(`#list #entry-${entryId} ${path}`).invoke('text').should('eq', expectedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function leftOnHoverCheck(entryNum, path, filterName) {
|
export function leftOnHoverCheck(entryId, path, filterName) {
|
||||||
cy.get(`#list #entry-${entryNum} ${path}`).trigger('mouseover');
|
cy.get(`#list #entry-${entryId} ${path}`).trigger('mouseover');
|
||||||
cy.get(`#list #entry-${entryNum} [data-cy='QueryableTooltip']`).invoke('text').should('match', new RegExp(filterName));
|
cy.get(`#list #entry-${entryId} [data-cy='QueryableTooltip']`).invoke('text').should('match', new RegExp(filterName));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rightTextCheck(path, expectedText) {
|
export function rightTextCheck(path, expectedText) {
|
||||||
@ -89,13 +89,13 @@ export function checkFilterByMethod(funcDict) {
|
|||||||
cy.get('#entries-length').invoke('text').then(len => {
|
cy.get('#entries-length').invoke('text').then(len => {
|
||||||
resizeIfNeeded(len);
|
resizeIfNeeded(len);
|
||||||
listElmWithIdAttr.forEach(entry => {
|
listElmWithIdAttr.forEach(entry => {
|
||||||
if (entry?.id && entry.id.match(RegExp(/entry-(\d{2}|\d{1})$/gm))) {
|
if (entry?.id && entry.id.match(RegExp(/entry-(\d{24})$/gm))) {
|
||||||
const entryNum = getEntryNumById(entry.id);
|
const entryId = getEntryId(entry.id);
|
||||||
|
|
||||||
leftTextCheck(entryNum, methodDict.pathLeft, methodDict.expectedText);
|
leftTextCheck(entryId, methodDict.pathLeft, methodDict.expectedText);
|
||||||
leftTextCheck(entryNum, protocolDict.pathLeft, protocolDict.expectedTextLeft);
|
leftTextCheck(entryId, protocolDict.pathLeft, protocolDict.expectedTextLeft);
|
||||||
if (summaryDict)
|
if (summaryDict)
|
||||||
leftTextCheck(entryNum, summaryDict.pathLeft, summaryDict.expectedText);
|
leftTextCheck(entryId, summaryDict.pathLeft, summaryDict.expectedText);
|
||||||
|
|
||||||
if (!doneCheckOnFirst) {
|
if (!doneCheckOnFirst) {
|
||||||
deepCheck(funcDict, protocolDict, methodDict, entry);
|
deepCheck(funcDict, protocolDict, methodDict, entry);
|
||||||
@ -111,6 +111,11 @@ export function checkFilterByMethod(funcDict) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getEntryId(id) {
|
||||||
|
// take the second part from the string (entry-<ID>)
|
||||||
|
return id.split('-')[1];
|
||||||
|
}
|
||||||
|
|
||||||
function resizeIfNeeded(entriesLen) {
|
function resizeIfNeeded(entriesLen) {
|
||||||
if (entriesLen > maxEntriesInDom){
|
if (entriesLen > maxEntriesInDom){
|
||||||
Cypress.config().viewportHeight === Cypress.env('normalMizuHeight') ?
|
Cypress.config().viewportHeight === Cypress.env('normalMizuHeight') ?
|
||||||
@ -119,14 +124,14 @@ function resizeIfNeeded(entriesLen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deepCheck(generalDict, protocolDict, methodDict, entry) {
|
function deepCheck(generalDict, protocolDict, methodDict, entry) {
|
||||||
const entryNum = getEntryNumById(entry.id);
|
const entryId = getEntryId(entry.id);
|
||||||
const {summary, value} = generalDict;
|
const {summary, value} = generalDict;
|
||||||
const summaryDict = getSummaryDict(summary);
|
const summaryDict = getSummaryDict(summary);
|
||||||
|
|
||||||
leftOnHoverCheck(entryNum, methodDict.pathLeft, methodDict.expectedOnHover);
|
leftOnHoverCheck(entryId, methodDict.pathLeft, methodDict.expectedOnHover);
|
||||||
leftOnHoverCheck(entryNum, protocolDict.pathLeft, protocolDict.expectedOnHover);
|
leftOnHoverCheck(entryId, protocolDict.pathLeft, protocolDict.expectedOnHover);
|
||||||
if (summaryDict)
|
if (summaryDict)
|
||||||
leftOnHoverCheck(entryNum, summaryDict.pathLeft, summaryDict.expectedOnHover);
|
leftOnHoverCheck(entryId, summaryDict.pathLeft, summaryDict.expectedOnHover);
|
||||||
|
|
||||||
cy.get(`#${entry.id}`).click();
|
cy.get(`#${entry.id}`).click();
|
||||||
|
|
||||||
@ -183,7 +188,3 @@ function getProtocolDict(protocol, protocolText) {
|
|||||||
expectedOnHover: protocol.toLowerCase()
|
expectedOnHover: protocol.toLowerCase()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEntryNumById (id) {
|
|
||||||
return parseInt(id.split('-')[1]);
|
|
||||||
}
|
|
||||||
|
@ -15,15 +15,11 @@ function checkEntries() {
|
|||||||
checkThatAllEntriesShown();
|
checkThatAllEntriesShown();
|
||||||
resizeToHugeMizu();
|
resizeToHugeMizu();
|
||||||
|
|
||||||
cy.get('#total-entries').then(number => {
|
cy.get('#list [id^=entry]').each(entryElement => {
|
||||||
const numOfEntries = parseInt(number.text());
|
entryElement.click();
|
||||||
[...Array(numOfEntries).keys()].map(checkEntry);
|
cy.get('#tbody-Headers').should('be.visible');
|
||||||
|
isValueExistsInElement(false, 'Ignored-User-Agent', '#tbody-Headers');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkEntry(entryIndex) {
|
|
||||||
cy.get(`#entry-${entryIndex}`).click();
|
|
||||||
cy.get('#tbody-Headers').should('be.visible');
|
|
||||||
isValueExistsInElement(false, 'Ignored-User-Agent', '#tbody-Headers');
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import {findLineAndCheck, getExpectedDetailsDict} from "../testHelpers/StatusBarHelper";
|
import {findLineAndCheck, getExpectedDetailsDict} from "../testHelpers/StatusBarHelper";
|
||||||
import {
|
import {
|
||||||
|
getEntryId,
|
||||||
leftOnHoverCheck,
|
leftOnHoverCheck,
|
||||||
leftTextCheck,
|
leftTextCheck,
|
||||||
resizeToHugeMizu,
|
resizeToHugeMizu,
|
||||||
@ -148,9 +149,6 @@ function checkFilterNoResults(filterName) {
|
|||||||
// the DOM should show 0 entries
|
// the DOM should show 0 entries
|
||||||
cy.get('#entries-length').should('have.text', '0');
|
cy.get('#entries-length').should('have.text', '0');
|
||||||
|
|
||||||
// going through every potential entry and verifies that it doesn't exist
|
|
||||||
[...Array(parseInt(totalEntries)).keys()].map(shouldNotExist);
|
|
||||||
|
|
||||||
cy.get('[title="Fetch old records"]').click();
|
cy.get('[title="Fetch old records"]').click();
|
||||||
cy.get('#noMoreDataTop', {timeout: refreshWaitTimeout}).should('be.visible');
|
cy.get('#noMoreDataTop', {timeout: refreshWaitTimeout}).should('be.visible');
|
||||||
cy.get('#entries-length').should('have.text', '0'); // after loading all entries there should still be 0 entries
|
cy.get('#entries-length').should('have.text', '0'); // after loading all entries there should still be 0 entries
|
||||||
@ -162,10 +160,6 @@ function checkFilterNoResults(filterName) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldNotExist(entryNum) {
|
|
||||||
cy.get(`entry-${entryNum}`).should('not.exist');
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkIllegalFilter(illegalFilterName) {
|
function checkIllegalFilter(illegalFilterName) {
|
||||||
it(`should show red search bar with the input: ${illegalFilterName}`, function () {
|
it(`should show red search bar with the input: ${illegalFilterName}`, function () {
|
||||||
cy.reload();
|
cy.reload();
|
||||||
@ -185,16 +179,28 @@ function checkIllegalFilter(illegalFilterName) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function checkFilter(filterDetails){
|
|
||||||
const {name, leftSidePath, rightSidePath, rightSideExpectedText, leftSideExpectedText, applyByEnter} = filterDetails;
|
function checkFilter(filterDetails) {
|
||||||
|
const {
|
||||||
|
name,
|
||||||
|
leftSidePath,
|
||||||
|
rightSidePath,
|
||||||
|
rightSideExpectedText,
|
||||||
|
leftSideExpectedText,
|
||||||
|
applyByEnter
|
||||||
|
} = filterDetails;
|
||||||
|
|
||||||
const entriesForDeeperCheck = 5;
|
const entriesForDeeperCheck = 5;
|
||||||
|
|
||||||
it(`checking the filter: ${name}`, function () {
|
it(`checking the filter: ${name}`, function () {
|
||||||
cy.get('#total-entries').should('not.have.text', '0').then(number => {
|
cy.get('#total-entries').should('not.have.text', '0').then(number => {
|
||||||
const totalEntries = number.text();
|
const totalEntries = number.text();
|
||||||
|
|
||||||
|
cy.get(`#list [id^=entry]`).last().then(elem => {
|
||||||
|
const element = elem[0];
|
||||||
|
const entryId = getEntryId(element.id);
|
||||||
// checks the hover on the last entry (the only one in DOM at the beginning)
|
// checks the hover on the last entry (the only one in DOM at the beginning)
|
||||||
leftOnHoverCheck(totalEntries - 1, leftSidePath, name);
|
leftOnHoverCheck(entryId, leftSidePath, name);
|
||||||
|
|
||||||
cy.get('.w-tc-editor-text').clear();
|
cy.get('.w-tc-editor-text').clear();
|
||||||
// applying the filter with alt+enter or with the button
|
// applying the filter with alt+enter or with the button
|
||||||
@ -204,11 +210,13 @@ function checkFilter(filterDetails){
|
|||||||
cy.get('[type="submit"]').click();
|
cy.get('[type="submit"]').click();
|
||||||
|
|
||||||
// only one entry in DOM after filtering, checking all checks on it
|
// only one entry in DOM after filtering, checking all checks on it
|
||||||
leftTextCheck(totalEntries - 1, leftSidePath, leftSideExpectedText);
|
leftTextCheck(entryId, leftSidePath, leftSideExpectedText);
|
||||||
leftOnHoverCheck(totalEntries - 1, leftSidePath, name);
|
leftOnHoverCheck(entryId, leftSidePath, name);
|
||||||
|
|
||||||
rightTextCheck(rightSidePath, rightSideExpectedText);
|
rightTextCheck(rightSidePath, rightSideExpectedText);
|
||||||
rightOnHoverCheck(rightSidePath, name);
|
rightOnHoverCheck(rightSidePath, name);
|
||||||
checkRightSideResponseBody();
|
checkRightSideResponseBody();
|
||||||
|
});
|
||||||
|
|
||||||
cy.get('[title="Fetch old records"]').click();
|
cy.get('[title="Fetch old records"]').click();
|
||||||
resizeToHugeMizu();
|
resizeToHugeMizu();
|
||||||
@ -217,28 +225,33 @@ function checkFilter(filterDetails){
|
|||||||
cy.get('#entries-length', {timeout: refreshWaitTimeout}).should('have.text', totalEntries);
|
cy.get('#entries-length', {timeout: refreshWaitTimeout}).should('have.text', totalEntries);
|
||||||
|
|
||||||
// checking only 'leftTextCheck' on all entries because the rest of the checks require more time
|
// checking only 'leftTextCheck' on all entries because the rest of the checks require more time
|
||||||
[...Array(parseInt(totalEntries)).keys()].forEach(entryNum => {
|
cy.get(`#list [id^=entry]`).each(elem => {
|
||||||
leftTextCheck(entryNum, leftSidePath, leftSideExpectedText);
|
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)
|
// making the other 3 checks on the first X entries (longer time for each check)
|
||||||
deeperChcek(leftSidePath, rightSidePath, name, leftSideExpectedText, rightSideExpectedText, entriesForDeeperCheck);
|
deeperCheck(leftSidePath, rightSidePath, name, leftSideExpectedText, rightSideExpectedText, entriesForDeeperCheck);
|
||||||
|
|
||||||
// reloading then waiting for the entries number to load
|
// reloading then waiting for the entries number to load
|
||||||
resizeToNormalMizu();
|
resizeToNormalMizu();
|
||||||
cy.reload();
|
cy.reload();
|
||||||
cy.get('#total-entries', {timeout: refreshWaitTimeout}).should('have.text', totalEntries);
|
cy.get('#total-entries', {timeout: refreshWaitTimeout}).should('have.text', totalEntries);
|
||||||
});
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deeperChcek(leftSidePath, rightSidePath, filterName, leftSideExpectedText, rightSideExpectedText, entriesNumToCheck) {
|
function deeperCheck(leftSidePath, rightSidePath, filterName, leftSideExpectedText, rightSideExpectedText, entriesNumToCheck) {
|
||||||
[...Array(entriesNumToCheck).keys()].forEach(entryNum => {
|
cy.get(`#list [id^=entry]`).each((element, index) => {
|
||||||
leftOnHoverCheck(entryNum, leftSidePath, filterName);
|
if (index < entriesNumToCheck) {
|
||||||
|
const entryId = getEntryId(element[0].id);
|
||||||
|
leftOnHoverCheck(entryId, leftSidePath, filterName);
|
||||||
|
|
||||||
cy.get(`#list #entry-${entryNum}`).click();
|
element.click();
|
||||||
rightTextCheck(rightSidePath, rightSideExpectedText);
|
rightTextCheck(rightSidePath, rightSideExpectedText);
|
||||||
rightOnHoverCheck(rightSidePath, filterName);
|
rightOnHoverCheck(rightSidePath, filterName);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user