Skip to content

Commit

Permalink
Complete E2E tests on on-canvas & node inspector panel editing
Browse files Browse the repository at this point in the history
  • Loading branch information
QubitPi committed Dec 8, 2023
1 parent 261d3dc commit a04a66d
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 14 deletions.
10 changes: 9 additions & 1 deletion docs/modules/ROOT/pages/operations/on-canvas-operations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ image:modifying-node-label-example.png[width=600]
== Creating On-Canvas Relationships

Alt-clicking one node, release the alk key, and alt-clicking another node will create a relationship between the two


== Editing the Relationshiop Type and Properties in Node Inspection Panel

[NOTE]
====
Make sure APOC plugin is enabled in Neo4J database:
image:enable-apoc.png[width=600]
====
71 changes: 70 additions & 1 deletion e2e_tests/integration/node-inspection-panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Node Inspection Panel rendering', () => {
.contains('My Node')
})

it('details pane title should be editable', () => {
it('details pane title should be editable and pressing enter does not insert a line break at the end of new title', () => {
cy.executeCommand(':clear')
cy.executeCommand(`CREATE (s:SourceNode {name: 'My Node'}) RETURN s`, {
parseSpecialCharSequences: false
Expand All @@ -65,5 +65,74 @@ describe('Node Inspection Panel rendering', () => {
.trigger('mouseenter', { force: true })
.get('[data-testid="viz-details-pane-title"]')
.contains('New Title')
.should(title => {
expect(title.text()).to.equal('New Title')
})
})

it('can directly modify node label in node inspector panel and pressing enter does not insert a line break at the end of new label', () => {
cy.executeCommand(':clear')
cy.executeCommand(`CREATE (a:TestLabel {name: 'testNode'}) RETURN a`, {
parseSpecialCharSequences: false
})

cy.get(`[aria-label^="graph-node"]`)
.first()
.trigger('mouseover', { force: true })
.trigger('mouseenter', { force: true })
.trigger('click', { force: true })
.get('[data-testid="styleable-node-label"]', { timeout: 5000 })
.clear()
.type('New Label{enter}', { force: true })
.wait(1500)
.get('[data-testid="styleable-node-label"]', { timeout: 5000 })
.contains('New Label')
.should(label => {
expect(label.text()).to.equal('New Label')
})
})

it('can directly modify relationship type in node inspector panel', () => {
cy.executeCommand(':clear')
cy.executeCommand(
'CREATE (a:TestLabel)-[:CONNECTS]->(b:TestLabel) RETURN a, b'
)
.wait(3000)
.get('.relationship', { timeout: 5000 })
.click(5, 40)
// .trigger('click', { force: true }) clicking on the rel center this way won't work
.get('[data-testid="styleable-rel-type"]', { timeout: 5000 })
.first()
.clear()
.type('New Link Label{enter}', { force: true })
.wait(1500)
.get('[data-testid="styleable-rel-type"]', { timeout: 5000 })
.contains('New Link Label')
})

it('can directly modify properties table value and pressing enter does not insert a line break at the end of new value', () => {
cy.executeCommand(':clear')
cy.executeCommand(`CREATE (a:TestLabel {name: 'testNode'}) RETURN a`, {
parseSpecialCharSequences: false
})
.wait(3000)
.get(`[aria-label^="graph-node"]`)
.first()
.trigger('mouseover', { force: true })
.trigger('mouseenter', { force: true })
.trigger('click', { force: true })
.get('[data-testid="properties-table-name-value-cell"]', {
timeout: 5000
})
.clear()
.type('New Name{enter}', { force: true })
.wait(1500)
.get('[data-testid="properties-table-name-value-cell"]', {
timeout: 5000
})
.contains('New Name')
.should(cellValue => {
expect(cellValue.text()).to.equal('New Name')
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function StyleableNodeLabel({

return (
<div
data-testid="styleable-node-label"
suppressContentEditableWarning={true}
contentEditable="true"
onKeyDown={(event: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,26 @@ export function StyleableRelType({
})
return (
<div
data-testid="styleable-rel-type"
suppressContentEditableWarning={true}
contentEditable="true"
onInput={e =>
onGraphInteraction(REL_TYPE_UPDATE, {
relId: relId,
sourceNodeId: sourceNodeId,
targetNodeId: targetNodeId,
oldType: selectedRelType.relType,
newType: e.currentTarget.textContent
})
}
onKeyDown={(event: any) => {
if (event.key == 'Enter') {
event.preventDefault() // prevent new line char on Enter (https://stackoverflow.com/a/60008550)
}
}}
onKeyUp={(event: any) => {
if (event.keyCode === 13) {
event.preventDefault()
onGraphInteraction(REL_TYPE_UPDATE, {
relId: relId,
sourceNodeId: sourceNodeId,
targetNodeId: targetNodeId,
oldType: selectedRelType.relType,
newType: event.currentTarget.textContent
})
}
}}
>
<Popup
on="click"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ LIMIT ${maxNewNeighbours}`
CYPHER_REQUEST,
{
query,
params: { sourceNodeId, targetNodeId, oldType, newType },
params: { type, sourceNodeId, targetNodeId, newType },
queryType: NEO4J_BROWSER_USER_ACTION_QUERY
},
(response: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function ExpandableValue({

return (
<div
data-testid={`properties-table-${propKey}-value-cell`}
suppressContentEditableWarning={true}
contentEditable="true"
onKeyDown={(event: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function DefaultDetailsPane({
}}
graphStyle={graphStyle}
onGraphInteraction={onGraphInteraction}
relId={vizItem.item.id}
sourceNodeId={vizItem.item.source.id}
targetNodeId={vizItem.item.target.id}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type RelTypeProps = {
graphStyle: GraphStyleModel
selectedRelType: { relType: string; propertyKeys: string[]; count?: number }
onGraphInteraction?: GraphInteractionCallBack
relId?: string
sourceNodeId?: string
targetNodeId?: string
}
Expand All @@ -40,6 +41,7 @@ export function RelType({
selectedRelType,
graphStyle,
onGraphInteraction = () => undefined,
relId,
sourceNodeId,
targetNodeId
}: RelTypeProps): JSX.Element {
Expand All @@ -59,6 +61,7 @@ export function RelType({
if (event.keyCode === 13) {
event.preventDefault()
onGraphInteraction(REL_TYPE_UPDATE, {
relId: relId,
sourceNodeId: sourceNodeId,
targetNodeId: targetNodeId,
oldType: selectedRelType.relType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export type GraphInteraction =
| 'NODE_UNPINNED'
| 'NODE_DISMISSED'
| typeof NODE_ON_CANVAS_CREATE
| typeof NODE_LABEL_UPDATE
| typeof REL_ON_CANVAS_CREATE
| typeof NODE_LABEL_UPDATE
| typeof REL_TYPE_UPDATE
| typeof PROP_UPDATE
| typeof DETAILS_PANE_TITLE_UPDATE
Expand Down
2 changes: 1 addition & 1 deletion src/neo4j-arc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neo4j-devtools-arc",
"version": "0.0.79",
"version": "0.0.80",
"main": "dist/neo4j-arc.js",
"author": "Neo4j Inc.",
"license": "GPL-3.0",
Expand Down

0 comments on commit a04a66d

Please sign in to comment.