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.
This commit is contained in:
Hornwitser committed 2026-09-11 19:51:16 +02:00
1 parent 30083b96c1
commit 511b8b7d97
2 files changed
+13 -6

No files matched your search

+8 -4
View File
@@ -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);
+5 -2
View File
@@ -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);