-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display cluster details by type (#1456)
* Update ClusterLink for ascs/ers cluster types * Rename ClusterDetails to HanaClusterDetails * Choose between details view depending on the type * Add basic test to see correct cluster type is used * Update HANA storybook story to match changes * Move cluster types constant to model lib
- Loading branch information
Showing
8 changed files
with
150 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
assets/js/components/ClusterDetails/ClusterDetailsPage.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
|
||
import { screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { withState, renderWithRouterMatch } from '@lib/test-utils'; | ||
|
||
import { clusterFactory } from '@lib/test-utils/factories'; | ||
|
||
import { ClusterDetailsPage } from './ClusterDetailsPage'; | ||
|
||
describe('ClusterDetails ClusterDetailsPage component', () => { | ||
it.each([ | ||
{ type: 'hana_scale_up', label: 'HANA scale-up' }, | ||
{ type: 'ascs_ers', label: 'ASCS/ERS' }, | ||
{ type: 'unknwon', label: 'Unknown cluster type' }, | ||
])( | ||
'should display the $type details based on cluster type', | ||
({ type, label }) => { | ||
const cluster = clusterFactory.build({ type }); | ||
const initialState = { | ||
clustersList: { clusters: [cluster] }, | ||
hostsList: { hosts: [] }, | ||
lastExecutions: { | ||
[cluster.id]: { data: null, loading: false, error: null }, | ||
}, | ||
}; | ||
|
||
const [statefulClusterDetailsPage, _] = withState( | ||
<ClusterDetailsPage />, | ||
initialState | ||
); | ||
|
||
renderWithRouterMatch(statefulClusterDetailsPage, { | ||
path: 'clusters/:clusterID', | ||
route: `/clusters/${cluster.id}`, | ||
}); | ||
|
||
expect(screen.getByText(label)).toBeInTheDocument(); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
|
||
import { screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { renderWithRouter } from '@lib/test-utils'; | ||
|
||
import { clusterFactory } from '@lib/test-utils/factories'; | ||
|
||
import ClusterLink from './ClusterLink'; | ||
|
||
describe('ClusterLink component', () => { | ||
it.each(['hana_scale_up', 'hana_scale_out', 'ascs_ers'])( | ||
'should render a link if the cluster type is %s', | ||
(type) => { | ||
const cluster = clusterFactory.build({ type }); | ||
|
||
renderWithRouter(<ClusterLink cluster={cluster} />); | ||
|
||
const link = screen.getByRole('link'); | ||
|
||
expect(link).toHaveTextContent(cluster.name); | ||
expect(link).toHaveAttribute('href', `/clusters/${cluster.id}`); | ||
} | ||
); | ||
|
||
it('should show a simple text if the cluster type is unknown', () => { | ||
const cluster = clusterFactory.build({ type: 'unknown' }); | ||
|
||
renderWithRouter(<ClusterLink cluster={cluster} />); | ||
|
||
expect(screen.queryByRole('link')).not.toBeInTheDocument(); | ||
expect(screen.getByText(cluster.name)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should show the cluster ID if the name is not available', () => { | ||
const cluster = clusterFactory.build({ name: '' }); | ||
|
||
renderWithRouter(<ClusterLink cluster={cluster} />); | ||
|
||
expect(screen.getByText(cluster.id)).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters