Skip to content

Commit 5348be8

Browse files
committed
#RI-2577 - Selected renamed key is displayed in tree view with old name
1 parent 9c5fc6d commit 5348be8

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

redisinsight/ui/src/components/virtual-tree/VirtualTree.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('VirtualTree', () => {
7777
/>
7878
)
7979

80-
expect(queryByTestId('test')).toBeInTheDocument()
80+
expect(queryByTestId('node-item_test')).toBeInTheDocument()
8181
})
8282

8383
it('should select first leaf "Keys" by default', async () => {

redisinsight/ui/src/components/virtual-tree/VirtualTree.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export interface Props {
4141
setConstructingTree: (status: boolean) => void
4242
}
4343

44-
const timeLabel = 'Time for construct a Tree'
4544
const VirtualTree = (props: Props) => {
4645
const {
4746
items,

redisinsight/ui/src/components/virtual-tree/components/Node/Node.spec.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { render, screen } from 'uiSrc/utils/test-utils'
55
import KeyDarkSVG from 'uiSrc/assets/img/sidebar/browser_active.svg'
66
import Node from './Node'
77
import { TreeData } from '../../interfaces'
8-
import { mockLeafKeys } from '../../VirtualTree.spec'
8+
import { mockLeafKeys, mockVirtualTreeResult } from '../../VirtualTree.spec'
99

1010
const mockedProps = mock<NodePublicState<TreeData>>()
1111
const mockedPropsData = mock<TreeData>()
@@ -16,6 +16,11 @@ const mockedData: TreeData = {
1616
}
1717
const mockDataFullName = 'test'
1818

19+
jest.mock('uiSrc/services', () => ({
20+
...jest.requireActual('uiSrc/services'),
21+
useDisposableWebworker: () => ({ result: mockVirtualTreeResult, run: jest.fn() }),
22+
}))
23+
1924
describe('Node', () => {
2025
it('should render', () => {
2126
expect(render(<Node {...instance(mockedProps)} data={mockedData} />)).toBeTruthy()
@@ -69,7 +74,7 @@ describe('Node', () => {
6974
data={mockData}
7075
/>)
7176

72-
screen.getByTestId(mockDataFullName).click()
77+
screen.getByTestId(`node-item_${mockDataFullName}`).click()
7378

7479
expect(mockSetItems).toBeCalledWith(mockLeafKeys)
7580
expect(mockUpdateStatusSelected).toBeCalledWith(mockDataFullName, mockLeafKeys)
@@ -101,7 +106,7 @@ describe('Node', () => {
101106
data={mockData}
102107
/>)
103108

104-
screen.getByTestId(mockDataFullName).click()
109+
screen.getByTestId(`node-item_${mockDataFullName}`).click()
105110

106111
expect(mockSetItems).not.toBeCalled()
107112
expect(mockUpdateStatusSelected).not.toBeCalled()

redisinsight/ui/src/components/virtual-tree/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FixedSizeNodeData } from 'react-vtree'
22
import { IKeyPropTypes } from 'uiSrc/constants/prop-types/keys'
33

4-
export const TREE_LEAF_FIELD = 'keys:keys:'
4+
export const TREE_LEAF_FIELD = 'keys:keys'
55

66
export interface TreeNode {
77
children: TreeNode[]

redisinsight/ui/src/helpers/tests/constructKeysToTreeMockResult.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const constructKeysToTreeMockResult = [
3131
}
3232
},
3333
keyCount: 4,
34-
fullName: 'keys:keys:',
34+
fullName: `${TREE_LEAF_FIELD}:`,
3535
keyApproximate: 40,
3636
},
3737
{
@@ -61,7 +61,7 @@ export const constructKeysToTreeMockResult = [
6161
}
6262
},
6363
keyCount: 3,
64-
fullName: 'keys:keys:keys:',
64+
fullName: `keys:${TREE_LEAF_FIELD}:`,
6565
keyApproximate: 30,
6666
},
6767
{
@@ -85,7 +85,7 @@ export const constructKeysToTreeMockResult = [
8585
}
8686
},
8787
keyCount: 2,
88-
fullName: 'keys:1:keys:keys:',
88+
fullName: `keys:1:${TREE_LEAF_FIELD}:`,
8989
keyApproximate: 20,
9090
}
9191
],
@@ -116,7 +116,7 @@ export const constructKeysToTreeMockResult = [
116116
}
117117
},
118118
keyCount: 1,
119-
fullName: 'empty::keys:keys:',
119+
fullName: `empty::${TREE_LEAF_FIELD}:`,
120120
keyApproximate: 10,
121121
}
122122
],

redisinsight/ui/src/pages/browser/components/key-tree/KeyTree.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('KeyTree', () => {
109109
it('"setBrowserTreeNodesOpen" should be called for Open a node', () => {
110110
render(<KeyTree {...propsMock} />)
111111

112-
fireEvent.click(screen.getByTestId(mockVirtualTreeResult?.[0]?.fullName))
112+
fireEvent.click(screen.getByTestId(`node-item_${mockVirtualTreeResult?.[0]?.fullName}`))
113113

114114
const expectedActions = [setBrowserTreeSelectedLeaf({}), setBrowserTreeNodesOpen({})]
115115

0 commit comments

Comments
 (0)