From 3a4e870c103f930350eb24145d2ff97ef2ff4207 Mon Sep 17 00:00:00 2001 From: Xabier Arbulu Insausti Date: Wed, 10 May 2023 14:30:51 +0200 Subject: [PATCH] Ascs ers type frontend (#1398) * Add ascs/ers cluster type to the frontend * Improve e2e testing of the clusters view --- assets/js/components/ClustersList.jsx | 2 + assets/js/components/ClustersList.test.jsx | 5 +- test/e2e/cypress/e2e/clusters_overview.cy.js | 43 ++++++++--- .../clusters-overview/available_clusters.js | 74 ++++++++++++++----- 4 files changed, 93 insertions(+), 31 deletions(-) diff --git a/assets/js/components/ClustersList.jsx b/assets/js/components/ClustersList.jsx index 3972503020..5cc6e99250 100644 --- a/assets/js/components/ClustersList.jsx +++ b/assets/js/components/ClustersList.jsx @@ -17,6 +17,8 @@ const getClusterTypeLabel = (type) => { return 'HANA Scale Up'; case 'hana_scale_out': return 'HANA Scale Out'; + case 'ascs_ers': + return 'ASCS/ERS'; default: return 'Unknown'; } diff --git a/assets/js/components/ClustersList.test.jsx b/assets/js/components/ClustersList.test.jsx index 0bb62212ce..746fb1e7e1 100644 --- a/assets/js/components/ClustersList.test.jsx +++ b/assets/js/components/ClustersList.test.jsx @@ -73,13 +73,14 @@ describe('ClustersList component', () => { }, { filter: 'Type', - options: ['hana_scale_up'], + options: ['hana_scale_up', 'ascs_ers'], state: { ...cleanInitialState, clustersList: { clusters: [].concat( clusterFactory.buildList(2, { type: 'unknown' }), - clusterFactory.buildList(2, { type: 'hana_scale_up' }) + clusterFactory.buildList(2, { type: 'hana_scale_up' }), + clusterFactory.buildList(2, { type: 'ascs_ers' }) ), }, }, diff --git a/test/e2e/cypress/e2e/clusters_overview.cy.js b/test/e2e/cypress/e2e/clusters_overview.cy.js index 93e9b8c013..88f331e358 100644 --- a/test/e2e/cypress/e2e/clusters_overview.cy.js +++ b/test/e2e/cypress/e2e/clusters_overview.cy.js @@ -1,12 +1,13 @@ import { - allClusterNames, - clusterIdByName, + availableClusters, healthyClusterScenario, unhealthyClusterScenario, } from '../fixtures/clusters-overview/available_clusters'; +const clusterIdByName = (clusterName) => + availableClusters.find(({ name }) => name === clusterName).id; + context('Clusters Overview', () => { - const availableClusters = allClusterNames(); beforeEach(() => { cy.visit('/clusters'); cy.url().should('include', '/clusters'); @@ -21,14 +22,35 @@ context('Clusters Overview', () => { it('should have 1 pages', () => { cy.get('.tn-page-item').its('length').should('eq', 1); }); - describe('Discovered clusternames are the expected ones', () => { - availableClusters.forEach((clusterName) => { - it(`should have a cluster named ${clusterName}`, () => { - cy.get('.tn-clustername').each(($link) => { - const displayedClusterName = $link.text().trim(); - expect(availableClusters).to.include(displayedClusterName); + 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); }); - }); }); }); describe('Unnamed cluster', () => { @@ -116,6 +138,7 @@ context('Clusters Overview', () => { 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}'`, () => { diff --git a/test/e2e/cypress/fixtures/clusters-overview/available_clusters.js b/test/e2e/cypress/fixtures/clusters-overview/available_clusters.js index 831c699317..a68a7be148 100644 --- a/test/e2e/cypress/fixtures/clusters-overview/available_clusters.js +++ b/test/e2e/cypress/fixtures/clusters-overview/available_clusters.js @@ -1,24 +1,60 @@ -const availableClusters = [ - ['8a66f8fb-5fe9-51b3-a34c-24321271a4e3', 'drbd_cluster'], - ['6bd7ec60-8cb1-5c6b-a892-29e1fd2f8380', 'drbd_cluster'], - ['c7a1e943-bf46-590b-bd26-bfc7c78def97', 'drbd_cluster'], - ['7965f822-0254-5858-abca-f6e8b4c27714', 'hana_cluster_1'], - ['fa0d74a3-9240-5d9e-99fa-61c4137acf81', 'hana_cluster_2'], - ['469e7be5-4e20-5007-b044-c6f540a87493', 'hana_cluster_3'], - ['5284f376-c1f4-5178-8966-d490df3dab4f', 'netweaver_cluster'], - ['fb861bce-d212-56b5-8786-74afd6eb58cb', 'netweaver_cluster'], - ['0eac831a-aa66-5f45-89a4-007fbd2c5714', 'netweaver_cluster'], +export const availableClusters = [ + { + id: '8a66f8fb-5fe9-51b3-a34c-24321271a4e3', + name: 'drbd_cluster', + sid: '', + type: 'Unknown', + }, + { + id: '6bd7ec60-8cb1-5c6b-a892-29e1fd2f8380', + name: 'drbd_cluster', + sid: '', + type: 'Unknown', + }, + { + id: 'c7a1e943-bf46-590b-bd26-bfc7c78def97', + name: 'drbd_cluster', + sid: '', + type: 'Unknown', + }, + { + id: '7965f822-0254-5858-abca-f6e8b4c27714', + name: 'hana_cluster_1', + sid: 'HDD', + type: 'HANA Scale Up', + }, + { + id: 'fa0d74a3-9240-5d9e-99fa-61c4137acf81', + name: 'hana_cluster_2', + sid: 'HDQ', + type: 'HANA Scale Up', + }, + { + id: '469e7be5-4e20-5007-b044-c6f540a87493', + name: 'hana_cluster_3', + sid: 'HDP', + type: 'HANA Scale Up', + }, + { + id: '5284f376-c1f4-5178-8966-d490df3dab4f', + name: 'netweaver_cluster', + sid: '', + type: 'ASCS/ERS', + }, + { + id: 'fb861bce-d212-56b5-8786-74afd6eb58cb', + name: 'netweaver_cluster', + sid: '', + type: 'ASCS/ERS', + }, + { + id: '0eac831a-aa66-5f45-89a4-007fbd2c5714', + name: 'netweaver_cluster', + sid: '', + type: 'ASCS/ERS', + }, ]; -export const allClusterNames = () => - availableClusters.map(([_, clusterName]) => clusterName); -export const allClusterIds = () => - availableClusters.map(([clusterId, _]) => clusterId); -export const clusterIdByName = (clusterName) => - availableClusters.find(([, name]) => name === clusterName)[0]; -export const clusterNameById = (clusterId) => - availableClusters.find(([id]) => id === clusterId)[1]; - export const healthyClusterScenario = { clusterName: 'hana_cluster_2', checks: ['156F64'],