| 
									
										
										
										
											2017-02-18 02:23:47 -07:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-06 13:21:21 -05:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Database Mock - wrapper for database.js, makes system use separate test db, instead of production | 
					
						
							|  |  |  |  * ATTENTION: testing db is flushed before every use! | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-31 07:58:37 -06:00
										 |  |  | require('../../require-main'); | 
					
						
							| 
									
										
										
										
											2018-10-16 13:20:32 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | const path = require('path'); | 
					
						
							|  |  |  | const nconf = require('nconf'); | 
					
						
							|  |  |  | const url = require('url'); | 
					
						
							|  |  |  | const util = require('util'); | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-20 08:55:07 -04:00
										 |  |  | process.env.NODE_ENV = process.env.TEST_ENV || 'production'; | 
					
						
							|  |  |  | global.env = process.env.NODE_ENV || 'production'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-16 13:20:32 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | const winston = require('winston'); | 
					
						
							| 
									
										
										
										
											2021-05-28 12:17:48 -04:00
										 |  |  | const packageInfo = require('../../package.json'); | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-16 13:07:13 -04:00
										 |  |  | winston.add(new winston.transports.Console({ | 
					
						
							|  |  |  | 	format: winston.format.combine( | 
					
						
							|  |  |  | 		winston.format.splat(), | 
					
						
							|  |  |  | 		winston.format.simple() | 
					
						
							|  |  |  | 	), | 
					
						
							|  |  |  | })); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-17 14:47:23 -05:00
										 |  |  | try { | 
					
						
							|  |  |  | 	const fs = require('fs'); | 
					
						
							|  |  |  | 	const configJSON = fs.readFileSync(path.join(__dirname, '../../config.json'), 'utf-8'); | 
					
						
							| 
									
										
										
										
											2022-02-17 15:11:24 -05:00
										 |  |  | 	winston.info('configJSON'); | 
					
						
							|  |  |  | 	winston.info(configJSON); | 
					
						
							| 
									
										
										
										
											2022-02-17 14:47:23 -05:00
										 |  |  | } catch (err) { | 
					
						
							|  |  |  | 	console.error(err.stack); | 
					
						
							|  |  |  | 	throw err; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | nconf.file({ file: path.join(__dirname, '../../config.json') }); | 
					
						
							|  |  |  | nconf.defaults({ | 
					
						
							|  |  |  | 	base_dir: path.join(__dirname, '../..'), | 
					
						
							|  |  |  | 	themes_path: path.join(__dirname, '../../node_modules'), | 
					
						
							| 
									
										
										
										
											2018-01-26 15:50:26 -05:00
										 |  |  | 	upload_path: 'test/uploads', | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 	views_dir: path.join(__dirname, '../../build/public/templates'), | 
					
						
							|  |  |  | 	relative_path: '', | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | const urlObject = url.parse(nconf.get('url')); | 
					
						
							|  |  |  | const relativePath = urlObject.pathname !== '/' ? urlObject.pathname : ''; | 
					
						
							| 
									
										
										
										
											2018-11-30 21:35:57 -05:00
										 |  |  | nconf.set('relative_path', relativePath); | 
					
						
							| 
									
										
										
										
											2022-02-15 19:22:34 -05:00
										 |  |  | nconf.set('asset_base_url', `${relativePath}/assets`); | 
					
						
							| 
									
										
										
										
											2020-10-26 10:43:18 -04:00
										 |  |  | nconf.set('upload_path', path.join(nconf.get('base_dir'), nconf.get('upload_path'))); | 
					
						
							|  |  |  | nconf.set('upload_url', '/assets/uploads'); | 
					
						
							| 
									
										
										
										
											2021-02-07 15:09:52 -05:00
										 |  |  | nconf.set('url_parsed', urlObject); | 
					
						
							| 
									
										
										
										
											2021-02-03 23:59:08 -07:00
										 |  |  | nconf.set('base_url', `${urlObject.protocol}//${urlObject.host}`); | 
					
						
							| 
									
										
										
										
											2021-02-07 15:09:52 -05:00
										 |  |  | nconf.set('secure', urlObject.protocol === 'https:'); | 
					
						
							|  |  |  | nconf.set('use_port', !!urlObject.port); | 
					
						
							|  |  |  | nconf.set('port', urlObject.port || nconf.get('port') || (nconf.get('PORT_ENV_VAR') ? nconf.get(nconf.get('PORT_ENV_VAR')) : false) || 4567); | 
					
						
							| 
									
										
										
										
											2020-10-26 10:43:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | // cookies don't provide isolation by port: http://stackoverflow.com/a/16328399/122353
 | 
					
						
							|  |  |  | const domain = nconf.get('cookieDomain') || urlObject.hostname; | 
					
						
							|  |  |  | const origins = nconf.get('socket.io:origins') || `${urlObject.protocol}//${domain}:*`; | 
					
						
							|  |  |  | nconf.set('socket.io:origins', origins); | 
					
						
							| 
									
										
										
										
											2018-11-30 21:35:57 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-07 20:13:14 -04:00
										 |  |  | if (nconf.get('isCluster') === undefined) { | 
					
						
							|  |  |  | 	nconf.set('isPrimary', true); | 
					
						
							| 
									
										
										
										
											2020-12-06 13:03:33 -05:00
										 |  |  | 	nconf.set('isCluster', false); | 
					
						
							|  |  |  | 	nconf.set('singleHostCluster', false); | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | const dbType = nconf.get('database'); | 
					
						
							|  |  |  | const testDbConfig = nconf.get('test_database'); | 
					
						
							|  |  |  | const productionDbConfig = nconf.get(dbType); | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | if (!testDbConfig) { | 
					
						
							| 
									
										
										
										
											2018-10-31 07:58:37 -06:00
										 |  |  | 	const errorText = 'test_database is not defined'; | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 	winston.info( | 
					
						
							| 
									
										
										
										
											2018-11-28 20:29:43 -07:00
										 |  |  | 		'\n===========================================================\n' + | 
					
						
							|  |  |  | 		'Please, add parameters for test database in config.json\n' + | 
					
						
							|  |  |  | 		'For example (redis):\n' + | 
					
						
							|  |  |  | 		'"test_database": {\n' + | 
					
						
							|  |  |  | 		'    "host": "127.0.0.1",\n' + | 
					
						
							|  |  |  | 		'    "port": "6379",\n' + | 
					
						
							|  |  |  | 		'    "password": "",\n' + | 
					
						
							|  |  |  | 		'    "database": "1"\n' + | 
					
						
							|  |  |  | 		'}\n' + | 
					
						
							|  |  |  | 		' or (mongo):\n' + | 
					
						
							|  |  |  | 		'"test_database": {\n' + | 
					
						
							|  |  |  | 		'    "host": "127.0.0.1",\n' + | 
					
						
							|  |  |  | 		'    "port": "27017",\n' + | 
					
						
							|  |  |  | 		'    "password": "",\n' + | 
					
						
							|  |  |  | 		'    "database": "1"\n' + | 
					
						
							|  |  |  | 		'}\n' + | 
					
						
							|  |  |  | 		' or (mongo) in a replicaset\n' + | 
					
						
							|  |  |  | 		'"test_database": {\n' + | 
					
						
							|  |  |  | 		'    "host": "127.0.0.1,127.0.0.1,127.0.0.1",\n' + | 
					
						
							|  |  |  | 		'    "port": "27017,27018,27019",\n' + | 
					
						
							|  |  |  | 		'    "username": "",\n' + | 
					
						
							|  |  |  | 		'    "password": "",\n' + | 
					
						
							|  |  |  | 		'    "database": "nodebb_test"\n' + | 
					
						
							|  |  |  | 		'}\n' + | 
					
						
							|  |  |  | 		' or (postgres):\n' + | 
					
						
							|  |  |  | 		'"test_database": {\n' + | 
					
						
							|  |  |  | 		'    "host": "127.0.0.1",\n' + | 
					
						
							|  |  |  | 		'    "port": "5432",\n' + | 
					
						
							|  |  |  | 		'    "username": "postgres",\n' + | 
					
						
							|  |  |  | 		'    "password": "",\n' + | 
					
						
							|  |  |  | 		'    "database": "nodebb_test"\n' + | 
					
						
							|  |  |  | 		'}\n' + | 
					
						
							|  |  |  | 		'===========================================================' | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 	); | 
					
						
							|  |  |  | 	winston.error(errorText); | 
					
						
							|  |  |  | 	throw new Error(errorText); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-28 20:29:43 -07:00
										 |  |  | if (testDbConfig.database === productionDbConfig.database && | 
					
						
							|  |  |  | 	testDbConfig.host === productionDbConfig.host && | 
					
						
							|  |  |  | 	testDbConfig.port === productionDbConfig.port) { | 
					
						
							| 
									
										
										
										
											2018-10-31 07:58:37 -06:00
										 |  |  | 	const errorText = 'test_database has the same config as production db'; | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 	winston.error(errorText); | 
					
						
							|  |  |  | 	throw new Error(errorText); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | nconf.set(dbType, testDbConfig); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-16 13:07:13 -04:00
										 |  |  | winston.info('database config %s', dbType, testDbConfig); | 
					
						
							| 
									
										
										
										
											2021-02-03 23:59:08 -07:00
										 |  |  | winston.info(`environment ${global.env}`); | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | const db = require('../../src/database'); | 
					
						
							| 
									
										
										
										
											2021-02-03 23:53:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | module.exports = db; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | before(async function () { | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 	this.timeout(30000); | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Parse out the relative_url and other goodies from the configured URL
 | 
					
						
							|  |  |  | 	const urlObject = url.parse(nconf.get('url')); | 
					
						
							| 
									
										
										
										
											2021-02-07 15:09:52 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	nconf.set('core_templates_path', path.join(__dirname, '../../src/views')); | 
					
						
							|  |  |  | 	nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-persona/templates')); | 
					
						
							|  |  |  | 	nconf.set('theme_config', path.join(nconf.get('themes_path'), 'nodebb-theme-persona', 'theme.json')); | 
					
						
							|  |  |  | 	nconf.set('bcrypt_rounds', 1); | 
					
						
							| 
									
										
										
										
											2020-05-20 09:08:27 -04:00
										 |  |  | 	nconf.set('socket.io:origins', '*:*'); | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	nconf.set('version', packageInfo.version); | 
					
						
							| 
									
										
										
										
											2020-07-21 20:32:36 -04:00
										 |  |  | 	nconf.set('runJobs', false); | 
					
						
							| 
									
										
										
										
											2020-07-21 20:53:25 -04:00
										 |  |  | 	nconf.set('jobsDisabled', false); | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-07 22:57:03 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	await db.init(); | 
					
						
							| 
									
										
										
										
											2021-01-22 23:59:52 -05:00
										 |  |  | 	if (db.hasOwnProperty('createIndices')) { | 
					
						
							|  |  |  | 		await db.createIndices(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-11-07 22:57:03 -05:00
										 |  |  | 	await setupMockDefaults(); | 
					
						
							|  |  |  | 	await db.initSessionStore(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	const meta = require('../../src/meta'); | 
					
						
							|  |  |  | 	nconf.set('theme_templates_path', meta.config['theme:templates'] ? path.join(nconf.get('themes_path'), meta.config['theme:id'], meta.config['theme:templates']) : nconf.get('base_templates_path')); | 
					
						
							|  |  |  | 	// nconf defaults, if not set in config
 | 
					
						
							|  |  |  | 	if (!nconf.get('sessionKey')) { | 
					
						
							|  |  |  | 		nconf.set('sessionKey', 'express.sid'); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	await meta.dependencies.check(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	const webserver = require('../../src/webserver'); | 
					
						
							|  |  |  | 	const sockets = require('../../src/socket.io'); | 
					
						
							| 
									
										
										
										
											2021-01-31 12:37:28 -05:00
										 |  |  | 	await sockets.init(webserver.server); | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	require('../../src/notifications').startJobs(); | 
					
						
							|  |  |  | 	require('../../src/user').startJobs(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	await webserver.listen(); | 
					
						
							| 
									
										
										
										
											2017-05-26 17:16:59 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Iterate over all of the test suites/contexts
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	this.test.parent.suites.forEach((suite) => { | 
					
						
							| 
									
										
										
										
											2017-05-26 17:16:59 -06:00
										 |  |  | 		// Attach an afterAll listener that resets the defaults
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		suite.afterAll(async () => { | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 			await setupMockDefaults(); | 
					
						
							| 
									
										
										
										
											2017-05-26 17:16:59 -06:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | async function setupMockDefaults() { | 
					
						
							|  |  |  | 	const meta = require('../../src/meta'); | 
					
						
							|  |  |  | 	await db.emptydb(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	winston.info('test_database flushed'); | 
					
						
							|  |  |  | 	await setupDefaultConfigs(meta); | 
					
						
							| 
									
										
										
										
											2022-08-10 13:24:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	await meta.configs.init(); | 
					
						
							|  |  |  | 	meta.config.postDelay = 0; | 
					
						
							|  |  |  | 	meta.config.initialPostDelay = 0; | 
					
						
							|  |  |  | 	meta.config.newbiePostDelay = 0; | 
					
						
							| 
									
										
										
										
											2019-11-05 19:51:01 -05:00
										 |  |  | 	meta.config.autoDetectLang = 0; | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-10 13:24:16 -04:00
										 |  |  | 	require('../../src/groups').cache.reset(); | 
					
						
							|  |  |  | 	require('../../src/posts/cache').reset(); | 
					
						
							|  |  |  | 	require('../../src/cache').reset(); | 
					
						
							|  |  |  | 	require('../../src/middleware/uploads').clearCache(); | 
					
						
							|  |  |  | 	// privileges must be given after cache reset
 | 
					
						
							|  |  |  | 	await giveDefaultGlobalPrivileges(); | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	await enableDefaultPlugins(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	await meta.themes.set({ | 
					
						
							|  |  |  | 		type: 'local', | 
					
						
							|  |  |  | 		id: 'nodebb-theme-persona', | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-10 17:51:48 -04:00
										 |  |  | 	const fs = require('fs'); | 
					
						
							|  |  |  | 	await fs.promises.rm('test/uploads', { recursive: true, force: true }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-10 17:56:41 -04:00
										 |  |  | 	const { mkdirp } = require('mkdirp'); | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	const folders = [ | 
					
						
							|  |  |  | 		'test/uploads', | 
					
						
							|  |  |  | 		'test/uploads/category', | 
					
						
							|  |  |  | 		'test/uploads/files', | 
					
						
							|  |  |  | 		'test/uploads/system', | 
					
						
							|  |  |  | 		'test/uploads/profile', | 
					
						
							|  |  |  | 	]; | 
					
						
							|  |  |  | 	for (const folder of folders) { | 
					
						
							|  |  |  | 		/* eslint-disable no-await-in-loop */ | 
					
						
							|  |  |  | 		await mkdirp(folder); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-05-23 18:00:52 -06:00
										 |  |  | } | 
					
						
							|  |  |  | db.setupMockDefaults = setupMockDefaults; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | async function setupDefaultConfigs(meta) { | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 	winston.info('Populating database with default configs, if not already set...\n'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	const defaults = require(path.join(nconf.get('base_dir'), 'install/data/defaults.json')); | 
					
						
							| 
									
										
										
										
											2018-10-16 15:50:32 -04:00
										 |  |  | 	defaults.eventLoopCheckEnabled = 0; | 
					
						
							| 
									
										
										
										
											2018-10-21 16:47:51 -04:00
										 |  |  | 	defaults.minimumPasswordStrength = 0; | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	await meta.configs.setOnEmpty(defaults); | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | async function giveDefaultGlobalPrivileges() { | 
					
						
							| 
									
										
										
										
											2020-11-02 20:34:12 -05:00
										 |  |  | 	winston.info('Giving default global privileges...\n'); | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	const privileges = require('../../src/privileges'); | 
					
						
							|  |  |  | 	await privileges.global.give([ | 
					
						
							| 
									
										
										
										
											2020-05-26 21:57:38 -04:00
										 |  |  | 		'groups:chat', 'groups:upload:post:image', 'groups:signature', 'groups:search:content', | 
					
						
							|  |  |  | 		'groups:search:users', 'groups:search:tags', 'groups:local:login', 'groups:view:users', | 
					
						
							|  |  |  | 		'groups:view:tags', 'groups:view:groups', | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	], 'registered-users'); | 
					
						
							|  |  |  | 	await privileges.global.give([ | 
					
						
							| 
									
										
										
										
											2020-05-26 21:57:38 -04:00
										 |  |  | 		'groups:view:users', 'groups:view:tags', 'groups:view:groups', | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	], 'guests'); | 
					
						
							| 
									
										
										
										
											2018-01-03 13:27:30 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | async function enableDefaultPlugins() { | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 	winston.info('Enabling default plugins\n'); | 
					
						
							| 
									
										
										
										
											2020-05-06 13:57:03 -04:00
										 |  |  | 	const testPlugins = Array.isArray(nconf.get('test_plugins')) ? nconf.get('test_plugins') : []; | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	const defaultEnabled = [ | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 		'nodebb-plugin-dbsearch', | 
					
						
							| 
									
										
										
										
											2019-07-29 19:42:55 -04:00
										 |  |  | 		'nodebb-widget-essentials', | 
					
						
							| 
									
										
											  
											
												Webpack5 (#10311)
* feat: webpack 5 part 1
* fix: gruntfile fixes
* fix: fix taskbar warning
add app.importScript
copy public/src/modules to build folder
* refactor: remove commented old code
* feat: reenable admin
* fix: acp settings pages, fix sortable on manage categories
embedded require in html not allowed
* fix: bundle serialize/deserizeli so plugins dont break
* test: fixe util tests
* test: fix require path
* test: more test fixes
* test: require correct utils module
* test: require correct utils
* test: log stack
* test: fix db require blowing up tests
* test: move and disable bundle test
* refactor: add aliases
* test: disable testing route
* fix: move webpack modules necessary for build, into `dependencies`
* test: fix one more test
remove 500-embed.tpl
* fix: restore use of assets/nodebb.min.js, at least for now
* fix: remove unnecessary line break
* fix: point to proper ACP bundle
* test: maybe fix build test
* test: composer
* refactor: dont need dist
* refactor: more cleanup
use everything from build/public folder
* get rid of conditional import in app.js
* fix: ace
* refactor: cropper alias
* test: lint and test fixes
* lint: fix
* refactor: rename function to app.require
* refactor: go back to using app.require
* chore: use github branch
* chore: use webpack branch
* feat: webpack webinstaller
* feat: add chunkFile name with contenthash
* refactor: move hooks to top
* refactor: get rid of template500Function
* fix(deps): use webpack5 branch of 2factor plugin
* chore: tagging v2.0.0-beta.0 pre-release version :boom: :shipit: :tada: :rocket:
* refactor: disable cache on templates
loadTemplate is called once by benchpress and the result is cache internally
* refactor: add server side helpers.js
* feat: deprecate /plugins shorthand route, closes #10343
* refactor: use build/public for webpack
* test: fix filename
* fix: more specific selector
* lint: ignore
* refactor: fix comments
* test: add debug for random failing test
* refactor: cleanup
remove test page, remove dupe functions in utils.common
* lint: use relative path  for now
* chore: bump prerelease version
* feat: add translateKeys
* fix: optional params
* fix: get rid of extra timeago files
* refactor: cleanup, require timeago locale earlier
remove translator.prepareDOM, it is in header.tpl html tag
* refactor: privileges system to use a Map in the backend instead of separate objects for keys and labels (#10378)
* refactor: privileges system to use a Map in the backend instead of separate objects for keys and labels
- Existing hooks are preserved (to be deprecated at a later date, possibly)
- New init hooks are called on NodeBB start, and provide a one-stop shop to add new privileges, instead of having to add to four different hooks
* docs: fix typo in comment
* test: spec changes
* refactor: privileges system to use a Map in the backend instead of separate objects for keys and labels (#10378)
* refactor: privileges system to use a Map in the backend instead of separate objects for keys and labels
- Existing hooks are preserved (to be deprecated at a later date, possibly)
- New init hooks are called on NodeBB start, and provide a one-stop shop to add new privileges, instead of having to add to four different hooks
* docs: fix typo in comment
* test: spec changes
* feat: allow app.require('bootbox'/'benchpressjs')
* refactor: require server side utils
* test: jquery ready
* change istaller to use build/public
* test: use document.addEventListener
* refactor: closes #10301
* refactor: generateTopicClass
* fix: column counts for other privileges
* fix: #10443, regression where sorted-list items did not render into the DOM in the predicted order [breaking]
* fix: typo in hook name
* refactor: introduce a generic autocomplete.init() method that can be called to add nodebb-style autocompletion but using different data sources (e.g. not user/groups/tags)
* fix: crash if `delay` not passed in (as it cannot be destructured)
* refactor: replace substr
* feat: set --panel-offset style in html element based on stored value in localStorage
* refactor: addDropupHandler() logic to be less naive
- Take into account height of the menu
- Don't apply dropUp logic if there's nothing in the dropdown
- Remove 'hidden' class (added by default in Persona for post tools) when menu items are added
closes #10423
* refactor: simplify utils.params [breaking]
Retrospective analysis of the usage of this method suggests that the options passed in are superfluous, and that only `url` is required. Using a browser built-in makes more sense to accomplish what this method sets out to do.
* feat: add support for returning full URLSearchParams for utils.params
* fix: utils.params() fallback handling
* fix: default empty obj for params()
* fix: remove \'loggedin\' and \'register\' qs parameters once they have been used, delay invocation of messages until ajaxify.end
* fix: utils.params() not allowing relative paths to be passed in
* refactor(DRY): new assertPasswordValidity utils method
* fix: incorrect error message returned on insufficient privilege on flag edit
* fix: read/update/delete access to flags API should be limited for moderators to only post flags in categories they moderate
- added failing tests and patched up middleware.assert.flags to fix
* refactor: flag api v3 tests to create new post and flags on every round
* fix: missing error:no-flag language key
* refactor: flags.canView to check flag existence, simplify middleware.assert.flag
* feat: flag deletion API endpoint, #10426
* feat: UI for flag deletion, closes #10426
* chore: update plugin versions
* chore: up emoji
* chore: update markdown
* chore: up emoji-android
* fix: regression caused by utils.params() refactor, supports arrays and pipes all values through utils.toType, adjusts tests to type check
Co-authored-by: Julian Lam <julian@nodebb.org>
											
										 
											2022-04-29 21:39:33 -04:00
										 |  |  | 		'nodebb-plugin-composer-default', | 
					
						
							| 
									
										
										
										
											2020-05-06 13:57:03 -04:00
										 |  |  | 	].concat(testPlugins); | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	winston.info('[install/enableDefaultPlugins] activating default plugins', defaultEnabled); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 17:05:52 -04:00
										 |  |  | 	await db.sortedSetAdd('plugins:active', Object.keys(defaultEnabled), defaultEnabled); | 
					
						
							| 
									
										
										
										
											2017-05-20 20:03:41 -04:00
										 |  |  | } |