Skip to content

Commit

Permalink
Fix/allow custom properties to pass on update for links (#220)
Browse files Browse the repository at this point in the history
* Remove hardcoded restrictions of node and links whitelists in graph.helper

* Rename map link function to merge link

* Re-add node props whitelist to avoid regression on change node props

* Pick link source and target for detecting changes

* Improve e2e tests for link properties changed

* Use a LINK_PROPS_WHITELIST same pattern as for nodes to allow customProps to flow

* Use object spread in favour of Object.assign

* Add babel transform-object-rest-spread plugin

* Update cypress to latest version 3.4.1 and fix e2e link tests

* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps

* Falsy edge case on checking state.config.directed property

* Add project path to cypress binary in node_modules

* Revert "Add project path to cypress binary in node_modules"

This reverts commit ceb674e.
  • Loading branch information
danielcaldas authored Sep 5, 2019
1 parent ca581d9 commit 8c6fff3
Show file tree
Hide file tree
Showing 10 changed files with 13,646 additions and 10,663 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["react", "es2015", "stage-2"]
"presets": ["react", "es2015", "stage-2"],
"plugins": ["transform-object-rest-spread"]
}
2 changes: 1 addition & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"videoRecording": false
"video": false
}
15 changes: 15 additions & 0 deletions cypress/integration/graph.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ describe("[rd3g-graph] graph tests", function() {

nodePO.getColor().should("eq", "red");

// again click (+) add prop to 1st node
this.sandboxPO.addJsonTreeFirstNodeProp();

// edit color
cy.get('[placeholder="Key"]')
.clear()
.type("color");

// edit color to yellow and press ENTER
cy.get('[placeholder="Value"]')
.clear()
.type("yellow{enter}");

nodePO.getColor().should("eq", "yellow");

// delete created prop
this.sandboxPO.deleteJsonTreeFirstNodeProp();

Expand Down
45 changes: 45 additions & 0 deletions cypress/integration/link.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ describe("[rd3g-link] link tests", function() {
this.sandboxPO.fullScreenMode().click();
});

afterEach(function() {
this.sandboxPO.exitFullScreenMode();
});

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
Expand Down Expand Up @@ -200,6 +204,47 @@ describe("[rd3g-link] link tests", function() {

this.link34PO.shouldHaveColor("rgb(211, 211, 211)");
this.link34PO.shouldHaveOpacity(0.2);

// clean
this.link14PO
.getLine()
.click()
.trigger("mouseout");
});
});

describe("when changing link props", function() {
it("should properly update link color", function() {
this.sandboxPO.jsonTreeExpandLinks();
this.sandboxPO.clickJsonTreeFirstLink();

this.sandboxPO.addJsonTreeFirstLinkProp();

// prop name be color
cy.get('[placeholder="Key"]')
.clear()
.type("color");
// prop value be red and press ENTER
cy.get('[placeholder="Value"]')
.clear()
.type("red{enter}");

this.sandboxPO.addJsonTreeFirstLinkProp();

// prop name be color
cy.get('[placeholder="Key"]')
.clear()
.type("color");
// prop value be red and press ENTER
cy.get('[placeholder="Value"]')
.clear()
.type("blue{enter}");

this.link12PO.shouldHaveColor("blue");

this.sandboxPO.deleteJsonTreeLastLinkProp();

this.link12PO.shouldHaveColor("rgb(211, 211, 211)");
});
});
});
21 changes: 21 additions & 0 deletions cypress/page-objects/sandbox.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function SandboxPO() {

// actions
this.fullScreenMode = () => cy.get(".container__graph > :nth-child(1) > :nth-child(1)");
this.exitFullScreenMode = () => cy.get(".cross-icon").click();
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 All @@ -31,6 +32,26 @@ function SandboxPO() {
cy.get(":nth-child(2) > :nth-child(1) > .rejt-not-collapsed > :nth-child(4) > .rejt-plus-menu").click();
this.deleteJsonTreeFirstNodeProp = () =>
cy.get(".rejt-not-collapsed-list > :nth-child(2) > .rejt-minus-menu").click();
this.jsonTreeExpandLinks = () =>
cy
.get(
".rejt-tree > :nth-child(1) > :nth-child(2) > :nth-child(2) > :nth-child(1) > :nth-child(1) > .rejt-name"
)
.click();
this.clickJsonTreeFirstLink = () =>
cy
.get(
":nth-child(2) > :nth-child(1) > :nth-child(2) > :nth-child(2) > :nth-child(1) > :nth-child(1) > .rejt-name"
)
.click();
this.addJsonTreeFirstLinkProp = () =>
cy
.get(
":nth-child(2) > :nth-child(1) > :nth-child(2) > :nth-child(2) > :nth-child(1) > .rejt-not-collapsed > :nth-child(4) > .rejt-plus-menu"
)
.click();
this.deleteJsonTreeLastLinkProp = () =>
cy.get(".rejt-not-collapsed-list > :nth-child(4) > .rejt-minus-menu").click();

// element getters
this.getFieldInput = field =>
Expand Down
Loading

0 comments on commit 8c6fff3

Please sign in to comment.