diff --git a/test/e2e/cypress/e2e/clusters_overview.cy.js b/test/e2e/cypress/e2e/clusters_overview.cy.js index f7beb84a6c..879d3f5a24 100644 --- a/test/e2e/cypress/e2e/clusters_overview.cy.js +++ b/test/e2e/cypress/e2e/clusters_overview.cy.js @@ -1,234 +1,117 @@ -import { createUserRequestFactory } from '@lib/test-utils/factories'; - -import { - availableClusters, - healthyClusterScenario, - unhealthyClusterScenario, -} from '../fixtures/clusters-overview/available_clusters'; - -const clusterIdByName = (clusterName) => - availableClusters.find(({ name }) => name === clusterName).id; - -const clusterTags = { - hana_cluster_1: 'env1', - hana_cluster_2: 'env2', - hana_cluster_3: 'env3', -}; +import * as clustersOverviewPage from '../pageObject/clusters-overview-po.js'; context('Clusters Overview', () => { - before(() => { - cy.preloadTestData(); - cy.visit('/clusters'); - cy.url().should('include', '/clusters'); + before(() => clustersOverviewPage.preloadTestData()); + + beforeEach(() => { + clustersOverviewPage.interceptClustersEndpoint(); + clustersOverviewPage.visit(); + clustersOverviewPage.validateUrl(); }); describe('Registered Clusters should be available in the overview', () => { it('should show all of the registered clusters', () => { - cy.get('.tn-clustername') - .its('length') - .should('eq', availableClusters.length); + clustersOverviewPage.allRegisteredClustersAreDisplayed(); }); it('should have 1 pages', () => { - cy.get(`[data-testid="pagination"]`).should('include.text', '1'); - cy.get(`[data-testid="pagination"]`).should('not.include.text', '2'); + clustersOverviewPage.paginationButtonsAreDisabled(); }); it('should show the expected clusters data', () => { - cy.get('.container').eq(0).as('clustersTable'); - availableClusters.forEach((cluster, index) => { - cy.get('@clustersTable') - .find('tr') - .eq(index + 1) - .find('td') - .as('clusterRow'); - - cy.get('@clustersTable') - .contains('th', 'Name') - .invoke('index') - .then((i) => { - cy.get('@clusterRow').eq(i).should('contain', cluster.name); - }); - - cy.get('@clustersTable') - .contains('th', 'SID') - .invoke('index') - .then((i) => { - cy.get('@clusterRow').eq(i).should('contain', cluster.sid); - }); - - cy.get('@clustersTable') - .contains('th', 'Type') - .invoke('index') - .then((i) => { - cy.get('@clusterRow').eq(i).should('contain', cluster.type); - }); - }); + clustersOverviewPage.clustersDataIsDisplayedAsExpected(); }); describe('Unnamed cluster', () => { - before(() => { - cy.loadScenario('cluster-unnamed'); - }); - - // Restore cluster name - after(() => { - cy.loadScenario('cluster-4-SOK'); - }); + before(() => clustersOverviewPage.loadScenario('cluster-unnamed')); it('Unnamed clusters should use the ID as details page link', () => { - const clusterID = clusterIdByName('hana_cluster_1'); - cy.get(`a:contains(${clusterID})`).should('be.visible'); + clustersOverviewPage.clusterNameLinkIsDisplayedAsId('hana_cluster_1'); }); + + after(() => clustersOverviewPage.restoreClusterName()); }); // eslint-disable-next-line mocha/no-skipped-tests describe.skip('Health status for each cluster is correct', () => { before(() => { - cy.selectChecks( - clusterIdByName(healthyClusterScenario.clusterName), - healthyClusterScenario.checks - ); + clustersOverviewPage.apiSelectChecksForHealthyCluster(); // wip: set expected results - cy.requestChecksExecution( - clusterIdByName(healthyClusterScenario.clusterName) - ); - - cy.selectChecks( - clusterIdByName(unhealthyClusterScenario.clusterName), - healthyClusterScenario.checks - ); + clustersOverviewPage.apiRequestChecksForHealthyCluster(); + + clustersOverviewPage.apiSelectChecksForUnhealthyCluster(); // wip: set expected results - cy.requestChecksExecution( - clusterIdByName(unhealthyClusterScenario.clusterName) - ); + clustersOverviewPage.apiRequestChecksForUnhealthyCluster(); }); after(() => { - cy.selectChecks( - clusterIdByName(healthyClusterScenario.clusterName), - [] - ); - - cy.selectChecks( - clusterIdByName(unhealthyClusterScenario.clusterName), - [] - ); + clustersOverviewPage.apiRemoveHealthyClusterChecks(); + clustersOverviewPage.apiRemoveUnhealthyClusterChecks(); }); - it(`should have ${healthyClusterScenario.clusterName} displaying healthy state`, () => { - cy.get('td') - .contains(healthyClusterScenario.clusterName) - .parent() - .parent() - .prev() - .get('div > svg') - .should('have.class', 'fill-jungle-green-500'); + it(`should have ${clustersOverviewPage.healthyClusterName} displaying healthy state`, () => { + clustersOverviewPage.healthyClusterNameDisplaysHealthyState(); }); - it(`should have ${unhealthyClusterScenario.clusterName} displaying unhealthy state`, () => { - cy.get('td') - .contains(unhealthyClusterScenario.clusterName) - .parent() - .parent() - .prev() - .get('div > svg') - .should('have.class', 'fill-red-500'); + it(`should have ${clustersOverviewPage.unhealthyClusterName} displaying unhealthy state`, () => { + clustersOverviewPage.unhealthyClusterNameDisplaysUnhealthyState(); }); }); }); describe('Clusters Tagging', () => { - before(() => { - cy.removeTagsFromView(); + beforeEach(() => { + clustersOverviewPage.restoreClusterName(); + clustersOverviewPage.apiRemoveAllTags(); }); - const clustersByMatchingPattern = (pattern) => (clusterName) => - clusterName.includes(pattern); - const taggingRules = [ - ['hana_cluster_1', clusterTags.hana_cluster_1], - ['hana_cluster_2', clusterTags.hana_cluster_2], - ['hana_cluster_3', clusterTags.hana_cluster_3], - ]; - - taggingRules.forEach(([pattern, tag]) => { - describe(`Add tag '${tag}' to all clusters with '${pattern}' in the cluster name`, () => { - availableClusters - .map(({ name }) => name) - .filter(clustersByMatchingPattern(pattern)) - .forEach((clusterName) => { - it(`should tag cluster '${clusterName}'`, () => { - cy.addTagByColumnValue(clusterName, tag); - }); - }); - }); + + it('should tag each cluster with the corresponding tag', () => { + clustersOverviewPage.setClusterTags(); + clustersOverviewPage.eachClusterTagsIsCorrectlyDisplayed(); }); }); describe('Deregistration', () => { - const hanaCluster1 = { - name: 'hana_cluster_1', - hosts: [ - '13e8c25c-3180-5a9a-95c8-51ec38e50cfc', - '0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4', - ], - }; - - it(`should not display '${hanaCluster1.name}' after deregistering all its nodes`, () => { - cy.deregisterHost(hanaCluster1.hosts[0]); - cy.deregisterHost(hanaCluster1.hosts[1]); - cy.contains(hanaCluster1.name).should('not.exist'); + before(() => { + clustersOverviewPage.apiRemoveAllTags(); + clustersOverviewPage.apiSetTagsHanaCluster1(); + clustersOverviewPage.apiDeregisterAllClusterHosts(); }); - it(`should show cluster ${hanaCluster1.name} after registering it again with the previous tags`, () => { - cy.loadScenario(`cluster-${hanaCluster1.name}-restore`); - cy.contains(hanaCluster1.name).should('exist'); - cy.contains('tr', hanaCluster1.name).within(() => { - cy.contains(clusterTags[hanaCluster1.name]).should('exist'); - }); + it(`should not display '${clustersOverviewPage.hanaCluster1.name}' after deregistering all its nodes`, () => { + clustersOverviewPage.clusterIsNotDisplayedWhenNodesAreDeregistered(); + }); + + it(`should show cluster '${clustersOverviewPage.hanaCluster1.name}' after registering it again with the previous tags`, () => { + clustersOverviewPage.apiRestoreClusterHosts(); + clustersOverviewPage.clusterNameIsDisplayed(); + clustersOverviewPage.hanaCluster1TagsAreDisplayed(); }); }); describe('Forbidden action', () => { - beforeEach(() => { - cy.deleteAllUsers(); - cy.logout(); - const user = createUserRequestFactory.build({ - password, - password_confirmation: password, + describe('Tag operations', () => { + beforeEach(() => { + clustersOverviewPage.apiRemoveAllTags(); + clustersOverviewPage.apiSetTagsHanaCluster1(); + clustersOverviewPage.apiDeleteAllUsers(); + clustersOverviewPage.logout(); }); - cy.wrap(user).as('user'); - }); - - const password = 'password'; - describe('Tag operations', () => { it('should prevent a tag update when the user abilities are not compliant', () => { - cy.get('@user').then((user) => { - cy.createUserWithAbilities(user, []); - cy.login(user.username, password); - }); - - cy.visit('/clusters'); - - cy.contains('span', 'Add Tag').should('have.class', 'opacity-50'); - cy.get('[data-test-id="tag-env1"]').should('have.class', 'opacity-50'); + clustersOverviewPage.apiCreateUserWithoutAbilities(); + clustersOverviewPage.loginWithoutTagAbilities(); + clustersOverviewPage.visit(); + clustersOverviewPage.addTagButtonsAreDisabled(); + clustersOverviewPage.removeTagButtonIsDisabled(); }); it('should allow a tag update when the user abilities are compliant', () => { - cy.get('@user').then((user) => { - cy.createUserWithAbilities(user, [ - { name: 'all', resource: 'cluster_tags' }, - ]); - cy.login(user.username, password); - }); - - cy.visit('/clusters'); - - cy.contains('span', 'Add Tag').should('not.have.class', 'opacity-50'); - cy.get('[data-test-id="tag-env1"]').should( - 'not.have.class', - 'opacity-50' - ); + clustersOverviewPage.apiCreateUserWithClusterTagsAbilities(); + clustersOverviewPage.loginWithTagAbilities(); + clustersOverviewPage.visit(); + clustersOverviewPage.addTagButtonsAreNotDisabled(); + clustersOverviewPage.removeTagButtonIsEnabled(); }); }); }); diff --git a/test/e2e/cypress/pageObject/about-po.js b/test/e2e/cypress/pageObject/about-po.js index 40c7b35536..217fa9643c 100644 --- a/test/e2e/cypress/pageObject/about-po.js +++ b/test/e2e/cypress/pageObject/about-po.js @@ -9,9 +9,7 @@ const githubRepositoryLabel = 'div:contains("GitHub repository") + div a'; const amountOfSlesForSapSubscriptionsLabel = 'div:contains("SLES for SAP subscriptions") + div span'; -export const visit = (_url = url) => { - return basePage.visit(_url); -}; +export const visit = () => basePage.visit(url); export const pageTitleIsDisplayed = () => { return cy.get(pageTitle).should('have.text', 'About Trento Console'); diff --git a/test/e2e/cypress/pageObject/base-po.js b/test/e2e/cypress/pageObject/base-po.js index 424848e1ee..21cd391917 100644 --- a/test/e2e/cypress/pageObject/base-po.js +++ b/test/e2e/cypress/pageObject/base-po.js @@ -102,8 +102,10 @@ export const apiLoginAndCreateSession = ( }; export const logout = () => { - window.localStorage.removeItem('access_token'); - window.localStorage.removeItem('refresh_token'); + cy.window().then((win) => { + win.localStorage.removeItem('access_token'); + win.localStorage.removeItem('refresh_token'); + }); Cypress.session.clearAllSavedSessions(); }; @@ -170,12 +172,12 @@ export const preloadTestData = () => { * scenario is sent in the second time. */ isTestDataLoaded().then((isLoaded) => { - if (!isLoaded) cy.loadScenario('healthy-27-node-SAP-cluster'); + if (!isLoaded) loadScenario('healthy-27-node-SAP-cluster'); }); loadScenario('healthy-27-node-SAP-cluster'); }; -const loadScenario = (scenario) => { +export const loadScenario = (scenario) => { const [projectRoot, photofinishBinary, webAPIHost, webAPIPort] = [ Cypress.env('project_root'), Cypress.env('photofinish_binary'), @@ -204,3 +206,29 @@ const isTestDataLoaded = () => }) .then(({ body }) => body.length !== 0) ); + +export const createUserWithAbilities = (payload, abilities) => + apiLogin().then(({ accessToken }) => + cy + .request({ + url: '/api/v1/abilities', + method: 'GET', + auth: { bearer: accessToken }, + body: {}, + }) + .then(({ body }) => { + const abilitiesWithID = abilities.map((ability) => ({ + ...body.find( + ({ name, resource }) => + ability.name === name && ability.resource === resource + ), + })); + + cy.request({ + url: '/api/v1/users', + method: 'POST', + auth: { bearer: accessToken }, + body: { ...payload, abilities: abilitiesWithID }, + }); + }) + ); diff --git a/test/e2e/cypress/pageObject/checks-catalog-po.js b/test/e2e/cypress/pageObject/checks-catalog-po.js index 9d7836c4d3..078a9b3ffd 100644 --- a/test/e2e/cypress/pageObject/checks-catalog-po.js +++ b/test/e2e/cypress/pageObject/checks-catalog-po.js @@ -13,8 +13,7 @@ const groupNames = '.check-group > div > div > h3'; const checkRows = '.check-row'; const checkPanels = '.check-panel'; -const clusterTargetTypeIcon = '[data-testid="target-icon-cluster"]'; -const hostTargetTypeIcon = '[data-testid="target-icon-host"]'; +const targetIcon = 'div[aria-label="accordion-panel"] span span:nth-child(1)'; const providersSelectionDropdown = 'button.providers-selection-dropdown'; const targetsSelectionDropdown = 'button.targets-selection-dropdown'; @@ -65,9 +64,7 @@ const selectFromCatalogDropdown = (dropdownElementSelector, choice) => { .click(); }; -export const visit = (_url = url) => { - return basePage.visit(_url); -}; +export const visit = () => basePage.visit(url); export const interceptChecksCatalogEndpoint = (forceError = false) => { let interceptArgument; @@ -172,11 +169,16 @@ export const eachGroupHasExpectedCheckIds = () => { }; export const expectedTargetTypeClusterIconsAreDisplayed = () => { - return cy.get(clusterTargetTypeIcon).should('have.length', group1Checks); + return cy + .get(`h3:contains("${clusterChecksGroup}")`) + .parents(checkGroups) + .within(() => cy.get(targetIcon).should('have.length', group1Checks)); }; export const expectedTargetTypeHostIconsAreDisplayed = () => { - return cy.get(hostTargetTypeIcon).should('have.length', group2Checks); + cy.get(`h3:contains("${hostChecksGroup}")`) + .parents(checkGroups) + .within(() => cy.get(targetIcon).should('have.length', group2Checks)); }; export const checkPanelIsNotVisible = () => { diff --git a/test/e2e/cypress/pageObject/clusters-overview-po.js b/test/e2e/cypress/pageObject/clusters-overview-po.js new file mode 100644 index 0000000000..3dafa47220 --- /dev/null +++ b/test/e2e/cypress/pageObject/clusters-overview-po.js @@ -0,0 +1,331 @@ +export * from './base-po.js'; +import * as basePage from './base-po.js'; + +import { createUserRequestFactory } from '@lib/test-utils/factories'; +import { + availableClusters, + healthyClusterScenario, + unhealthyClusterScenario, +} from '../fixtures/clusters-overview/available_clusters'; + +const url = '/clusters'; +const clustersEndpoint = '/api/v2/clusters'; +const clustersEndpointAlias = 'clustersEndpoint'; + +//Selectors +const clusterNames = '.tn-clustername'; +const paginationNavigationButtons = 'div[class*="bg-gray-50"] ul button'; +const tableRows = 'tbody tr'; +const rowCells = 'td'; +const addTagButtons = 'span span:contains("Add Tag")'; +const removeEnv1TagButton = 'span span:contains("env1") span'; + +//Test data +export const healthyClusterName = healthyClusterScenario.clusterName; +export const unhealthyClusterName = unhealthyClusterScenario.clusterName; + +const password = 'password'; + +const user = createUserRequestFactory.build({ + password, + password_confirmation: password, +}); + +export const hanaCluster1 = { + name: 'hana_cluster_1', + hosts: [ + '13e8c25c-3180-5a9a-95c8-51ec38e50cfc', + '0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4', + ], +}; + +const clusterTags = { + hana_cluster_1: 'env1', + hana_cluster_2: 'env2', + hana_cluster_3: 'env3', +}; + +const taggingRules = [ + ['hana_cluster_1', clusterTags.hana_cluster_1], + ['hana_cluster_2', clusterTags.hana_cluster_2], + ['hana_cluster_3', clusterTags.hana_cluster_3], +]; + +export const visit = () => basePage.visit(url); + +export const validateUrl = () => basePage.validateUrl(url); + +export const interceptClustersEndpoint = () => + cy.intercept(clustersEndpoint).as(clustersEndpointAlias); + +export const waitForClustersEndpoint = () => + basePage.waitForRequest(clustersEndpointAlias); + +// UI Interactions + +export const setClusterTags = () => { + taggingRules.forEach(([clusterName, tag]) => { + addTagByColumnValue(clusterName, tag); + }); +}; + +const addTagByColumnValue = (columnValue, tagValue) => { + cy.get(`td:contains(${columnValue})`) + .parents('tr') + .within(() => { + cy.get(addTagButtons).type(`${tagValue}{enter}`); + }); +}; + +// Validations + +export const hanaCluster1TagsAreDisplayed = () => { + return cy + .get(`tr:contains("${hanaCluster1.name}")`) + .within(() => + cy + .get(`span span:contains("${clusterTags[hanaCluster1.name]}")`) + .should('be.visible') + ); +}; + +export const addTagButtonsAreDisabled = () => + cy.get(addTagButtons).should('have.class', 'opacity-50'); + +export const addTagButtonsAreNotDisabled = () => + cy.get(addTagButtons).should('not.have.class', 'opacity-50'); + +export const removeTagButtonIsDisabled = () => + cy.get(removeEnv1TagButton).should('have.class', 'opacity-50'); + +export const removeTagButtonIsEnabled = () => + cy.get(removeEnv1TagButton).should('not.have.class', 'opacity-50'); + +export const clusterNameLinkIsDisplayedAsId = (clusterName) => { + const clusterID = clusterIdByName(clusterName); + return waitForClustersEndpoint().then(() => + cy.get(tableRows).eq(8).find(rowCells).eq(1).should('have.text', clusterID) + ); +}; + +export const allRegisteredClustersAreDisplayed = () => + cy.get(clusterNames).should('have.length', availableClusters.length); + +export const paginationButtonsAreDisabled = () => + cy.get(paginationNavigationButtons).should('be.disabled'); + +export const clustersDataIsDisplayedAsExpected = () => { + return waitForClustersEndpoint().then(() => { + return cy.get(tableRows).each(($row, index) => { + const cluster = availableClusters[index]; + cy.wrap($row).find('td').eq(1).should('have.text', cluster.name); + cy.wrap($row).find('td').eq(2).should('have.text', cluster.sid); + return cy.wrap($row).find('td').eq(5).should('have.text', cluster.type); + }); + }); +}; + +export const healthyClusterNameDisplaysHealthyState = () => + clusterHealthIconHasExpectedClass( + healthyClusterScenario.clusterName, + 'fill-jungle-green-500' + ); + +export const unhealthyClusterNameDisplaysUnhealthyState = () => + clusterHealthIconHasExpectedClass( + unhealthyClusterScenario.clusterName, + 'fill-red-500' + ); + +export const clusterHealthIconHasExpectedClass = (clusterName, className) => { + return cy + .get(`td:contains("${clusterName}")`) + .parents('tr') + .within(() => + cy.get('td').eq(0).find('svg').should('have.class', className) + ); +}; + +export const eachClusterTagsIsCorrectlyDisplayed = () => { + return taggingRules.forEach(([tag]) => + cy.get(`span span:contains(${tag})`).should('be.visible') + ); +}; + +export const clusterIsNotDisplayedWhenNodesAreDeregistered = () => + cy.get(`span span:contains("${hanaCluster1.name}")`).should('not.exist'); + +export const clusterNameIsDisplayed = () => { + cy.get(`span span:contains("${hanaCluster1.name}")`).should('be.visible'); +}; + +// Helpers + +const clusterIdByName = (clusterName) => + availableClusters.find(({ name }) => name === clusterName).id; + +// API Interactions + +export const apiRemoveTagByClusterId = (clusterId, tagId) => { + return basePage.apiLogin().then(({ accessToken }) => + cy.request({ + url: `/api/v1/clusters/${clusterId}/tags/${tagId}`, + method: 'DELETE', + auth: { bearer: accessToken }, + }) + ); +}; + +const apiGetClusters = () => { + return basePage.apiLogin().then(({ accessToken }) => { + const url = '/api/v2/clusters'; + return cy + .request({ + method: 'GET', + url: url, + auth: { + bearer: accessToken, + }, + }) + .then((response) => response); + }); +}; + +export const apiRemoveAllTags = () => { + apiGetClusters().then((response) => { + const clusterTags = getClusterTags(response.body); + Object.entries(clusterTags).forEach(([clusterId, tags]) => { + tags.forEach((tag) => apiRemoveTagByClusterId(clusterId, tag)); + }); + }); + return basePage.refresh(); +}; + +const getClusterTags = (jsonData) => { + const clusterTags = {}; + jsonData.forEach((cluster) => { + if (cluster.tags && cluster.tags.length > 0) { + clusterTags[cluster.id] = cluster.tags.map((tag) => tag.value); + } + }); + + return clusterTags; +}; + +const apiDeregisterHost = (hostId) => { + return basePage.apiLogin().then(({ accessToken }) => { + const url = `/api/v1/hosts/${hostId}`; + cy.request({ + method: 'DELETE', + url: url, + auth: { + bearer: accessToken, + }, + }); + }); +}; + +export const apiDeregisterAllClusterHosts = () => + hanaCluster1.hosts.forEach((hostId) => apiDeregisterHost(hostId)); + +export const apiRestoreClusterHosts = () => + basePage.loadScenario(`cluster-${hanaCluster1.name}-restore`); + +const apiSetTag = (clusterName, tag) => { + const clusterID = clusterIdByName(clusterName); + return basePage.apiLogin().then(({ accessToken }) => + cy.request({ + url: `/api/v1/clusters/${clusterID}/tags`, + method: 'POST', + auth: { bearer: accessToken }, + body: { value: tag }, + }) + ); +}; + +export const apiSetTagsHanaCluster1 = () => { + const tagsForCluster1 = taggingRules + .filter(([cluster]) => cluster === 'hana_cluster_1') + .map(([, tag]) => tag); + return tagsForCluster1.forEach((tag) => apiSetTag('hana_cluster_1', tag)); +}; + +export const apiCreateUserWithoutAbilities = () => + basePage.createUserWithAbilities(user, []); + +export const apiCreateUserWithClusterTagsAbilities = () => + basePage.createUserWithAbilities(user, [ + { name: 'all', resource: 'cluster_tags' }, + ]); + +export const loginWithoutTagAbilities = () => + basePage.apiLoginAndCreateSession(user.username, password); + +export const loginWithTagAbilities = () => + basePage.apiLoginAndCreateSession(user.username, password); + +const apiSelectChecks = (clusterId, checks) => { + const checksBody = JSON.stringify({ + checks: checks, + }); + + const headers = { + 'Content-Type': 'application/json;charset=UTF-8', + }; + + return basePage.apiLogin().then(({ accessToken }) => { + const url = `/api/clusters/${clusterId}/checks`; + cy.request({ + method: 'POST', + url: url, + body: checksBody, + headers: headers, + auth: { + bearer: accessToken, + }, + }); + }); +}; + +const apiRequestChecksExecution = (clusterId) => { + return basePage.apiLogin().then(({ accessToken }) => { + const url = `/api/clusters/${clusterId}/checks/request_execution`; + cy.request({ + method: 'POST', + url: url, + auth: { + bearer: accessToken, + }, + }); + }); +}; + +export const apiSelectChecksForHealthyCluster = () => + apiSelectChecks( + clusterIdByName(healthyClusterScenario.clusterName), + healthyClusterScenario.checks + ); + +export const apiRequestChecksForHealthyCluster = () => + apiRequestChecksExecution( + clusterIdByName(healthyClusterScenario.clusterName) + ); + +export const apiSelectChecksForUnhealthyCluster = () => + apiSelectChecks( + clusterIdByName(unhealthyClusterScenario.clusterName), + healthyClusterScenario.checks + ); + +export const apiRequestChecksForUnhealthyCluster = () => + apiRequestChecksExecution( + clusterIdByName(unhealthyClusterScenario.clusterName) + ); + +export const apiRemoveHealthyClusterChecks = () => + apiSelectChecks(clusterIdByName(healthyClusterScenario.clusterName), []); + +export const apiRemoveUnhealthyClusterChecks = () => + apiSelectChecks(clusterIdByName(unhealthyClusterScenario.clusterName), []); + +export const restoreClusterName = () => basePage.loadScenario('cluster-4-SOK'); diff --git a/test/e2e/cypress/support/commands.js b/test/e2e/cypress/support/commands.js index 6beee3441a..a2bdc130e4 100644 --- a/test/e2e/cypress/support/commands.js +++ b/test/e2e/cypress/support/commands.js @@ -125,33 +125,6 @@ Cypress.Commands.add('clickOutside', () => { return cy.get('body').click(0, 0); //0,0 here are the x and y coordinates }); -Cypress.Commands.add('selectChecks', (clusterId, checks) => { - const [webAPIHost, webAPIPort] = [ - Cypress.env('web_api_host'), - Cypress.env('web_api_port'), - ]; - const checksBody = JSON.stringify({ - checks: checks, - }); - - const headers = { - 'Content-Type': 'application/json;charset=UTF-8', - }; - - cy.apiLogin().then(({ accessToken }) => { - const url = `http://${webAPIHost}:${webAPIPort}/api/clusters/${clusterId}/checks`; - cy.request({ - method: 'POST', - url: url, - body: checksBody, - headers: headers, - auth: { - bearer: accessToken, - }, - }); - }); -}); - const isTestDataLoaded = () => cy.apiLogin().then(({ accessToken }) => cy @@ -198,29 +171,6 @@ Cypress.Commands.add('resetFilterSelection', (filterName) => { }); }); -Cypress.Commands.add('requestChecksExecution', (clusterId) => { - const [webAPIHost, webAPIPort] = [ - Cypress.env('web_api_host'), - Cypress.env('web_api_port'), - ]; - - const headers = { - 'Content-Type': 'application/json;charset=UTF-8', - }; - - cy.apiLogin().then(({ accessToken }) => { - const url = `http://${webAPIHost}:${webAPIPort}/api/clusters/${clusterId}/checks/request_execution`; - cy.request({ - method: 'POST', - url: url, - headers: headers, - auth: { - bearer: accessToken, - }, - }); - }); -}); - Cypress.Commands.add('deregisterHost', (hostId) => { const [webAPIHost, webAPIPort] = [ Cypress.env('web_api_host'),