Skip to content

Commit 543503a

Browse files
authored
Fix/mouse over link highlight (#75)
* Assure that node.id is passed as string to buildNodeProps * Add test for mouse over link
1 parent ee6c27a commit 543503a

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

cypress/integration/link.e2e.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,43 @@ describe('[rd3g-graph] link tests', function() {
146146
this.link34PO.shouldHaveColor('blue');
147147
});
148148
});
149+
150+
describe('when mouse is over some link', function() {
151+
beforeEach(function() {
152+
// small hack to disable any previous highlight behavior
153+
this.sandboxPO.fullScreenMode().click();
154+
});
155+
156+
it('should highlight the link and the intervening nodes', function() {
157+
// mouse over link between nodes 1 and 4
158+
// should highlight nodes 1 and 4 as well as they're connection
159+
this.link14PO
160+
.getLine()
161+
.click()
162+
.trigger('mouseover');
163+
164+
this.node1PO.getColor().should('eq', 'red');
165+
this.node1PO.getFontWeight().should('eq', 'bold');
166+
167+
this.node2PO.getColor().should('eq', '#d3d3d3');
168+
this.node2PO.getOpacity().should('eq', '0.2');
169+
170+
this.node3PO.getColor().should('eq', '#d3d3d3');
171+
this.node3PO.getOpacity().should('eq', '0.2');
172+
173+
this.node4PO.getColor().should('eq', 'red');
174+
this.node4PO.getFontWeight().should('eq', 'bold');
175+
176+
this.link12PO.shouldHaveColor('rgb(211, 211, 211)');
177+
this.link12PO.shouldHaveOpacity(0.2);
178+
179+
this.link13PO.shouldHaveColor('rgb(211, 211, 211)');
180+
this.link13PO.shouldHaveOpacity(0.2);
181+
182+
this.link14PO.shouldHaveColor('blue');
183+
184+
this.link34PO.shouldHaveColor('rgb(211, 211, 211)');
185+
this.link34PO.shouldHaveOpacity(0.2);
186+
});
187+
});
149188
});

cypress/page-objects/sandbox.po.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function SandboxPO() {
99
this.checkboxes = ['node.renderLabel', 'staticGraph'];
1010

1111
// actions
12+
this.fullScreenMode = () => cy.get('.container__graph > :nth-child(1) > :nth-child(1)');
1213
this.playGraph = () => cy.get('.container__graph > :nth-child(1) > :nth-child(2)').click();
1314
this.pauseGraph = () => cy.get('.container__graph > :nth-child(1) > :nth-child(3)').click();
1415
this.addNode = () => cy.get('.container__graph > :nth-child(1) > :nth-child(5)').click();

src/components/graph/graph.renderer.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ function _buildLinks(nodes, links, linksMatrix, config, linkCallbacks, highlight
6262
*/
6363
function _buildNodes(nodes, nodeCallbacks, config, highlightedNode, highlightedLink, transform) {
6464
return Object.keys(nodes).map(nodeId => {
65-
const props = buildNodeProps(nodes[nodeId], config, nodeCallbacks, highlightedNode, highlightedLink, transform);
65+
const props = buildNodeProps(
66+
Object.assign({}, nodes[nodeId], { id: `${nodeId}` }),
67+
config,
68+
nodeCallbacks,
69+
highlightedNode,
70+
highlightedLink,
71+
transform
72+
);
6673

6774
return <Node key={nodeId} {...props} />;
6875
});

0 commit comments

Comments
 (0)