diff --git a/acceptanceTests/cypress/integration/tests/UiTest.js b/acceptanceTests/cypress/integration/tests/UiTest.js index af5ca6332..9d0c623f9 100644 --- a/acceptanceTests/cypress/integration/tests/UiTest.js +++ b/acceptanceTests/cypress/integration/tests/UiTest.js @@ -1,15 +1,24 @@ import {findLineAndCheck, getExpectedDetailsDict} from "../testHelpers/StatusBarHelper"; import { + leftOnHoverCheck, leftTextCheck, resizeToHugeMizu, resizeToNormalMizu, rightOnHoverCheck, - leftOnHoverCheck, rightTextCheck, verifyMinimumEntries } from "../testHelpers/TrafficHelper"; + const refreshWaitTimeout = 10000; + +const fullParam = Cypress.env('arrayDict'); // "Name:fooNamespace:barName:foo1Namespace:bar1" +const podsArray = fullParam.split('Name:').slice(1); // ["fooNamespace:bar", "foo1Namespace:bar1"] +podsArray.forEach((podStr, index) => { + const podAndNamespaceArr = podStr.split('Namespace:'); // [foo, bar] / [foo1, bar1] + podsArray[index] = getExpectedDetailsDict(podAndNamespaceArr[0], podAndNamespaceArr[1]); +}); + it('opening mizu', function () { cy.visit(Cypress.env('testUrl')); }); @@ -17,16 +26,13 @@ it('opening mizu', function () { verifyMinimumEntries(); it('top bar check', function () { - const podName1 = 'httpbin', namespace1 = 'mizu-tests'; - const podName2 = 'httpbin2', namespace2 = 'mizu-tests'; - cy.get('.podsCount').trigger('mouseover'); - findLineAndCheck(getExpectedDetailsDict(podName1, namespace1)); - findLineAndCheck(getExpectedDetailsDict(podName2, namespace2)); + podsArray.map(findLineAndCheck); cy.reload(); }); it('filtering guide check', function () { + cy.reload(); cy.get('[title="Open Filtering Guide (Cheatsheet)"]').click(); cy.get('#modal-modal-title').should('be.visible'); cy.get('[lang="en"]').click(0, 0); @@ -64,8 +70,6 @@ it('right side sanity test', function () { }); }); -serviceMapCheck(); - checkIllegalFilter('invalid filter'); checkFilter({ @@ -86,14 +90,27 @@ checkFilter({ applyByEnter: false }); -checkFilter({ - name: 'src.name == ""', - leftSidePath: '[title="Source Name"]', - leftSideExpectedText: '[Unresolved]', - rightSidePath: '> :nth-child(2) [title="Source Name"]', - rightSideExpectedText: '[Unresolved]', - applyByEnter: false -}); +if (Cypress.env('shouldCheckSrcAndDest')) { + serviceMapCheck(); + + checkFilter({ + name: 'src.name == ""', + leftSidePath: '[title="Source Name"]', + leftSideExpectedText: '[Unresolved]', + rightSidePath: '> :nth-child(2) [title="Source Name"]', + rightSideExpectedText: '[Unresolved]', + applyByEnter: false + }); + + checkFilter({ + name: `dst.name == "httpbin.mizu-tests"`, + leftSidePath: '> :nth-child(3) > :nth-child(2) > :nth-child(3) > :nth-child(2)', + leftSideExpectedText: 'httpbin.mizu-tests', + rightSidePath: '> :nth-child(2) > :nth-child(2) > :nth-child(2) > :nth-child(3) > :nth-child(2)', + rightSideExpectedText: 'httpbin.mizu-tests', + applyByEnter: false + }); +} checkFilter({ name: 'method == "GET"', @@ -113,15 +130,6 @@ checkFilter({ applyByEnter: false }); -checkFilter({ - name: 'dst.name == "httpbin.mizu-tests"', - leftSidePath: '> :nth-child(3) > :nth-child(2) > :nth-child(3) > :nth-child(2)', - leftSideExpectedText: 'httpbin.mizu-tests', - rightSidePath: '> :nth-child(2) > :nth-child(2) > :nth-child(2) > :nth-child(3) > :nth-child(2)', - rightSideExpectedText: 'httpbin.mizu-tests', - applyByEnter: false -}); - checkFilter({ name: 'src.ip == "127.0.0.1"', leftSidePath: '[title="Source IP"]', @@ -169,6 +177,7 @@ function shouldNotExist(entryNum) { function checkIllegalFilter(illegalFilterName) { it(`should show red search bar with the input: ${illegalFilterName}`, function () { + cy.reload(); cy.get('#total-entries').then(number => { const totalEntries = number.text(); diff --git a/acceptanceTests/tap_test.go b/acceptanceTests/tap_test.go index b27c2907b..4c2349059 100644 --- a/acceptanceTests/tap_test.go +++ b/acceptanceTests/tap_test.go @@ -62,7 +62,19 @@ func TestTap(t *testing.T) { } } - runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/UiTest.js\" --env entriesCount=%d", entriesCount)) + expectedPods := []PodDescriptor{ + {Name: "httpbin", Namespace: "mizu-tests"}, + {Name: "httpbin2", Namespace: "mizu-tests"}, + } + + var expectedPodsStr string + for i := 0; i < len(expectedPods); i++ { + expectedPodsStr += fmt.Sprintf("Name:%vNamespace:%v", expectedPods[i].Name, expectedPods[i].Namespace) + } + + const shouldCheckSrcAndDest = false + runCypressTests(t, fmt.Sprintf("npx cypress run --spec \"cypress/integration/tests/UiTest.js\" --env entriesCount=%d,arrayDict=%v,shouldCheckSrcAndDest=%v", + entriesCount, expectedPodsStr, shouldCheckSrcAndDest)) }) } } diff --git a/acceptanceTests/testsUtils.go b/acceptanceTests/testsUtils.go index c7b5734f2..9c42602f7 100644 --- a/acceptanceTests/testsUtils.go +++ b/acceptanceTests/testsUtils.go @@ -148,9 +148,9 @@ func getDefaultConfigCommandArgs() []string { func runCypressTests(t *testing.T, cypressRunCmd string) { cypressCmd := exec.Command("bash", "-c", cypressRunCmd) t.Logf("running command: %v", cypressCmd.String()) - out, err := cypressCmd.Output() + out, err := cypressCmd.CombinedOutput() if err != nil { - t.Errorf("error running cypress, error: %v", err) + t.Errorf("error running cypress, error: %v, output: %v", err, string(out)) return }