From 511b8b7d975fd02b7a5500a246877c34b4a49ff7 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Thu, 10 Sep 2026 20:01:54 +0200 Subject: [PATCH] Remove global_chat dependency in restart test Use a fictional restart_test mock plugin added as a before step instead of global_chat for the .checkRestartRequired() test. Prevents the test from failing if the integration tests are not also run. Also fixes the fixture not accounting for setting load_plugin causing restartRequired to be set to true due to the integration tests having already set it to the same value. --- test/controller/Controller.js | 12 ++++++++---- test/host.js | 7 +++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/test/controller/Controller.js b/test/controller/Controller.js index 736d4cbe..6054854a 100644 --- a/test/controller/Controller.js +++ b/test/controller/Controller.js @@ -10,6 +10,7 @@ const express = require("express"); const { ControllerConfig, Address, RequestError, InstanceConfig, SystemInfo, Role, ModPack, + addPluginConfigFields, } = require("@clusterio/lib"); class MockEvent {} @@ -234,13 +235,16 @@ describe("controller/src/Controller", function() { }); }); describe(".checkRestartRequired()", function() { + before(function() { + addPluginConfigFields([{ name: "restart_test" }]); + }); beforeEach(function() { // Would not be needed if controller setup was beforeEach - controller.config.restartRequired = false; controller.config.set("controller.version", controllerVersion); - controller.config.set("global_chat.load_plugin", true); + controller.config.set("restart_test.load_plugin", true); + controller.config.restartRequired = false; controller.pluginInfos[0] = { - name: "global_chat", + name: "restart_test", packagePath: require.resolve("@clusterio/controller/package.json"), version: controllerVersion, }; @@ -256,7 +260,7 @@ describe("controller/src/Controller", function() { controller.pluginInfos[0].version = "0.0.0"; controller.pluginInfos[0].webEntrypoint = true; controller.pluginInfos[0].controllerEntrypoint = true; - controller.config.set("global_chat.load_plugin", false); + controller.config.set("restart_test.load_plugin", false); controller.config.restartRequired = false; // Setting load_plugin requires a restart const result = await controller.checkRestartRequired(); assert.equal(result, false); diff --git a/test/host.js b/test/host.js index ad97bd83..5fb6ab5f 100644 --- a/test/host.js +++ b/test/host.js @@ -119,10 +119,13 @@ describe("Host testing", function() { describe(".checkRestartRequired()", function() { let host; const hostVersion = require("@clusterio/host/package.json").version; + before(function() { + lib.addPluginConfigFields([{ name: "restart_test", hostEntrypoint: "host.js" }]); + }); beforeEach(function() { // This can be used more generally, but i did not want to interfere with handleSyncUserListsEvent const pluginInfos = [{ - name: "global_chat", + name: "restart_test", packagePath: require.resolve("@clusterio/host/package.json"), version: hostVersion, }]; @@ -141,7 +144,7 @@ describe("Host testing", function() { host.pluginInfos[0].version = "0.0.0"; host.pluginInfos[0].hostEntrypoint = true; host.pluginInfos[0].instanceEntrypoint = true; - host.config.set("global_chat.load_plugin", false); + host.config.set("restart_test.load_plugin", false); host.config.restartRequired = false; // Setting load_plugin requires a restart const result = await host.checkRestartRequired(); assert.equal(result, false);