diff --git a/src/res/config.template.js.ejs b/src/res/config.template.js.ejs index 504256a..695dd57 100644 --- a/src/res/config.template.js.ejs +++ b/src/res/config.template.js.ejs @@ -42,7 +42,7 @@ var config = require('webgme/config/config.default'), <%= routers.map(function(router) { return [ - 'config.rest[\'' + router.name + '\'] = {', + 'config.rest.components[\'' + router.name + '\'] = {', ' src: __dirname + \'/../' + router.srcFile + '\',', ' mount: \'' + router.mount + '\',', ' options: {}', diff --git a/test/layout.spec.js b/test/layout.spec.js index e755801..854e2a3 100644 --- a/test/layout.spec.js +++ b/test/layout.spec.js @@ -66,10 +66,11 @@ describe('Layout tests', function() { }); it('should add the layout (relative) path to the config file', function() { - var config = require(path.join(PROJECT_DIR, WebGMEConfig)); - // check that basePath has been added! - var relativeBase = LayoutBasePath.replace(PROJECT_DIR+path.sep, ''); - assert.notEqual(config.visualization.layout.basePaths.indexOf(relativeBase), -1); + const config = require(path.join(PROJECT_DIR, WebGMEConfig)); + const layoutPaths = config.visualization.layout.basePaths.map(dir => path.resolve(dir)); + const layoutDir = path.resolve(LayoutBasePath); + + assert(layoutPaths.includes(layoutDir)); }); it('should record the layout in webgme-setup.json', function() { diff --git a/test/res/BasicProject/config/config.webgme.js b/test/res/BasicProject/config/config.webgme.js index 4b87824..34c2553 100644 --- a/test/res/BasicProject/config/config.webgme.js +++ b/test/res/BasicProject/config/config.webgme.js @@ -7,24 +7,29 @@ var config = require('webgme/config/config.default'), validateConfig = require('webgme/config/validator'); // The paths can be loaded from the webgme-setup.json -config.plugin.basePaths.push('src/plugins'); -config.addOn.basePaths.push('src/addOns/MyAddon'); -config.visualization.layout.basePaths.push('src/layouts'); -config.seedProjects.basePaths.push('src/seeds/test'); +config.plugin.basePaths.push(__dirname + '/../src/plugins'); +config.addOn.basePaths.push(__dirname + '/../src/addOns/MyAddon'); +config.visualization.layout.basePaths.push(__dirname + '/../src/layouts'); +config.seedProjects.basePaths.push(__dirname + '/../src/seeds/test'); config.addOn.enable = true; -config.visualization.panelPaths.push('src/visualizers/panels'); +config.visualization.panelPaths.push(__dirname + '/../src/visualizers/panels'); -config.rest.components['routers/MyRouter'] = __dirname + '/../src/routers/MyRouter/MyRouter.js' +config.rest.components['MyRouter'] = { + src: __dirname + '/../src/routers/MyRouter/MyRouter.js', + mount: 'routers/MyRouter', + options: {} +}; // Visualizer descriptors -config.visualization.visualizerDescriptors.push('./src/visualizers/Visualizers.json'); +config.visualization.visualizerDescriptors.push(__dirname + '/../src/visualizers/Visualizers.json'); // Add requirejs paths config.requirejsPaths = { 'panels': './src/visualizers/panels', - 'widgets': './src/visualizers/widgets' + 'widgets': './src/visualizers/widgets', + 'basicproject': './src/common' }; config.visualization.layout.default = 'EnabledLayout'; diff --git a/test/router.spec.js b/test/router.spec.js index 72a5e5c..404c518 100644 --- a/test/router.spec.js +++ b/test/router.spec.js @@ -68,7 +68,7 @@ describe('Router tests', function() { let routerConfig; before(() => { let gmeConfig = require(`${PROJECT_DIR}/config/config.webgme.js`); - routerConfig = gmeConfig.rest[ROUTER_NAME]; + routerConfig = gmeConfig.rest.components[ROUTER_NAME]; }); it('should update the webgme config', function() { @@ -234,10 +234,10 @@ describe('Router tests', function() { }); it('should add the path to the webgme config', function() { - var config = require(path.join(PROJECT_DIR, WebGMEConfig)), - mntPt = 'other/mount/point'; + const config = require(path.join(PROJECT_DIR, WebGMEConfig)); + const mntPt = 'other/mount/point'; - assert.equal(config.rest[OTHER_ROUTER].mount, mntPt); + assert.equal(config.rest.components[OTHER_ROUTER].mount, mntPt); }); describe('rm dependency router', function() { diff --git a/test/visualizers.spec.js b/test/visualizers.spec.js index ff967bf..0fc42c8 100644 --- a/test/visualizers.spec.js +++ b/test/visualizers.spec.js @@ -66,7 +66,10 @@ describe('Viz tests', function() { before(function(done) { process.chdir(PROJECT_DIR); // Start in different directory manager.new({visualizerID: NEW_VIZ}, function() { - utils.requireReload(path.join(VizBasePath, 'Visualizers.json')); + utils.requireReload( + path.join(VizBasePath, 'Visualizers.json'), + path.join(PROJECT_DIR, WebGMEConfig) + ); done(); }); }); @@ -76,8 +79,10 @@ describe('Viz tests', function() { }); it('should add panelPaths', function() { - var config = require(path.join(PROJECT_DIR, WebGMEConfig)); - assert.notEqual(config.visualization.panelPaths.indexOf('src/visualizers/panels'), -1); + const config = require(path.join(PROJECT_DIR, WebGMEConfig)); + const localPanelPath = config.visualization.panelPaths + .find(panelPath => panelPath.includes('src/visualizers/panels')) + assert(localPanelPath); }); it('should add panels and widgets to requirejsPaths', function() { @@ -87,11 +92,12 @@ describe('Viz tests', function() { }); it('should add Visualizers.json to config.webgme.js', function() { - var config = require(path.join(PROJECT_DIR, WebGMEConfig)), - index = config.visualization.visualizerDescriptors - .indexOf('./src/visualizers/Visualizers.json'); + console.log(fse.readFileSync(path.join(PROJECT_DIR, WebGMEConfig), 'utf8')); + const config = require(path.join(PROJECT_DIR, WebGMEConfig)); + const localVisJson = config.visualization.visualizerDescriptors + .find(desc => desc.includes('./src/visualizers/Visualizers.json')); - assert.notEqual(index, -1); + assert(localVisJson); }); it('should add the viz (relative) path to the Visualizers.json', function() {