Skip to content

Commit

Permalink
Fix/mouse over link highlight (#75)
Browse files Browse the repository at this point in the history
* Assure that node.id is passed as string to buildNodeProps

* Add test for mouse over link
  • Loading branch information
danielcaldas committed May 13, 2018
1 parent ee6c27a commit 543503a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
39 changes: 39 additions & 0 deletions cypress/integration/link.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,43 @@ describe('[rd3g-graph] link tests', function() {
this.link34PO.shouldHaveColor('blue');
});
});

describe('when mouse is over some link', function() {
beforeEach(function() {
// small hack to disable any previous highlight behavior
this.sandboxPO.fullScreenMode().click();
});

it('should highlight the link and the intervening nodes', function() {
// mouse over link between nodes 1 and 4
// should highlight nodes 1 and 4 as well as they're connection
this.link14PO
.getLine()
.click()
.trigger('mouseover');

this.node1PO.getColor().should('eq', 'red');
this.node1PO.getFontWeight().should('eq', 'bold');

this.node2PO.getColor().should('eq', '#d3d3d3');
this.node2PO.getOpacity().should('eq', '0.2');

this.node3PO.getColor().should('eq', '#d3d3d3');
this.node3PO.getOpacity().should('eq', '0.2');

this.node4PO.getColor().should('eq', 'red');
this.node4PO.getFontWeight().should('eq', 'bold');

this.link12PO.shouldHaveColor('rgb(211, 211, 211)');
this.link12PO.shouldHaveOpacity(0.2);

this.link13PO.shouldHaveColor('rgb(211, 211, 211)');
this.link13PO.shouldHaveOpacity(0.2);

this.link14PO.shouldHaveColor('blue');

this.link34PO.shouldHaveColor('rgb(211, 211, 211)');
this.link34PO.shouldHaveOpacity(0.2);
});
});
});
1 change: 1 addition & 0 deletions cypress/page-objects/sandbox.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function SandboxPO() {
this.checkboxes = ['node.renderLabel', 'staticGraph'];

// actions
this.fullScreenMode = () => cy.get('.container__graph > :nth-child(1) > :nth-child(1)');
this.playGraph = () => cy.get('.container__graph > :nth-child(1) > :nth-child(2)').click();
this.pauseGraph = () => cy.get('.container__graph > :nth-child(1) > :nth-child(3)').click();
this.addNode = () => cy.get('.container__graph > :nth-child(1) > :nth-child(5)').click();
Expand Down
9 changes: 8 additions & 1 deletion src/components/graph/graph.renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ function _buildLinks(nodes, links, linksMatrix, config, linkCallbacks, highlight
*/
function _buildNodes(nodes, nodeCallbacks, config, highlightedNode, highlightedLink, transform) {
return Object.keys(nodes).map(nodeId => {
const props = buildNodeProps(nodes[nodeId], config, nodeCallbacks, highlightedNode, highlightedLink, transform);
const props = buildNodeProps(
Object.assign({}, nodes[nodeId], { id: `${nodeId}` }),
config,
nodeCallbacks,
highlightedNode,
highlightedLink,
transform
);

return <Node key={nodeId} {...props} />;
});
Expand Down

0 comments on commit 543503a

Please sign in to comment.