mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
ensure link-call cache is updated when link-in is modified
fixes #3694 depends on node-red-node-test-helper@0.3.0
This commit is contained in:
parent
fc5a5f1b73
commit
9729c89f5d
@ -111,7 +111,7 @@
|
|||||||
"marked": "4.0.17",
|
"marked": "4.0.17",
|
||||||
"minami": "1.2.3",
|
"minami": "1.2.3",
|
||||||
"mocha": "9.2.2",
|
"mocha": "9.2.2",
|
||||||
"node-red-node-test-helper": "^0.2.7",
|
"node-red-node-test-helper": "^0.3.0",
|
||||||
"nodemon": "2.0.16",
|
"nodemon": "2.0.16",
|
||||||
"proxy": "^1.0.2",
|
"proxy": "^1.0.2",
|
||||||
"sass": "1.52.3",
|
"sass": "1.52.3",
|
||||||
|
@ -109,16 +109,13 @@ module.exports = function(RED) {
|
|||||||
},
|
},
|
||||||
remove(node) {
|
remove(node) {
|
||||||
const target = generateTarget(node);
|
const target = generateTarget(node);
|
||||||
const tn = this.getTarget(target.name, target.flowId);
|
const targs = this.getTargets(target.name);
|
||||||
if (tn) {
|
const idx = getIndex(targs, target.id);
|
||||||
const targs = this.getTargets(tn.name);
|
if (idx > -1) {
|
||||||
const idx = getIndex(targs, tn.id);
|
targs.splice(idx, 1);
|
||||||
if (idx > -1) {
|
}
|
||||||
targs.splice(idx, 1);
|
if (targs.length === 0) {
|
||||||
}
|
delete registry.name[tn.name];
|
||||||
if (targs.length === 0) {
|
|
||||||
delete registry.name[tn.name];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
delete registry.id[target.id];
|
delete registry.id[target.id];
|
||||||
},
|
},
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
var should = require("should");
|
var should = require("should");
|
||||||
var linkNode = require("nr-test-utils").require("@node-red/nodes/core/common/60-link.js");
|
var linkNode = require("nr-test-utils").require("@node-red/nodes/core/common/60-link.js");
|
||||||
var helper = require("node-red-node-test-helper");
|
var helper = require("node-red-node-test-helper");
|
||||||
|
var clone = require("clone");
|
||||||
|
|
||||||
describe('link Node', function() {
|
describe('link Node', function() {
|
||||||
|
|
||||||
@ -319,6 +320,48 @@ describe('link Node', function() {
|
|||||||
linkCall.receive({ payload: "hello", target: "double payload" });
|
linkCall.receive({ payload: "hello", target: "double payload" });
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
it('should not raise error after deploying a name change to a duplicate link-in node', async function () {
|
||||||
|
this.timeout(400);
|
||||||
|
const flow = [
|
||||||
|
{ id: "tab-flow-1", type: "tab", label: "Flow 1" },
|
||||||
|
{ id: "link-in-1", z: "tab-flow-1", type: "link in", name: "duplicate", wires: [["link-out-1"]] },
|
||||||
|
{ id: "link-in-2", z: "tab-flow-1", type: "link in", name: "duplicate", wires: [["link-out-1"]] }, //duplicate name
|
||||||
|
{ id: "link-out-1", z: "tab-flow-1", type: "link out", mode: "return" },
|
||||||
|
{ id: "link-call", z: "tab-flow-1", type: "link call", linkType: "dynamic", links: [], wires: [["n4"]] },
|
||||||
|
{ id: "n4", z: "tab-flow-1", type: "helper" }
|
||||||
|
];
|
||||||
|
|
||||||
|
await helper.load(linkNode, flow)
|
||||||
|
|
||||||
|
const linkIn2before = helper.getNode("link-in-2");
|
||||||
|
linkIn2before.should.have.property("name", "duplicate") // check link-in-2 has been deployed with the duplicate name
|
||||||
|
|
||||||
|
//modify the flow and deploy change
|
||||||
|
const newConfig = clone(flow);
|
||||||
|
newConfig[2].name = "add" // change nodes name
|
||||||
|
await helper.setFlows(newConfig, "nodes") // deploy "nodes" only
|
||||||
|
|
||||||
|
const helperNode = helper.getNode("n4");
|
||||||
|
const linkCall2 = helper.getNode("link-call");
|
||||||
|
const linkIn2after = helper.getNode("link-in-2");
|
||||||
|
linkIn2after.should.have.property("name", "add") // check link-in-2 no longer has a duplicate name
|
||||||
|
|
||||||
|
//poke { payload: "hello", target: "add" } into the link-call node and
|
||||||
|
//ensure that a message arrives via the link-in node named "add"
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
helperNode.on("input", function (msg) {
|
||||||
|
try {
|
||||||
|
msg.should.have.property("target", "add");
|
||||||
|
msg.should.not.have.property("error");
|
||||||
|
resolve()
|
||||||
|
} catch (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
linkCall2.receive({ payload: "hello", target: "add" });
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
it('should allow nested link-call flows', function(done) {
|
it('should allow nested link-call flows', function(done) {
|
||||||
this.timeout(500);
|
this.timeout(500);
|
||||||
var flow = [/** Multiply by 2 link flow **/
|
var flow = [/** Multiply by 2 link flow **/
|
||||||
|
Loading…
Reference in New Issue
Block a user