Skip to content

Commit 90f8c96

Browse files
fix bug where element-id shows incorrectly in table (#1949)
* fix bug where element-id showed incorrectly in table * add elementId check to test * update test * fix type errors in test * Fix test
1 parent 90cd97e commit 90f8c96

File tree

14 files changed

+60
-21
lines changed

14 files changed

+60
-21
lines changed

e2e_tests/integration/types.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ describe('Types in Browser', () => {
145145
cy.get('[data-testid="vizInspector"]')
146146
.should('contain', 'P11M2DT2H19')
147147
.and('contain', 'srid:4326')
148+
.and('contain', 'elementId')
148149
})
149150
it('renders types in paths in viz correctly', () => {
150151
cy.executeCommand(':clear')

src/browser/modules/Stream/CypherFrame/AsciiView.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import { shallowEquals } from 'services/utils'
4343
import { GlobalState } from 'shared/globalState'
4444
import { BrowserRequestResult } from 'shared/modules/requests/requestsDuck'
4545
import { getMaxFieldItems } from 'shared/modules/settings/settingsDuck'
46-
import { Record } from 'neo4j-driver'
4746

4847
interface BaseAsciiViewComponentProps {
4948
result: BrowserRequestResult

src/browser/modules/Stream/CypherFrame/VisualizationView/PropertiesPanelContent/DetailsPane.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe('<DetailsPane />', () => {
5555
type: type,
5656
item: {
5757
id: 'abc',
58+
elementId: 'abc',
5859
labels,
5960
propertyList
6061
}
@@ -65,6 +66,7 @@ describe('<DetailsPane />', () => {
6566
type: type,
6667
item: {
6768
id: 'abc',
69+
elementId: 'abc',
6870
type: 'abc2',
6971
propertyList
7072
}
@@ -84,8 +86,8 @@ describe('<DetailsPane />', () => {
8486

8587
expect(screen.getByRole('button', { name: 'Show all' })).toBeInTheDocument()
8688
expect(
87-
screen.getByRole('button', { name: 'Show 2 more' })
88-
).toBeInTheDocument() // id is added to list of properties so only showing 999
89+
screen.getByRole('button', { name: 'Show 3 more' })
90+
).toBeInTheDocument() // id & elementId is added to list of properties so only showing 998
8991
expect(screen.queryByText('prop1000')).not.toBeInTheDocument()
9092

9193
const showAllButton = screen.getByText('Show all')
@@ -117,7 +119,7 @@ describe('<DetailsPane />', () => {
117119
screen.queryByRole('button', { name: 'Show all' })
118120
).toBeInTheDocument()
119121
expect(
120-
screen.getByRole('button', { name: 'Show 2 more' })
122+
screen.getByRole('button', { name: 'Show 3 more' })
121123
).toBeInTheDocument()
122124
})
123125
})

src/browser/modules/Stream/CypherFrame/VisualizationView/PropertiesPanelContent/DetailsPane.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ export function DetailsPane({
4141
value: `${vizItem.item.id}`,
4242
type: 'String'
4343
}
44-
const allItemProperties = [idProperty, ...vizItem.item.propertyList].sort(
45-
(a, b) => (a.key < b.key ? -1 : 1)
46-
)
44+
const elementIdProperty = {
45+
key: '<elementId>',
46+
value: `${vizItem.item.elementId}`,
47+
type: 'String'
48+
}
49+
const allItemProperties = [
50+
idProperty,
51+
elementIdProperty,
52+
...vizItem.item.propertyList
53+
].sort((a, b) => (a.key < b.key ? -1 : 1))
4754
const visibleItemProperties = allItemProperties.slice(0, maxPropertiesCount)
4855

4956
const handleMorePropertiesClick = (numMore: number) => {

src/neo4j-arc/common/components/PropertiesTable/PropertiesTable.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('<DetailsPane />', () => {
5151
type: type,
5252
item: {
5353
id: 'abc',
54+
elementId: 'abc',
5455
labels,
5556
propertyList
5657
}
@@ -61,6 +62,7 @@ describe('<DetailsPane />', () => {
6162
type: type,
6263
item: {
6364
id: 'abc',
65+
elementId: 'abc',
6466
type: 'abc2',
6567
propertyList
6668
}

src/neo4j-arc/common/types/arcTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
*/
2020
export type BasicNode = {
2121
id: string
22+
elementId: string
2223
labels: string[]
2324
properties: Record<string, string>
2425
propertyTypes: Record<string, string>
2526
}
2627
export type BasicRelationship = {
2728
id: string
29+
elementId: string
2830
startNodeId: string
2931
endNodeId: string
3032
type: string

src/neo4j-arc/common/utils/driverUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export const extractUniqueNodesAndRels = (
117117
const nodes = Array.from(nodeMap.values()).map(item => {
118118
return {
119119
id: item.identity.toString(),
120+
elementId: item.elementId,
120121
labels: item.labels,
121122
properties: mapObjectValues(item.properties, propertyToString),
122123
propertyTypes: mapObjectValues(
@@ -142,6 +143,7 @@ export const extractUniqueNodesAndRels = (
142143
.map(item => {
143144
return {
144145
id: item.identity.toString(),
146+
elementId: item.elementId,
145147
startNodeId: item.start.toString(),
146148
endNodeId: item.end.toString(),
147149
type: item.type,

src/neo4j-arc/graph-visualization/GraphVisualizer/DefaultPanelContent/DefaultDetailsPane.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ describe('<DetailsPane />', () => {
5959
type: type,
6060
item: {
6161
id: 'abc',
62+
elementId: 'elementId',
6263
labels,
6364
propertyList
6465
}
@@ -69,6 +70,7 @@ describe('<DetailsPane />', () => {
6970
type: type,
7071
item: {
7172
id: 'abc',
73+
elementId: 'elementId',
7274
type: 'abc2',
7375
propertyList
7476
}
@@ -88,8 +90,8 @@ describe('<DetailsPane />', () => {
8890

8991
expect(screen.getByRole('button', { name: 'Show all' })).toBeInTheDocument()
9092
expect(
91-
screen.getByRole('button', { name: 'Show 2 more' })
92-
).toBeInTheDocument() // id is added to list of properties so only showing 999
93+
screen.getByRole('button', { name: 'Show 3 more' })
94+
).toBeInTheDocument() // id & elementId is added to list of properties so only showing 998
9395
expect(screen.queryByText('prop1000')).not.toBeInTheDocument()
9496

9597
const showAllButton = screen.getByText('Show all')
@@ -121,7 +123,7 @@ describe('<DetailsPane />', () => {
121123
screen.queryByRole('button', { name: 'Show all' })
122124
).toBeInTheDocument()
123125
expect(
124-
screen.getByRole('button', { name: 'Show 2 more' })
126+
screen.getByRole('button', { name: 'Show 3 more' })
125127
).toBeInTheDocument()
126128
})
127129
})

src/neo4j-arc/graph-visualization/GraphVisualizer/DefaultPanelContent/DefaultDetailsPane.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,16 @@ export function DefaultDetailsPane({
4747
value: `${vizItem.item.id}`,
4848
type: 'String'
4949
}
50-
const allItemProperties = [idProperty, ...vizItem.item.propertyList].sort(
51-
(a, b) => (a.key < b.key ? -1 : 1)
52-
)
50+
const elementIdProperty = {
51+
key: '<element-id>',
52+
value: `${vizItem.item.elementId}`,
53+
type: 'String'
54+
}
55+
const allItemProperties = [
56+
idProperty,
57+
elementIdProperty,
58+
...vizItem.item.propertyList
59+
].sort((a, b) => (a.key < b.key ? -1 : 1))
5360
const visibleItemProperties = allItemProperties.slice(0, maxPropertiesCount)
5461

5562
const handleMorePropertiesClick = (numMore: number) => {

src/neo4j-arc/graph-visualization/models/Node.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export type NodeCaptionLine = {
3030

3131
export class NodeModel {
3232
id: string
33+
elementId: string
3334
labels: string[]
3435
propertyList: VizItemProperty[]
3536
propertyMap: NodeProperties
@@ -55,7 +56,8 @@ export class NodeModel {
5556
id: string,
5657
labels: string[],
5758
properties: NodeProperties,
58-
propertyTypes: Record<string, string>
59+
propertyTypes: Record<string, string>,
60+
elementId: string
5961
) {
6062
this.id = id
6163
this.labels = labels
@@ -76,6 +78,7 @@ export class NodeModel {
7678
this.y = 0
7779
this.hoverFixed = false
7880
this.initialPositionCalculated = false
81+
this.elementId = elementId
7982
}
8083

8184
toJSON(): NodeProperties {

0 commit comments

Comments
 (0)