Skip to content

Commit

Permalink
ARTESCA-11664: display name when empty
Browse files Browse the repository at this point in the history
Add test case for displaying name even if displayName is not empty

Update NodePageOverviewTab component to display the node name in metadata labels
  • Loading branch information
hervedombya committed Mar 14, 2024
1 parent 82f1fb1 commit 0bef13a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
45 changes: 44 additions & 1 deletion ui/src/components/NodePageOverviewTab.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,50 @@ describe('NodePageOverviewTab', () => {
await userEvent.keyboard('{enter}');

expect(SUT).toHaveBeenCalledWith({
metadata: { labels: { 'metalk8s.scality.com/name': NEW_DISPLAY_NAME } },
metadata: {
labels: {
'metalk8s.scality.com/name': `${props.nodeName}${NEW_DISPLAY_NAME}`,
},
},
});
});

it('should display name even if displayName is not empty', async () => {
const testProps = {
nodeName: 'mock-node',
nodeTableData: [
{
id: 'mock-id',
name: {
name: 'mock-node',
displayName: '',
controlPlaneIP: '',
workloadPlaneIP: '',
},
status: {
status: 'ready',
conditions: [],
statusTextColor: '#0AADA6',
computedStatus: ['ready'],
},
roles: 'bootstrap',
health: {
health: 'healthy',
totalAlertsCounter: 0,
criticalAlertsCounter: 0,
warningAlertsCounter: 0,
},
},
],
nodes: [],
pods: [],
volumes: [],
};

render(<NodePageOverviewTab {...testProps} />);

const inputs = await screen.findAllByText(testProps.nodeName);

expect(inputs.length).toBe(2);
});
});
4 changes: 3 additions & 1 deletion ui/src/components/NodePageOverviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ const NodePageOverviewTab = (props) => {
id="node-name-input"
autoFocus
changeMutation={mutation}
defaultValue={currentNode?.name?.displayName}
defaultValue={
currentNode?.name?.displayName || currentNode?.name?.name
}
/>
</Stack>
<OverviewInformationSpan>
Expand Down

0 comments on commit 0bef13a

Please sign in to comment.