From a0489f2a0de99d31e2258782b43ee52dc4dc55ab Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 21 Feb 2018 08:38:36 -0800 Subject: [PATCH] Fix tests for existing file flag in settings --- test/red/api/editor/settings_spec.js | 80 ++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/test/red/api/editor/settings_spec.js b/test/red/api/editor/settings_spec.js index 826a5bcef..6f3089cf9 100644 --- a/test/red/api/editor/settings_spec.js +++ b/test/red/api/editor/settings_spec.js @@ -104,6 +104,46 @@ describe("api/editor/settings", function() { return done(err); } res.body.should.have.property("project","test-active-project"); + res.body.should.not.have.property("files"); + res.body.should.have.property("git"); + res.body.git.should.have.property("globalUser",{name:'foo',email:'foo@example.com'}); + done(); + }); + }); + it('includes existing files details if projects enabled but no active project and files exist', function(done) { + info.init({ + settings: { + foo: 123, + httpNodeRoot: "testHttpNodeRoot", + version: "testVersion", + paletteCategories :["red","blue","green"], + exportNodeSettings: function(obj) { + obj.testNodeSetting = "helloWorld"; + } + }, + nodes: { + paletteEditorEnabled: function() { return true; }, + getCredentialKeyType: function() { return "test-key-type"} + }, + log: { error: console.error }, + storage: { + projects: { + flowFileExists: () => true, + getActiveProject: () => false, + getFlowFilename: () => 'test-flow-file', + getCredentialsFilename: () => 'test-creds-file', + getGlobalGitUser: () => {return {name:'foo',email:'foo@example.com'}} + } + } + }); + request(app) + .get("/settings") + .expect(200) + .end(function(err,res) { + if (err) { + return done(err); + } + res.body.should.not.have.property("project"); res.body.should.have.property("files"); res.body.files.should.have.property("flow",'test-flow-file'); res.body.files.should.have.property("credentials",'test-creds-file'); @@ -112,6 +152,46 @@ describe("api/editor/settings", function() { done(); }); }); + it('does not include file details if projects enabled but no active project and files do not exist', function(done) { + info.init({ + settings: { + foo: 123, + httpNodeRoot: "testHttpNodeRoot", + version: "testVersion", + paletteCategories :["red","blue","green"], + exportNodeSettings: function(obj) { + obj.testNodeSetting = "helloWorld"; + } + }, + nodes: { + paletteEditorEnabled: function() { return true; }, + getCredentialKeyType: function() { return "test-key-type"} + }, + log: { error: console.error }, + storage: { + projects: { + flowFileExists: () => false, + getActiveProject: () => false, + getFlowFilename: () => 'test-flow-file', + getCredentialsFilename: () => 'test-creds-file', + getGlobalGitUser: () => {return {name:'foo',email:'foo@example.com'}} + } + } + }); + request(app) + .get("/settings") + .expect(200) + .end(function(err,res) { + if (err) { + return done(err); + } + res.body.should.not.have.property("project"); + res.body.should.not.have.property("files"); + res.body.should.have.property("git"); + res.body.git.should.have.property("globalUser",{name:'foo',email:'foo@example.com'}); + done(); + }); + }); it('overrides palette editable if runtime says it is disabled', function(done) { info.init({ settings: {