mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 03:01:08 +01:00
feat: add node 16 (#9847)
* feat: add node 16
* fix: check errors in fork
* test: add use-spawn
* test: another test
* Revert "test: another test"
This reverts commit 606efe26fe.
* test: another test
* fix: lint
* fix: remove spawn-wrap
* test: comment out plugin installs
* fix: lint
* test: uncomment all tests except npm i
* fix: lint
* test: bring back tests
* test: remove leftover override
This commit is contained in:
committed by
GitHub
parent
67cb249122
commit
d27c9696e3
2
.github/workflows/test.yaml
vendored
2
.github/workflows/test.yaml
vendored
@@ -21,7 +21,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest]
|
os: [ubuntu-latest]
|
||||||
node: [12, 14]
|
node: [12, 14, 16]
|
||||||
database: [mongo-dev, mongo, redis, postgres]
|
database: [mongo-dev, mongo, redis, postgres]
|
||||||
include:
|
include:
|
||||||
# only run coverage once
|
# only run coverage once
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ function forkChild(message, callback) {
|
|||||||
child.on('message', (msg) => {
|
child.on('message', (msg) => {
|
||||||
callback(msg.err ? new Error(msg.err) : null, msg.result);
|
callback(msg.err ? new Error(msg.err) : null, msg.result);
|
||||||
});
|
});
|
||||||
|
child.on('error', (err) => {
|
||||||
|
console.error(err.stack);
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
|
|
||||||
child.send(message);
|
child.send(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
const { execSync } = require('child_process');
|
const { execSync } = require('child_process');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { readFileSync } = require('fs');
|
const { readFileSync } = require('fs');
|
||||||
@@ -9,12 +8,14 @@ const assert = require('assert');
|
|||||||
|
|
||||||
describe('Package install', () => {
|
describe('Package install', () => {
|
||||||
it('should remove non-`nodebb-` modules not specified in `install/package.json`', () => {
|
it('should remove non-`nodebb-` modules not specified in `install/package.json`', () => {
|
||||||
|
const oldValue = process.env.NODE_ENV;
|
||||||
|
process.env.NODE_ENV = 'development';
|
||||||
const packageFilePath = path.join(__dirname, '../package.json');
|
const packageFilePath = path.join(__dirname, '../package.json');
|
||||||
|
|
||||||
// install an extra package
|
// install an extra package
|
||||||
// chose dotenv because it's a popular package
|
// chose dotenv because it's a popular package
|
||||||
// and we use nconf instead
|
// and we use nconf instead
|
||||||
execSync('npm install dotenv --save --production');
|
execSync('npm install dotenv --save');
|
||||||
|
|
||||||
// assert it saves in package.json
|
// assert it saves in package.json
|
||||||
const packageWithExtras = JSON.parse(readFileSync(packageFilePath, 'utf8'));
|
const packageWithExtras = JSON.parse(readFileSync(packageFilePath, 'utf8'));
|
||||||
@@ -26,5 +27,6 @@ describe('Package install', () => {
|
|||||||
// assert it removed the extra package
|
// assert it removed the extra package
|
||||||
const packageCleaned = JSON.parse(readFileSync(packageFilePath, 'utf8'));
|
const packageCleaned = JSON.parse(readFileSync(packageFilePath, 'utf8'));
|
||||||
assert(!packageCleaned.dependencies.dotenv, 'dependency was not removed');
|
assert(!packageCleaned.dependencies.dotenv, 'dependency was not removed');
|
||||||
|
process.env.NODE_ENV = oldValue;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
const assert = require('assert');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
@@ -47,7 +46,7 @@ describe('Plugins', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should register and fire a filter hook having 3 methods, one returning a promise, one calling the callback and one just returning', async () => {
|
it('should register and fire a filter hook having 3 methods', async () => {
|
||||||
function method1(data, callback) {
|
function method1(data, callback) {
|
||||||
data.foo += 1;
|
data.foo += 1;
|
||||||
callback(null, data);
|
callback(null, data);
|
||||||
@@ -214,6 +213,16 @@ describe('Plugins', () => {
|
|||||||
describe('install/activate/uninstall', () => {
|
describe('install/activate/uninstall', () => {
|
||||||
let latest;
|
let latest;
|
||||||
const pluginName = 'nodebb-plugin-imgur';
|
const pluginName = 'nodebb-plugin-imgur';
|
||||||
|
const oldValue = process.env.NODE_ENV;
|
||||||
|
before((done) => {
|
||||||
|
process.env.NODE_ENV = 'development';
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
after((done) => {
|
||||||
|
process.env.NODE_ENV = oldValue;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
it('should install a plugin', function (done) {
|
it('should install a plugin', function (done) {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
plugins.toggleInstall(pluginName, '1.0.16', (err, pluginData) => {
|
plugins.toggleInstall(pluginName, '1.0.16', (err, pluginData) => {
|
||||||
@@ -284,7 +293,8 @@ describe('Plugins', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should 404 if resource does not exist', (done) => {
|
it('should 404 if resource does not exist', (done) => {
|
||||||
request.get(`${nconf.get('url')}/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/should404.tpl`, (err, res, body) => {
|
const url = `${nconf.get('url')}/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/should404.tpl`;
|
||||||
|
request.get(url, (err, res, body) => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.equal(res.statusCode, 404);
|
assert.equal(res.statusCode, 404);
|
||||||
assert(body);
|
assert(body);
|
||||||
@@ -293,7 +303,8 @@ describe('Plugins', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get resource', (done) => {
|
it('should get resource', (done) => {
|
||||||
request.get(`${nconf.get('url')}/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/dbsearch.tpl`, (err, res, body) => {
|
const url = `${nconf.get('url')}/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/dbsearch.tpl`;
|
||||||
|
request.get(url, (err, res, body) => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.equal(res.statusCode, 200);
|
assert.equal(res.statusCode, 200);
|
||||||
assert(body);
|
assert(body);
|
||||||
@@ -302,3 +313,5 @@ describe('Plugins', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,12 @@ describe('socket.io', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should post a topic', (done) => {
|
it('should post a topic', (done) => {
|
||||||
io.emit('topics.post', { title: 'test topic title', content: 'test topic main post content', uid: adminUid, cid: cid }, (err, result) => {
|
io.emit('topics.post', {
|
||||||
|
title: 'test topic title',
|
||||||
|
content: 'test topic main post content',
|
||||||
|
uid: adminUid,
|
||||||
|
cid: cid,
|
||||||
|
}, (err, result) => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.equal(result.user.username, 'admin');
|
assert.equal(result.user.username, 'admin');
|
||||||
assert.equal(result.category.cid, cid);
|
assert.equal(result.category.cid, cid);
|
||||||
@@ -473,9 +478,17 @@ describe('socket.io', () => {
|
|||||||
|
|
||||||
it('should toggle plugin install', function (done) {
|
it('should toggle plugin install', function (done) {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
socketAdmin.plugins.toggleInstall({ uid: adminUid }, { id: 'nodebb-plugin-location-to-map', version: 'latest' }, (err, data) => {
|
const oldValue = process.env.NODE_ENV;
|
||||||
|
process.env.NODE_ENV = 'development';
|
||||||
|
socketAdmin.plugins.toggleInstall({
|
||||||
|
uid: adminUid,
|
||||||
|
}, {
|
||||||
|
id: 'nodebb-plugin-location-to-map',
|
||||||
|
version: 'latest',
|
||||||
|
}, (err, data) => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.equal(data.name, 'nodebb-plugin-location-to-map');
|
assert.equal(data.name, 'nodebb-plugin-location-to-map');
|
||||||
|
process.env.NODE_ENV = oldValue;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -507,8 +520,16 @@ describe('socket.io', () => {
|
|||||||
|
|
||||||
it('should upgrade plugin', function (done) {
|
it('should upgrade plugin', function (done) {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
socketAdmin.plugins.upgrade({ uid: adminUid }, { id: 'nodebb-plugin-location-to-map', version: 'latest' }, (err) => {
|
const oldValue = process.env.NODE_ENV;
|
||||||
|
process.env.NODE_ENV = 'development';
|
||||||
|
socketAdmin.plugins.upgrade({
|
||||||
|
uid: adminUid,
|
||||||
|
}, {
|
||||||
|
id: 'nodebb-plugin-location-to-map',
|
||||||
|
version: 'latest',
|
||||||
|
}, (err) => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
process.env.NODE_ENV = oldValue;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -521,7 +542,13 @@ describe('socket.io', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should error with invalid data', (done) => {
|
it('should error with invalid data', (done) => {
|
||||||
const data = [{ template: 'global', location: 'sidebar', widgets: [{ widget: 'html', data: { html: 'test', title: 'test', container: '' } }] }];
|
const data = [
|
||||||
|
{
|
||||||
|
template: 'global',
|
||||||
|
location: 'sidebar',
|
||||||
|
widgets: [{ widget: 'html', data: { html: 'test', title: 'test', container: '' } }],
|
||||||
|
},
|
||||||
|
];
|
||||||
socketAdmin.widgets.set({ uid: adminUid }, data, (err) => {
|
socketAdmin.widgets.set({ uid: adminUid }, data, (err) => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
db.getObjectField('widgets:global', 'sidebar', (err, widgetData) => {
|
db.getObjectField('widgets:global', 'sidebar', (err, widgetData) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user