Replace endpoint address constants with helper functions in vulnmanagement integration tests#3131
Conversation
…ement integration tests
|
Images are ready for the commit at c33f312. To use with deploy scripts, first |
|
The following unrelated test failure looks like my bad editing cypress/helpers/compliance.js in #2799
There was a second click of the Scan button, which makes no sense. Apparently a copy-paste error. |
vjwilson
left a comment
There was a problem hiding this comment.
Just one question about some still-skipped tests.
| it.skip('should show same number of Image CVEs in menu item and entities list', () => { | ||
| verifyVulnerabilityManagementDashboardCVEs('image-cves', /^\d+ Image CVEs?$/); | ||
| }); |
There was a problem hiding this comment.
You abstracted the setup into a function verifyVulnerabilityManagementDashboardCVEs(), but did you mean to leave all three of these tests that now use it skip'ed ?
There was a problem hiding this comment.
Good eyes. I tested them locally and decided on temporary skip instead of feature flag logic.
When we turn on the feature flag for nightly and release builds, we can remove the skip.

Description
Encapsulate endpoints to reduce the sources of supporting information needed to read or write tests.
Through the experience of fixing 2 minor mistakes that I made in the first draft, I do see a benefit to my understanding from explicitly declaring entity keys for each interaction within a test.
Factor out multiple or parallel references in tests as helper functions which have semantic names:
visitVulnerabilityManagementEntityInSidePanelinteractAndWaitForVulnerabilityManagementEntityinteractAndWaitForVulnerabilityManagementEntitiesinteractAndWaitForVulnerabilityManagementSecondaryEntitiesIf only one test requires some container-specific information, consider pro and con to write it as inline string in the test, and then factor it out later if there is need to reuse it in other tests.
api.vulnMgmt.graphqlOps.getFixableCvesForEntityhas only 1 reference.Delete a few redundant tests which had been skipped for a long time.
Changed files
Edit cypress/constants/apiEndpoints.js
vulnMgmtobject.opnameForEntity,opnameForEntities,opnamePrefixForPrimaryAndSecondaryEntitiesobjects to entities.js file.Edit cypress/constants/VulnManagementPage.js
sidepanelproperty ofurlobject.applicationAndInfrastructureDropdownproperty ofdashboardSelectorsobject.Edit cypress/helpers/vulnmanagement/entities.js
opnameForEntity,opnameForEntities,opnamePrefixForPrimaryAndSecondaryEntitiesobjects from apiEndpoints.js file.keyForEntityastypeOfEntitybecause it is the type in workflow state.Edit cypress/integration/vulnmanagement/dashboard.test.js
interactAndWaitForVulnerabilityManagementEntitiesfunction to wait on relevant request for entities list.pathnameassertions into helper functions.cy.getgets DOM elements too soon, and therefore deletetimeoutoptions.parseIntfunction calls with:contains(value)pseudo-selector to reduce risk thatcy.getgets DOM elements too soon.'should properly navigate to the policies list'test which is redundant with the first test.Edit cypress/integration/vulnmanagement/entitypages.test.js
parseIntfunction calls with:contains(value)pseudo-selector to reduce risk thatcy.getgets DOM elements too soon.'should filter deployment count in failing policies section in namespace findings by namespace'test because it is redundant with a test in namespacesListPages.test.js file.'should filter component count in images list and image overview by cve when coming from cve list'test because it is redundant with tests in imageCvesListPages.test.js file.api.vulnMgmt.graphqlOps.getFixableCvesForEntitywith inline string.Edit cypress/integration/vulnmanagement/imageSection/imageOverview.test.js
idfrom fixture file.visitVulnerabilityManagementEntityInSidePanelfunction with static response argument for body from fixture file.Edit cypress/integration/vulnmanagement/nodeSection/nodeOverview.test.js
idfrom fixture file.visitVulnerabilityManagementEntityInSidePanelfunction with static response argument for body from fixture file.Checklist
Testing Performed
Ran changed tests one at a time in local deployment and used inspector with stagingdb for tests which fail because no vulnerabilities: