diff --git a/test/e2e/cypress/e2e/checks_catalog.cy.js b/test/e2e/cypress/e2e/checks_catalog.cy.js index c80f1f1a7f..c75212d345 100644 --- a/test/e2e/cypress/e2e/checks_catalog.cy.js +++ b/test/e2e/cypress/e2e/checks_catalog.cy.js @@ -14,7 +14,7 @@ describe('Checks catalog', () => { }); it('should have only the first group expanded', () => { - checksCatalogPage.onlyFirstGroupIsExpanded(); + checksCatalogPage.onlyFirstCheckGroupIsExpanded(); }); }); @@ -48,28 +48,28 @@ describe('Checks catalog', () => { describe('Filtering', () => { it('expected query is issued for AWS provider', () => { - const expectedEndpointUrl = 'provider=aws'; + const expectedRequestQuery = 'provider=aws'; checksCatalogPage .selectFromProvidersDropdown('AWS') .then((endpointUrl) => - expect(endpointUrl).to.include(expectedEndpointUrl) + expect(endpointUrl).to.include(expectedRequestQuery) ); }); it('expected query is issued for AWS provider & Cluster Target Type', () => { - const expectedEndpointUrl = 'provider=aws&target_type=cluster'; + const expectedRequestQuery = 'provider=aws&target_type=cluster'; checksCatalogPage.selectFromProvidersDropdown('AWS'); checksCatalogPage .selectFromTargetsSelectionDropdown('Clusters') .then((endpointUrl) => - expect(endpointUrl).to.include(expectedEndpointUrl) + expect(endpointUrl).to.include(expectedRequestQuery) ); }); it('expected query is issued for AWS provider & Cluster Target Type & HANA Scale Up Perf. Opt.', () => { - const expectedEndpointUrl = + const expectedRequestQuery = 'provider=aws&target_type=cluster&cluster_type=hana_scale_up&hana_scenario=performance_optimized'; checksCatalogPage.selectFromProvidersDropdown('AWS'); @@ -77,12 +77,12 @@ describe('Checks catalog', () => { checksCatalogPage .selectFromClusterTypesSelectionDropdown('HANA Scale Up Perf. Opt.') .then((endpointUrl) => - expect(endpointUrl).to.include(expectedEndpointUrl) + expect(endpointUrl).to.include(expectedRequestQuery) ); }); it('expected query is issued for AWS provider & Cluster Target Type & HANA Scale Up Cost Opt.', () => { - const expectedEndpointUrl = + const expectedRequestQuery = 'provider=aws&target_type=cluster&cluster_type=hana_scale_up&hana_scenario=cost_optimized'; checksCatalogPage.selectFromProvidersDropdown('AWS'); @@ -90,7 +90,7 @@ describe('Checks catalog', () => { checksCatalogPage .selectFromClusterTypesSelectionDropdown('HANA Scale Up Cost Opt.') .then((endpointUrl) => - expect(endpointUrl).to.include(expectedEndpointUrl) + expect(endpointUrl).to.include(expectedRequestQuery) ); }); }); diff --git a/test/e2e/cypress/pageObject/base-po.js b/test/e2e/cypress/pageObject/base-po.js index 1712431077..487f6bc3fb 100644 --- a/test/e2e/cypress/pageObject/base-po.js +++ b/test/e2e/cypress/pageObject/base-po.js @@ -2,6 +2,7 @@ import { TOTP } from 'totp-generator'; const DEFAULT_USERNAME = Cypress.env('login_user'); const DEFAULT_PASSWORD = Cypress.env('login_password'); + const pageTitle = 'h1'; const userDropdownMenuButton = 'header button[id*="menu"]'; const userDropdownProfileButton = 'a:contains("Profile")'; @@ -135,13 +136,6 @@ export const validateItemPresentInNavigationMenu = (navigationMenuItem) => { export const waitForRequest = (requestAlias) => cy.wait(`@${requestAlias}`); -export const requestHasExpectedUrl = (url, requestAlias) => { - return waitForRequest(requestAlias).then(({ request }) => { - expect(request.url.includes(url), `${request.url} should include ${url}`).to - .be.true; - }); -}; - export const selectFromDropdown = (selector, choice) => { cy.get(selector).click(); return cy.get(`${selector} + div div:contains("${choice}")`).click(); diff --git a/test/e2e/cypress/pageObject/checks-catalog-po.js b/test/e2e/cypress/pageObject/checks-catalog-po.js index aa14447434..9d7836c4d3 100644 --- a/test/e2e/cypress/pageObject/checks-catalog-po.js +++ b/test/e2e/cypress/pageObject/checks-catalog-po.js @@ -7,7 +7,7 @@ import { groupBy } from 'lodash'; const url = '/catalog'; const checksCatalogEndpointAlias = 'checksCatalogRequest'; -//Selectors +// Selectors const checkGroups = 'div.check-group'; const groupNames = '.check-group > div > div > h3'; const checkRows = '.check-row'; @@ -26,7 +26,7 @@ const dropdownSelectedIcon = const networkErrorLabel = 'p:contains("Network Error")'; const tryAgainButton = 'button:contains("Try again")'; -//Test Data +// Test Data const checksCatalogURL = '**/api/v3/checks/catalog'; const clusterChecksGroup = 'Group 1'; @@ -57,28 +57,29 @@ const group3 = catalogCheckFactory.buildList(group3Checks, { }); const catalog = [...group1, ...group2, ...group3]; -export const visit = (_url = url) => { - return basePage.visit(_url); -}; - -export const expectedCheckGroupsAreDisplayed = () => { - return cy.get(checkGroups).should('have.length', 3); +const selectFromCatalogDropdown = (dropdownElementSelector, choice) => { + cy.get(dropdownElementSelector).click(); + cy.get(dropdownSelectedIcon).should('be.visible'); + return cy + .get(`${dropdownElementSelector} + div div:contains("${choice}")`) + .click(); }; -export const onlyFirstGroupIsExpanded = () => { - return cy.get(checkGroups).first().find(checkRows).should('have.length', 2); +export const visit = (_url = url) => { + return basePage.visit(_url); }; export const interceptChecksCatalogEndpoint = (forceError = false) => { let interceptArgument; if (forceError) { interceptArgument = { forceNetworkError: true }; - } else interceptArgument = { body: { items: catalog } }; + } else { + interceptArgument = { body: { items: catalog } }; + } - cy.intercept(`${checksCatalogURL}**`, interceptArgument).as( - checksCatalogEndpointAlias - ); - return checksCatalogEndpointAlias; + return cy + .intercept(`${checksCatalogURL}**`, interceptArgument) + .as(checksCatalogEndpointAlias); }; export const interceptChecksCatalogEndpointWithError = () => { @@ -89,11 +90,17 @@ export const getCheckGroupsNames = () => { return Object.entries(groupBy(catalog, 'group')).map(([group]) => group); }; -export const expectedcheckGroupssAreIncluded = () => { +export const expectedCheckGroupsAreDisplayed = () => { + return cy.get(checkGroups).should('have.length', 3); +}; + +export const onlyFirstCheckGroupIsExpanded = () => { + return cy.get(checkGroups).first().find(checkRows).should('have.length', 2); +}; + +export const expectedCheckGroupsAreIncluded = () => { const groups = getCheckGroupsNames(); - return groups.forEach(([group]) => - cy.get(groupNames).should('contain', group) - ); + return groups.forEach((group) => cy.get(groupNames).should('contain', group)); }; export const eachGroupShouldBeExpanded = () => { @@ -118,44 +125,10 @@ export const expandAllGroups = () => { }); }; -export const eachGroupHasExpectedCheckIds = () => { - expandAllGroups(); - const catalogIds = catalog.map((item) => item.id); - - return catalogIds.forEach((id) => { - cy.get(`p:contains("${id}")`).should('be.visible'); - }); -}; - -export const expectedTargetTypeClusterIconsAreDisplayed = () => { - return cy.get(clusterTargetTypeIcon).should('have.length', group1Checks); -}; - -export const expectedTargetTypeHostIconsAreDisplayed = () => { - return cy.get(hostTargetTypeIcon).should('have.length', group2Checks); -}; - -export const checkPanelIsNotVisible = () => { - return cy.get(checkPanels).should('not.exist'); -}; - export const clickFirstCheckRow = () => { return cy.get(checkRows).first().click(); }; -export const checkPanelHasTheExpectedText = () => { - return cy - .get(checkPanels) - .first() - .should('have.text', catalog[0].remediation); -}; - -const selectFromCatalogDropdown = (selector, choice) => { - cy.get(selector).click(); - cy.get(dropdownSelectedIcon).should('be.visible'); - cy.get(`${selector} + div div:contains("${choice}")`).click(); -}; - export const selectFromProvidersDropdown = (choice) => { selectFromCatalogDropdown(providersSelectionDropdown, choice); return waitForChecksCatalogRequest().then((response) => response.request.url); @@ -174,11 +147,6 @@ export const selectFromClusterTypesSelectionDropdown = (choice) => { export const waitForChecksCatalogRequest = () => { return basePage.waitForRequest(checksCatalogEndpointAlias); }; - -export const checksCatalogRequestsHasExpectedUrl = (url) => { - return basePage.requestHasExpectedUrl(url, checksCatalogEndpointAlias); -}; - export const networkErrorLabelIsDisplayed = () => { return cy.get(networkErrorLabel).should('be.visible'); }; @@ -186,3 +154,31 @@ export const networkErrorLabelIsDisplayed = () => { export const tryAgainButtonIsDisplayed = () => { return cy.get(tryAgainButton).should('be.visible'); }; + +export const checkPanelHasTheExpectedText = () => { + return cy + .get(checkPanels) + .first() + .should('have.text', catalog[0].remediation); +}; + +export const eachGroupHasExpectedCheckIds = () => { + expandAllGroups(); + const catalogIds = catalog.map((item) => item.id); + + return catalogIds.forEach((id) => { + cy.get(`p:contains("${id}")`).should('be.visible'); + }); +}; + +export const expectedTargetTypeClusterIconsAreDisplayed = () => { + return cy.get(clusterTargetTypeIcon).should('have.length', group1Checks); +}; + +export const expectedTargetTypeHostIconsAreDisplayed = () => { + return cy.get(hostTargetTypeIcon).should('have.length', group2Checks); +}; + +export const checkPanelIsNotVisible = () => { + return cy.get(checkPanels).should('not.exist'); +}; diff --git a/test/e2e/cypress/pageObject/login-po.js b/test/e2e/cypress/pageObject/login-po.js index 7ef31c08ec..4c0c8d1111 100644 --- a/test/e2e/cypress/pageObject/login-po.js +++ b/test/e2e/cypress/pageObject/login-po.js @@ -53,10 +53,6 @@ export const login = (username, password) => { return clickSubmitLoginButton(); }; -export const sleep = (seconds) => { - return new Promise((resolve) => setTimeout(resolve, seconds * 1000)); -}; - export const invalidCredentialsErrorIsDisplayed = () => { return cy.get(invalidCredentialsError).should('be.visible'); }; diff --git a/test/e2e/cypress/pageObject/users-po.js b/test/e2e/cypress/pageObject/users-po.js index 83b7d13909..79f07e47f2 100644 --- a/test/e2e/cypress/pageObject/users-po.js +++ b/test/e2e/cypress/pageObject/users-po.js @@ -153,7 +153,7 @@ export const selectFromTotpDropdown = (choice) => { return basePage.selectFromDropdown(editUserTotpDropdown, choice); }; -export const getTotpSecret = () => { +const getTotpSecret = () => { return cy.get(totpSecret).then((element) => element.text()); }; @@ -241,7 +241,7 @@ export const apiPatchUser = (id, payload) => { export const apiModifyUserFullName = () => { return getUserIdFromPath().then((id) => - apiPatchUser(id, { fullname: 'some_random_string' }) + apiPatchUser(id, { fullname: 'new_name' }) ); };