-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set pdisks column width (#1793)
- Loading branch information
Showing
9 changed files
with
222 additions
and
48 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
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
8 changes: 6 additions & 2 deletions
8
src/containers/Storage/StorageNodes/columns/StorageNodesColumns.scss
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
137 changes: 137 additions & 0 deletions
137
src/store/reducers/storage/__tests__/calculateMaximumDisksPerNode.test.ts
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,137 @@ | ||
import type {TNodeInfo} from '../../../../types/api/nodes'; | ||
import {TPDiskState} from '../../../../types/api/pdisk'; | ||
import {calculateMaximumDisksPerNode} from '../utils'; | ||
|
||
describe('calculateMaximumDisksPerNode', () => { | ||
it('should return providedMaximumDisksPerNode when it is provided', () => { | ||
const nodes: TNodeInfo[] = []; | ||
const providedMaximumDisksPerNode = '5'; | ||
|
||
expect(calculateMaximumDisksPerNode(nodes, providedMaximumDisksPerNode)).toBe('5'); | ||
}); | ||
|
||
it('should return "1" for empty nodes array', () => { | ||
const nodes: TNodeInfo[] = []; | ||
|
||
expect(calculateMaximumDisksPerNode(nodes)).toBe('1'); | ||
}); | ||
|
||
it('should return "1" for undefined nodes', () => { | ||
expect(calculateMaximumDisksPerNode(undefined)).toBe('1'); | ||
}); | ||
|
||
it('should return "1" for nodes without PDisks', () => { | ||
const nodes: TNodeInfo[] = [ | ||
{ | ||
NodeId: 1, | ||
SystemState: {}, | ||
}, | ||
]; | ||
|
||
expect(calculateMaximumDisksPerNode(nodes)).toBe('1'); | ||
}); | ||
|
||
it('should calculate maximum disks correctly for single node with multiple PDisks', () => { | ||
const nodes: TNodeInfo[] = [ | ||
{ | ||
NodeId: 1, | ||
SystemState: {}, | ||
PDisks: [ | ||
{ | ||
PDiskId: 1, | ||
State: TPDiskState.Normal, | ||
}, | ||
{ | ||
PDiskId: 2, | ||
State: TPDiskState.Normal, | ||
}, | ||
{ | ||
PDiskId: 3, | ||
State: TPDiskState.Normal, | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
expect(calculateMaximumDisksPerNode(nodes)).toBe('3'); | ||
}); | ||
|
||
it('should calculate maximum disks across multiple nodes', () => { | ||
const nodes: TNodeInfo[] = [ | ||
{ | ||
NodeId: 1, | ||
SystemState: {}, | ||
PDisks: [ | ||
{ | ||
PDiskId: 1, | ||
State: TPDiskState.Normal, | ||
}, | ||
], | ||
}, | ||
{ | ||
NodeId: 2, | ||
SystemState: {}, | ||
PDisks: [ | ||
{ | ||
PDiskId: 2, | ||
State: TPDiskState.Normal, | ||
}, | ||
{ | ||
PDiskId: 3, | ||
State: TPDiskState.Normal, | ||
}, | ||
], | ||
}, | ||
{ | ||
NodeId: 3, | ||
SystemState: {}, | ||
PDisks: [ | ||
{ | ||
PDiskId: 4, | ||
State: TPDiskState.Normal, | ||
}, | ||
{ | ||
PDiskId: 5, | ||
State: TPDiskState.Normal, | ||
}, | ||
{ | ||
PDiskId: 6, | ||
State: TPDiskState.Normal, | ||
}, | ||
{ | ||
PDiskId: 7, | ||
State: TPDiskState.Normal, | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
expect(calculateMaximumDisksPerNode(nodes)).toBe('4'); | ||
}); | ||
|
||
it('should handle nodes with empty PDisks array', () => { | ||
const nodes: TNodeInfo[] = [ | ||
{ | ||
NodeId: 1, | ||
SystemState: {}, | ||
PDisks: [], | ||
}, | ||
{ | ||
NodeId: 2, | ||
SystemState: {}, | ||
PDisks: [ | ||
{ | ||
PDiskId: 1, | ||
State: TPDiskState.Normal, | ||
}, | ||
{ | ||
PDiskId: 2, | ||
State: TPDiskState.Normal, | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
expect(calculateMaximumDisksPerNode(nodes)).toBe('2'); | ||
}); | ||
}); |
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
Oops, something went wrong.