mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-26 00:04:33 +00:00
Cypress: GuiPort test fix & new check in every test (#748)
This commit is contained in:
parent
4c4405885b
commit
78be20fe4d
@ -20,6 +20,7 @@
|
|||||||
"testUrl": "http://localhost:8899/",
|
"testUrl": "http://localhost:8899/",
|
||||||
"redactHeaderContent": "User-Header[REDACTED]",
|
"redactHeaderContent": "User-Header[REDACTED]",
|
||||||
"redactBodyContent": "{ \"User\": \"[REDACTED]\" }",
|
"redactBodyContent": "{ \"User\": \"[REDACTED]\" }",
|
||||||
"regexMaskingBodyContent": "[REDACTED]"
|
"regexMaskingBodyContent": "[REDACTED]",
|
||||||
|
"minimumEntries": 25
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,3 +16,15 @@ export function resizeToNormalMizu() {
|
|||||||
cy.viewport(1920, 1080);
|
cy.viewport(1920, 1080);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function verifyMinimumEntries() {
|
||||||
|
const minimumEntries = Cypress.env('minimumEntries');
|
||||||
|
it(`Making sure that mizu shows at least ${minimumEntries} entries`, async function () {
|
||||||
|
cy.get('#total-entries').then(number => {
|
||||||
|
const getNum = () => {
|
||||||
|
const numOfEntries = number.text();
|
||||||
|
return parseInt(numOfEntries);
|
||||||
|
};
|
||||||
|
cy.wrap({ there: getNum }).invoke('there').should('be.gte', minimumEntries);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
it('check', function () {
|
import {findLineAndCheck, getExpectedDetailsDict} from "../testHelpers/StatusBarHelper";
|
||||||
cy.visit(`http://localhost:${Cypress.env('port')}/`);
|
import {verifyMinimumEntries} from "../testHelpers/TrafficHelper";
|
||||||
|
|
||||||
cy.get('.header').should('be.visible');
|
it('check', function () {
|
||||||
cy.get('.TrafficPageHeader').should('be.visible');
|
const podName = Cypress.env('name'), namespace = Cypress.env('namespace');
|
||||||
cy.get('.TrafficPage-ListContainer').should('be.visible');
|
const port = Cypress.env('port');
|
||||||
cy.get('.TrafficPage-Container').should('be.visible');
|
cy.intercept('GET', `http://localhost:${port}/status/tap`).as('statusTap');
|
||||||
|
|
||||||
|
cy.visit(`http://localhost:${port}`);
|
||||||
|
cy.wait('@statusTap').its('response.statusCode').should('match', /^2\d{2}/);
|
||||||
|
|
||||||
|
verifyMinimumEntries();
|
||||||
|
|
||||||
|
cy.get('.podsCount').trigger('mouseover');
|
||||||
|
findLineAndCheck(getExpectedDetailsDict(podName, namespace));
|
||||||
});
|
});
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
import {isValueExistsInElement, resizeToHugeMizu} from "../testHelpers/TrafficHelper";
|
import {isValueExistsInElement, resizeToHugeMizu, verifyMinimumEntries} from "../testHelpers/TrafficHelper";
|
||||||
|
|
||||||
it('Loading Mizu', function () {
|
it('Loading Mizu', function () {
|
||||||
cy.visit(Cypress.env('testUrl'));
|
cy.visit(Cypress.env('testUrl'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('going through each entry', function () {
|
verifyMinimumEntries();
|
||||||
resizeToHugeMizu();
|
|
||||||
cy.get('#total-entries').then(number => {
|
|
||||||
const getNum = () => {
|
|
||||||
const numOfEntries = number.text();
|
|
||||||
return parseInt(numOfEntries);
|
|
||||||
};
|
|
||||||
cy.wrap({ there: getNum }).invoke('there').should('be.gte', 25);
|
|
||||||
|
|
||||||
|
checkEntries();
|
||||||
|
|
||||||
|
function checkEntries() {
|
||||||
|
it('checking all entries', function () {
|
||||||
checkThatAllEntriesShown();
|
checkThatAllEntriesShown();
|
||||||
|
resizeToHugeMizu();
|
||||||
|
|
||||||
const entriesNum = getNum();
|
cy.get('#total-entries').then(number => {
|
||||||
[...Array(entriesNum).keys()].map(checkEntry);
|
const numOfEntries = parseInt(number.text());
|
||||||
|
[...Array(numOfEntries).keys()].map(checkEntry);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function checkThatAllEntriesShown() {
|
function checkThatAllEntriesShown() {
|
||||||
cy.get('#entries-length').then(number => {
|
cy.get('#entries-length').then(number => {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import {isValueExistsInElement} from '../testHelpers/TrafficHelper';
|
import {isValueExistsInElement, verifyMinimumEntries} from '../testHelpers/TrafficHelper';
|
||||||
|
|
||||||
it('Loading Mizu', function () {
|
it('Loading Mizu', function () {
|
||||||
cy.visit(Cypress.env('testUrl'));
|
cy.visit(Cypress.env('testUrl'));
|
||||||
})
|
});
|
||||||
|
|
||||||
|
verifyMinimumEntries();
|
||||||
|
|
||||||
isValueExistsInElement(false, Cypress.env('redactHeaderContent'), '#tbody-Headers');
|
isValueExistsInElement(false, Cypress.env('redactHeaderContent'), '#tbody-Headers');
|
||||||
isValueExistsInElement(false, Cypress.env('redactBodyContent'), '.hljs');
|
isValueExistsInElement(false, Cypress.env('redactBodyContent'), '.hljs');
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import {isValueExistsInElement} from '../testHelpers/TrafficHelper';
|
import {isValueExistsInElement, verifyMinimumEntries} from '../testHelpers/TrafficHelper';
|
||||||
|
|
||||||
it('Loading Mizu', function () {
|
it('Loading Mizu', function () {
|
||||||
cy.visit(Cypress.env('testUrl'));
|
cy.visit(Cypress.env('testUrl'));
|
||||||
})
|
});
|
||||||
|
|
||||||
|
verifyMinimumEntries();
|
||||||
|
|
||||||
isValueExistsInElement(true, Cypress.env('redactHeaderContent'), '#tbody-Headers');
|
isValueExistsInElement(true, Cypress.env('redactHeaderContent'), '#tbody-Headers');
|
||||||
isValueExistsInElement(true, Cypress.env('redactBodyContent'), '.hljs');
|
isValueExistsInElement(true, Cypress.env('redactBodyContent'), '.hljs');
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import {isValueExistsInElement} from "../testHelpers/TrafficHelper";
|
import {isValueExistsInElement, verifyMinimumEntries} from "../testHelpers/TrafficHelper";
|
||||||
|
|
||||||
it('Loading Mizu', function () {
|
it('Loading Mizu', function () {
|
||||||
cy.visit(Cypress.env('testUrl'));
|
cy.visit(Cypress.env('testUrl'));
|
||||||
})
|
});
|
||||||
|
|
||||||
|
verifyMinimumEntries();
|
||||||
|
|
||||||
isValueExistsInElement(true, Cypress.env('regexMaskingBodyContent'), '.hljs');
|
isValueExistsInElement(true, Cypress.env('regexMaskingBodyContent'), '.hljs');
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {findLineAndCheck, getExpectedDetailsDict} from "../testHelpers/StatusBarHelper";
|
import {findLineAndCheck, getExpectedDetailsDict} from "../testHelpers/StatusBarHelper";
|
||||||
import {resizeToHugeMizu, resizeToNormalMizu} from "../testHelpers/TrafficHelper";
|
import {resizeToHugeMizu, resizeToNormalMizu, verifyMinimumEntries} from "../testHelpers/TrafficHelper";
|
||||||
const greenFilterColor = 'rgb(210, 250, 210)';
|
const greenFilterColor = 'rgb(210, 250, 210)';
|
||||||
const redFilterColor = 'rgb(250, 214, 220)';
|
const redFilterColor = 'rgb(250, 214, 220)';
|
||||||
const refreshWaitTimeout = 10000;
|
const refreshWaitTimeout = 10000;
|
||||||
@ -9,6 +9,8 @@ it('opening mizu', function () {
|
|||||||
cy.visit(Cypress.env('testUrl'));
|
cy.visit(Cypress.env('testUrl'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
verifyMinimumEntries();
|
||||||
|
|
||||||
it('top bar check', function () {
|
it('top bar check', function () {
|
||||||
const podName1 = 'httpbin', namespace1 = 'mizu-tests';
|
const podName1 = 'httpbin', namespace1 = 'mizu-tests';
|
||||||
const podName2 = 'httpbin2', namespace2 = 'mizu-tests';
|
const podName2 = 'httpbin2', namespace2 = 'mizu-tests';
|
||||||
@ -229,7 +231,6 @@ function deeperChcek(leftSidePath, rightSidePath, filterName, leftSideExpectedTe
|
|||||||
cy.get(`#list #entry-${entryNum}`).click();
|
cy.get(`#list #entry-${entryNum}`).click();
|
||||||
rightTextCheck(rightSidePath, rightSideExpectedText);
|
rightTextCheck(rightSidePath, rightSideExpectedText);
|
||||||
rightOnHoverCheck(rightSidePath, filterName);
|
rightOnHoverCheck(rightSidePath, filterName);
|
||||||
checkRightSideResponseBody();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,8 +259,6 @@ function checkRightSideResponseBody() {
|
|||||||
|
|
||||||
cy.get(`${bodyJsonClass}`).then(value => {
|
cy.get(`${bodyJsonClass}`).then(value => {
|
||||||
const encodedBody = value.text();
|
const encodedBody = value.text();
|
||||||
cy.log(encodedBody);
|
|
||||||
|
|
||||||
const decodedBody = atob(encodedBody);
|
const decodedBody = atob(encodedBody);
|
||||||
const responseBody = JSON.parse(decodedBody);
|
const responseBody = JSON.parse(decodedBody);
|
||||||
|
|
||||||
|
@ -110,7 +110,16 @@ func TestTapGuiPort(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/GuiPort.js\" --env port=%d", guiPort))
|
proxyUrl := getProxyUrl(defaultNamespaceName, defaultServiceName)
|
||||||
|
for i := 0; i < defaultEntriesCount; i++ {
|
||||||
|
if _, requestErr := executeHttpGetRequest(fmt.Sprintf("%v/get", proxyUrl)); requestErr != nil {
|
||||||
|
t.Errorf("failed to send proxy request, err: %v", requestErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/GuiPort.js\" --env name=%v,namespace=%v,port=%d",
|
||||||
|
"httpbin", "mizu-tests", guiPort))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user