From 048360db404a3bd826d548b3078c84a04af79d38 Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Thu, 25 Jun 2020 16:51:45 +0200 Subject: [PATCH] Add element IDs to simplify tests --- .../clusterConfiguration/discoveryImageModal.tsx | 6 +++++- src/components/clusters/ClusterStatus.tsx | 2 +- src/components/clusters/ClustersTable.tsx | 1 + src/components/clusters/newClusterModal.tsx | 2 +- src/components/hosts/HostsTable.tsx | 16 +++++++++++----- src/selectors/clusters.tsx | 2 +- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/components/clusterConfiguration/discoveryImageModal.tsx b/src/components/clusterConfiguration/discoveryImageModal.tsx index 7adf981f2b..2aeb2e1c0d 100644 --- a/src/components/clusterConfiguration/discoveryImageModal.tsx +++ b/src/components/clusterConfiguration/discoveryImageModal.tsx @@ -40,7 +40,11 @@ export const DiscoveryImageModalButton: React.FC return ( <> - setIsModalOpen(true)}> + setIsModalOpen(true)} + id="button-download-discovery-iso" + > Download discovery ISO {isModalOpen && } diff --git a/src/components/clusters/ClusterStatus.tsx b/src/components/clusters/ClusterStatus.tsx index 8774e4c45a..ebe9c7c7d1 100644 --- a/src/components/clusters/ClusterStatus.tsx +++ b/src/components/clusters/ClusterStatus.tsx @@ -45,7 +45,7 @@ const ClusterStatus: React.FC = ({ cluster }) => { minWidth="30rem" maxWidth="50rem" > - diff --git a/src/components/clusters/ClustersTable.tsx b/src/components/clusters/ClustersTable.tsx index 6d9173f04e..07e43e9190 100644 --- a/src/components/clusters/ClustersTable.tsx +++ b/src/components/clusters/ClustersTable.tsx @@ -52,6 +52,7 @@ const ClustersTable: React.FC = ({ rows, deleteCluster }) => (rowData) => [ { title: 'Delete', + id: `button-delete-${rowData.props.name}`, isDisabled: getClusterTableStatusCell(rowData).sortableValue === CLUSTER_STATUS_LABELS.installing, onClick: (event: React.MouseEvent, rowIndex: number, rowData: IRowData) => { diff --git a/src/components/clusters/newClusterModal.tsx b/src/components/clusters/newClusterModal.tsx index 8f254b645f..1edf1f0258 100644 --- a/src/components/clusters/newClusterModal.tsx +++ b/src/components/clusters/newClusterModal.tsx @@ -40,7 +40,7 @@ export const NewClusterModalButton: React.FC = ({ ButtonComponent = Button, onClick, }) => ( - + Create New Cluster ); diff --git a/src/components/hosts/HostsTable.tsx b/src/components/hosts/HostsTable.tsx index 2d89eebe61..d989413120 100644 --- a/src/components/hosts/HostsTable.tsx +++ b/src/components/hosts/HostsTable.tsx @@ -92,6 +92,8 @@ const hostToHostTableRow = (openRows: OpenRows) => (host: Host): IRow => { fullWidth: true, cells: [{ title: }], key: `${host.id}-detail`, + extraData: host, + inventory, }, ]; }; @@ -234,7 +236,9 @@ const HostsTable: React.FC = ({ cluster }) => { const actionResolver = React.useCallback( (rowData: IRowData) => { - const host = rowData.extraData; + const host: Host = rowData.extraData; + const hostname = rowData.inventory?.hostname; + if (!host) { // I.e. row with detail return []; @@ -244,26 +248,28 @@ const HostsTable: React.FC = ({ cluster }) => { if (host.status === 'disabled') { actions.push({ title: 'Enable in cluster', + id: `button-enable-in-cluster-${hostname}`, onClick: onHostEnable, }); } if (['discovering', 'disconnected', 'known', 'insufficient'].includes(host.status)) { actions.push({ title: 'Disable in cluster', + id: `button-disable-in-cluster-${hostname}`, onClick: onHostDisable, }); } actions.push({ title: 'View Host Events History', + id: `button-view-host-events-${hostname}`, onClick: onViewHostEvents, }); if (!['installing', 'installing-in-progress', 'error', 'installed'].includes(host.status)) { actions.push({ title: 'Delete', - onClick: (event: React.MouseEvent, rowIndex: number, rowData: IRowData) => { - const hostId = rowData.extraData.id; - const hostname = rowData.inventory.hostname; - setHostToDelete({ id: hostId, hostname }); + id: `button-delete-host-${hostname}`, + onClick: () => { + setHostToDelete({ id: host.id, hostname }); }, }); } diff --git a/src/selectors/clusters.tsx b/src/selectors/clusters.tsx index 91a29c6e00..cea6a97438 100644 --- a/src/selectors/clusters.tsx +++ b/src/selectors/clusters.tsx @@ -31,7 +31,7 @@ const clusterToClusterTableRow = (cluster: Cluster): IRow => { cells: [ { title: ( - + {name} ),