Allows flows to be enabled/disabled in the runtime

This commit is contained in:
Nick O'Leary
2017-03-06 15:23:31 +00:00
parent 17e092afb3
commit 7698990e37
3 changed files with 140 additions and 51 deletions

View File

@@ -643,5 +643,59 @@ describe('flows/util', function() {
diffResult.rewired.should.have.length(0);
diffResult.linked.sort().should.eql(["1","3"]);
});
it('ignores tab changes that are immaterial', function() {
var config = [{id:"1",type:"tab",label:"fred"},{id:"2",type:"test",bar:"b",wires:[["1"]],z:"1"}];
var newConfig = clone(config);
newConfig[0].label = "barney";
var originalConfig = flowUtil.parseConfig(config);
var changedConfig = flowUtil.parseConfig(newConfig);
originalConfig.missingTypes.should.have.length(0);
var diffResult = flowUtil.diffConfigs(originalConfig,changedConfig);
diffResult.added.should.have.length(0);
diffResult.changed.should.have.length(0);
diffResult.removed.should.have.length(0);
diffResult.rewired.should.have.length(0);
});
it('marks all nodes as added when tab state changes disabled to enabled', function() {
var config = [{id:"1",type:"tab",disabled:true,label:"fred"},{id:"2",type:"test",bar:"b",wires:[["1"]],z:"1"},{id:"3",type:"test"}];
var newConfig = clone(config);
newConfig[0].disabled = false;
var originalConfig = flowUtil.parseConfig(config);
var changedConfig = flowUtil.parseConfig(newConfig);
originalConfig.missingTypes.should.have.length(0);
var diffResult = flowUtil.diffConfigs(originalConfig,changedConfig);
diffResult.added.should.have.length(2);
diffResult.added.sort().should.eql(["1","2"]);
diffResult.changed.should.have.length(0);
diffResult.removed.should.have.length(0);
diffResult.rewired.should.have.length(0);
});
it('marks all nodes as removed when tab state changes enabled to disabled', function() {
var config = [{id:"1",type:"tab",disabled:false,label:"fred"},{id:"2",type:"test",bar:"b",wires:[["1"]],z:"1"},{id:"3",type:"test"}];
var newConfig = clone(config);
newConfig[0].disabled = true;
var originalConfig = flowUtil.parseConfig(config);
var changedConfig = flowUtil.parseConfig(newConfig);
originalConfig.missingTypes.should.have.length(0);
var diffResult = flowUtil.diffConfigs(originalConfig,changedConfig);
diffResult.added.should.have.length(0);
diffResult.changed.should.have.length(0);
diffResult.removed.should.have.length(2);
diffResult.removed.sort().should.eql(["1","2"]);
diffResult.rewired.should.have.length(0);
});
});
});