mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Fix various tests due to projects rework
This commit is contained in:
@@ -47,12 +47,15 @@ describe("api/editor/index", function() {
|
||||
});
|
||||
describe("enables the editor", function() {
|
||||
var mockList = [
|
||||
'library','theme','locales','credentials','comms'
|
||||
'library','theme','locales','credentials','comms',"settings"
|
||||
]
|
||||
var isStarted = true;
|
||||
var errors = [];
|
||||
var session_data = {};
|
||||
before(function() {
|
||||
sinon.stub(auth,'needsPermission',function(permission) {
|
||||
return function(req,res,next) { next(); }
|
||||
});
|
||||
mockList.forEach(function(m) {
|
||||
sinon.stub(require("../../../../red/api/editor/"+m),"init",function(){});
|
||||
});
|
||||
@@ -63,28 +66,10 @@ describe("api/editor/index", function() {
|
||||
require("../../../../red/api/editor/"+m).init.restore();
|
||||
})
|
||||
require("../../../../red/api/editor/theme").app.restore();
|
||||
auth.needsPermission.restore();
|
||||
});
|
||||
|
||||
before(function() {
|
||||
auth.init({
|
||||
settings:{
|
||||
adminAuth: {
|
||||
default: {
|
||||
permissions: ['read']
|
||||
}
|
||||
},
|
||||
storage: {
|
||||
getSessions: function(){
|
||||
return when.resolve(session_data);
|
||||
},
|
||||
setSessions: function(_session) {
|
||||
session_data = _session;
|
||||
return when.resolve();
|
||||
}
|
||||
},
|
||||
log:{audit:function(){},error:function(msg){errors.push(msg)}}
|
||||
}
|
||||
});
|
||||
app = editorApi.init({},{
|
||||
log:{audit:function(){},error:function(msg){errors.push(msg)}},
|
||||
settings:{httpNodeRoot:true, httpAdminRoot: true,disableEditor:false,exportNodeSettings:function(){}},
|
||||
@@ -132,14 +117,14 @@ describe("api/editor/index", function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('GET /settings', function(done) {
|
||||
request(app).get("/settings").expect(200).end(function(err,res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
// permissionChecks.should.have.property('settings.read',1);
|
||||
done();
|
||||
})
|
||||
});
|
||||
// it('GET /settings', function(done) {
|
||||
// request(app).get("/settings").expect(200).end(function(err,res) {
|
||||
// if (err) {
|
||||
// return done(err);
|
||||
// }
|
||||
// // permissionChecks.should.have.property('settings.read',1);
|
||||
// done();
|
||||
// })
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
@@ -48,9 +48,11 @@ describe("api/editor/settings", function() {
|
||||
}
|
||||
},
|
||||
nodes: {
|
||||
paletteEditorEnabled: function() { return true; }
|
||||
paletteEditorEnabled: function() { return true; },
|
||||
getCredentialKeyType: function() { return "test-key-type"}
|
||||
},
|
||||
log: { error: console.error }
|
||||
log: { error: console.error },
|
||||
storage: {}
|
||||
});
|
||||
request(app)
|
||||
.get("/settings")
|
||||
@@ -65,7 +67,45 @@ describe("api/editor/settings", function() {
|
||||
res.body.should.have.property("editorTheme",{test:456});
|
||||
res.body.should.have.property("testNodeSetting","helloWorld");
|
||||
res.body.should.not.have.property("foo",123);
|
||||
|
||||
res.body.should.have.property("flowEncryptionType","test-key-type");
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('includes project settings if projects available', 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: {
|
||||
getActiveProject: () => 'test-active-project',
|
||||
getFlowFilename: () => 'test-flow-file',
|
||||
getCredentialsFilename: () => 'test-creds-file'
|
||||
}
|
||||
}
|
||||
});
|
||||
request(app)
|
||||
.get("/settings")
|
||||
.expect(200)
|
||||
.end(function(err,res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
res.body.should.have.property("project","test-active-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');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -78,9 +118,13 @@ describe("api/editor/settings", function() {
|
||||
exportNodeSettings: function() {}
|
||||
},
|
||||
nodes: {
|
||||
paletteEditorEnabled: function() { return false; }
|
||||
paletteEditorEnabled: function() { return false; },
|
||||
getCredentialKeyType: function() { return "test-key-type"}
|
||||
|
||||
},
|
||||
log: { error: console.error }
|
||||
log: { error: console.error },
|
||||
storage: {}
|
||||
|
||||
});
|
||||
request(app)
|
||||
.get("/settings")
|
||||
|
@@ -73,10 +73,10 @@ describe("api/index", function() {
|
||||
});
|
||||
});
|
||||
after(afterEach);
|
||||
it('exposes the editor',function() {
|
||||
it('exposes the editor',function(done) {
|
||||
request(api.adminApp).get("/editor").expect(200).end(done);
|
||||
})
|
||||
it('exposes the admin api',function() {
|
||||
it('exposes the admin api',function(done) {
|
||||
request(api.adminApp).get("/admin").expect(200).end(done);
|
||||
})
|
||||
it('exposes the auth api',function(done) {
|
||||
@@ -92,10 +92,10 @@ describe("api/index", function() {
|
||||
});
|
||||
});
|
||||
after(afterEach);
|
||||
it('does not expose the editor',function() {
|
||||
it('does not expose the editor',function(done) {
|
||||
request(api.adminApp).get("/editor").expect(404).end(done);
|
||||
})
|
||||
it('exposes the admin api',function() {
|
||||
it('exposes the admin api',function(done) {
|
||||
request(api.adminApp).get("/admin").expect(200).end(done);
|
||||
})
|
||||
it('exposes the auth api',function(done) {
|
||||
|
Reference in New Issue
Block a user