Node.js based forum software built for the modern web
test: fix tests due to updating config.json
Barış Soner Uşaklıd4ecc53cb31d
diff --git a/src/upgrades/4.14.3/trust_proxy.js b/src/upgrades/4.14.3/trust_proxy.jsindex bb9812325d..d51c3c2cae 100644--- a/src/upgrades/4.14.3/trust_proxy.js+++ b/src/upgrades/4.14.3/trust_proxy.js@@ -1,20 +1,25 @@'use strict';-const install = require('../../install');+const fs = require('fs');+const path = require('path');module.exports = {name: 'Backfill trust_proxy for upgraded installs',timestamp: Date.UTC(2026, 6, 28),method: async function () {let configJSON;+ const pathToConfig = '../../../config.json';try {- configJSON = require('../../../config.json') || {};+ configJSON = require(pathToConfig) || {};} catch (err) {configJSON = {};}if (!Object.hasOwn(configJSON, 'trust_proxy')) {- await install.save({ trust_proxy: true });+ await fs.promises.writeFile(path.join(__dirname, pathToConfig), JSON.stringify({+ ...configJSON,+ trust_proxy: true,+ }, null, 4));}},};\ No newline at end of filediff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.jsindex db80850056..6073fc62ee 100644--- a/test/mocks/databasemock.js+++ b/test/mocks/databasemock.js@@ -37,10 +37,11 @@ try {}nconf.file({ file: path.join(__dirname, '../../config.json') });+const base_dir = path.join(__dirname, '../../');nconf.defaults({- base_dir: path.join(__dirname, '../..'),+ base_dir: base_dir,themes_path: path.join(__dirname, '../../node_modules'),- upload_path: 'test/uploads',+ upload_path: path.resolve(base_dir, 'test/uploads'),views_dir: path.join(__dirname, '../../build/public/templates'),relative_path: '',});@@ -49,7 +50,6 @@ const urlObject = new URL(nconf.get('url'));const relativePath = urlObject.pathname !== '/' ? urlObject.pathname : '';nconf.set('relative_path', relativePath);nconf.set('asset_base_url', `${relativePath}/assets`);-nconf.set('upload_path', path.resolve(nconf.get('base_dir'), nconf.get('upload_path')));nconf.set('upload_url', '/assets/uploads');nconf.set('url_parsed', {href: urlObject.href,