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 606efe26fe1decd5d9269d63d5b649441ba2203b.

* 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
isekai-main
Barış Soner Uşaklı 3 years ago committed by GitHub
parent 67cb249122
commit d27c9696e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,7 +21,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [12, 14]
node: [12, 14, 16]
database: [mongo-dev, mongo, redis, postgres]
include:
# only run coverage once

@ -14,6 +14,10 @@ function forkChild(message, callback) {
child.on('message', (msg) => {
callback(msg.err ? new Error(msg.err) : null, msg.result);
});
child.on('error', (err) => {
console.error(err.stack);
callback(err);
});
child.send(message);
}

@ -1,6 +1,5 @@
'use strict';
const { execSync } = require('child_process');
const path = require('path');
const { readFileSync } = require('fs');
@ -9,12 +8,14 @@ const assert = require('assert');
describe('Package install', () => {
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');
// install an extra package
// chose dotenv because it's a popular package
// and we use nconf instead
execSync('npm install dotenv --save --production');
execSync('npm install dotenv --save');
// assert it saves in package.json
const packageWithExtras = JSON.parse(readFileSync(packageFilePath, 'utf8'));
@ -26,5 +27,6 @@ describe('Package install', () => {
// assert it removed the extra package
const packageCleaned = JSON.parse(readFileSync(packageFilePath, 'utf8'));
assert(!packageCleaned.dependencies.dotenv, 'dependency was not removed');
process.env.NODE_ENV = oldValue;
});
});

@ -1,7 +1,6 @@
'use strict';
const assert = require('assert');
const assert = require('assert');
const path = require('path');
const nconf = require('nconf');
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) {
data.foo += 1;
callback(null, data);
@ -214,6 +213,16 @@ describe('Plugins', () => {
describe('install/activate/uninstall', () => {
let latest;
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) {
this.timeout(0);
plugins.toggleInstall(pluginName, '1.0.16', (err, pluginData) => {
@ -284,7 +293,8 @@ describe('Plugins', () => {
});
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.equal(res.statusCode, 404);
assert(body);
@ -293,7 +303,8 @@ describe('Plugins', () => {
});
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.equal(res.statusCode, 200);
assert(body);
@ -302,3 +313,5 @@ describe('Plugins', () => {
});
});
});

@ -106,7 +106,12 @@ describe('socket.io', () => {
});
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.equal(result.user.username, 'admin');
assert.equal(result.category.cid, cid);
@ -473,9 +478,17 @@ describe('socket.io', () => {
it('should toggle plugin install', function (done) {
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.equal(data.name, 'nodebb-plugin-location-to-map');
process.env.NODE_ENV = oldValue;
done();
});
});
@ -507,8 +520,16 @@ describe('socket.io', () => {
it('should upgrade plugin', function (done) {
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);
process.env.NODE_ENV = oldValue;
done();
});
});
@ -521,7 +542,13 @@ describe('socket.io', () => {
});
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) => {
assert.ifError(err);
db.getObjectField('widgets:global', 'sidebar', (err, widgetData) => {

Loading…
Cancel
Save