forked from neo4j/neo4j-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NodeInspectorPanel shows by default but can be turned-off by option (#21
) * NodeInspectorPanel shows by default but can be turned-off by option * Fix test * Version bump * Self-review: add documentation
- Loading branch information
Showing
5 changed files
with
173 additions
and
39 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
125 changes: 125 additions & 0 deletions
125
src/neo4j-arc/graph-visualization/GraphVisualizer/GraphVisualizer.test.tsx
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,125 @@ | ||
/* | ||
* Copyright (c) Jiaqi Liu | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { render, screen } from '@testing-library/react' | ||
import React from 'react' | ||
|
||
import { BasicNode, BasicRelationship } from 'neo4j-arc/common' | ||
import { GraphVisualizer } from 'neo4j-arc/graph-visualization' | ||
|
||
describe('<GraphVisualizer />', () => { | ||
const isFullscreen = true | ||
const nodes: BasicNode[] = [ | ||
{ | ||
id: '1', | ||
labels: ['Person'], | ||
properties: { | ||
name: 'Jack', | ||
age: '20' | ||
}, | ||
propertyTypes: { | ||
name: 'string', | ||
age: 'number' | ||
} | ||
}, | ||
{ | ||
id: '2', | ||
labels: ['React'], | ||
properties: { | ||
name: 'ReactJS' | ||
}, | ||
propertyTypes: { | ||
name: 'string' | ||
} | ||
} | ||
] | ||
const links: BasicRelationship[] = [ | ||
{ | ||
id: '3', | ||
startNodeId: '1', | ||
endNodeId: '2', | ||
type: 'likes', | ||
properties: {}, | ||
propertyTypes: {} | ||
} | ||
] | ||
|
||
type RenderComponentProps = { | ||
showNodeInspectorPanel?: boolean | ||
} | ||
|
||
const renderComponent = ({ | ||
showNodeInspectorPanel = true | ||
}: RenderComponentProps) => { | ||
if (showNodeInspectorPanel) { | ||
// we never pass showNodeInspectorPanel in this case to test the "default behavior" | ||
return render( | ||
<GraphVisualizer | ||
maxNeighbours={100} | ||
hasTruncatedFields={false} | ||
nodes={nodes} | ||
autocompleteRelationships={true} // "true" prevents "undefined (reading 'baseVal')" test error | ||
relationships={links} | ||
isFullscreen={isFullscreen} | ||
nodeLimitHit={false} | ||
getAutoCompleteCallback={undefined} | ||
wheelZoomRequiresModKey={!isFullscreen} | ||
wheelZoomInfoMessageEnabled={false} | ||
useGeneratedDefaultColors={false} | ||
initialZoomToFit={false} | ||
/> | ||
) | ||
} | ||
|
||
return render( | ||
<GraphVisualizer | ||
maxNeighbours={100} | ||
hasTruncatedFields={false} | ||
nodes={nodes} | ||
autocompleteRelationships={true} | ||
relationships={links} | ||
isFullscreen={isFullscreen} | ||
nodeLimitHit={false} | ||
getAutoCompleteCallback={undefined} | ||
wheelZoomRequiresModKey={!isFullscreen} | ||
wheelZoomInfoMessageEnabled={false} | ||
useGeneratedDefaultColors={false} | ||
initialZoomToFit={false} | ||
showNodeInspectorPanel={false} | ||
/> | ||
) | ||
} | ||
|
||
test('should render NodeInspectorPanel by default', async () => { | ||
renderComponent({}) | ||
|
||
expect( | ||
screen.getByRole('button', { | ||
name: 'Collapse the node properties display' | ||
}) | ||
).toBeInTheDocument() | ||
}) | ||
|
||
test('should not render NodeInspectorPanel if explicitly being turned off', async () => { | ||
renderComponent({ showNodeInspectorPanel: false }) | ||
|
||
expect( | ||
screen.queryByRole('button', { | ||
name: 'Collapse the node properties display' | ||
}) | ||
).toBeNull() | ||
}) | ||
}) |
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