Skip to content

Commit

Permalink
final touches
Browse files Browse the repository at this point in the history
  • Loading branch information
vicenteqa committed Jan 23, 2025
1 parent f608915 commit 8528eff
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 80 deletions.
18 changes: 9 additions & 9 deletions test/e2e/cypress/e2e/checks_catalog.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Checks catalog', () => {
});

it('should have only the first group expanded', () => {
checksCatalogPage.onlyFirstGroupIsExpanded();
checksCatalogPage.onlyFirstCheckGroupIsExpanded();
});
});

Expand Down Expand Up @@ -48,49 +48,49 @@ 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');
checksCatalogPage.selectFromTargetsSelectionDropdown('Clusters');
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');
checksCatalogPage.selectFromTargetsSelectionDropdown('Clusters');
checksCatalogPage
.selectFromClusterTypesSelectionDropdown('HANA Scale Up Cost Opt.')
.then((endpointUrl) =>
expect(endpointUrl).to.include(expectedEndpointUrl)
expect(endpointUrl).to.include(expectedRequestQuery)
);
});
});
Expand Down
8 changes: 1 addition & 7 deletions test/e2e/cypress/pageObject/base-po.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")';
Expand Down Expand Up @@ -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();
Expand Down
112 changes: 54 additions & 58 deletions test/e2e/cypress/pageObject/checks-catalog-po.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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 = () => {
Expand All @@ -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 = () => {
Expand All @@ -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);
Expand All @@ -174,15 +147,38 @@ 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');
};

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');
};
4 changes: 0 additions & 4 deletions test/e2e/cypress/pageObject/login-po.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/cypress/pageObject/users-po.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
};

Expand Down Expand Up @@ -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' })
);
};

Expand Down

0 comments on commit 8528eff

Please sign in to comment.