Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([health-test-updatesettingswith-mock]): enforce plain-object return in the mock to match the real guard

[._.]/ Adam Eivy1617be7ddaeb
diff --git a/server/routes/health.test.js b/server/routes/health.test.js
index ad5563d86f..c8de49cdff 100644
--- a/server/routes/health.test.js
+++ b/server/routes/health.test.js
@@ -32,8 +32,16 @@ vi.mock('../services/settings.js', () => ({
updateSettings: vi.fn().mockResolvedValue({}),
// PUT /health/thresholds was migrated to updateSettingsWith (a read-modify-write
// that hands the mutator the current settings and returns its result). Mirror
- // that contract: apply the mutator to an empty current-settings object.
- updateSettingsWith: vi.fn(async (mutate) => mutate({}))
+ // that contract faithfully — including the real helper's plain-object guard —
+ // so a future route mutator that forgets to `return` (or returns a non-object)
+ // fails this test instead of silently passing while it would throw in prod.
+ updateSettingsWith: vi.fn(async (mutate) => {
+ const next = await mutate({});
+ if (!next || typeof next !== 'object' || Array.isArray(next)) {
+ throw new TypeError('updateSettingsWith: mutate() must return a plain settings object');
+ }
+ return next;
+ })
}));
describe('System Health Routes', () => {