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

test: cover user-added keys and corrupt files in migration 412 (#11881)

Adam Eivyec9aeb1d8b69
diff --git a/scripts/migrations/412-prune-config-seed-duplicates.test.js b/scripts/migrations/412-prune-config-seed-duplicates.test.js
index a74699041e..faadbe30ee 100644
--- a/scripts/migrations/412-prune-config-seed-duplicates.test.js
+++ b/scripts/migrations/412-prune-config-seed-duplicates.test.js
@@ -185,4 +185,32 @@ describe('migration 412 — prune config seeds that duplicate DEFAULT_CONFIG', (
expect(readJson(memoryConfigPath)).toEqual({ model: 'custom-llm' });
expect(readJson(browserConfigPath)).toEqual({ cdpHost: 'custom-host' });
});
+
+ describe('keys and files the migration must not touch', () => {
+ it('keeps a user-added key that is not in the shipped seed', async () => {
+ writeJson(memoryConfigPath, {
+ enabled: true,
+ provider: 'lmstudio',
+ customKey: 'x',
+ });
+ writeJson(browserConfigPath, { cdpPort: 5556, customKey: 'y' });
+
+ await migration.up({ rootDir });
+
+ expect(readJson(memoryConfigPath)).toEqual({ customKey: 'x' });
+ expect(readJson(browserConfigPath)).toEqual({ customKey: 'y' });
+ });
+
+ it('leaves an unparseable config file byte-for-byte untouched', async () => {
+ const corrupt = '{ "enabled": true, "provider": ';
+ writeFileSync(memoryConfigPath, corrupt);
+ writeFileSync(browserConfigPath, corrupt);
+
+ const result = await migration.up({ rootDir });
+
+ expect(result).toEqual({ memoryClassifier: null, browser: null });
+ expect(readFileSync(memoryConfigPath, 'utf-8')).toBe(corrupt);
+ expect(readFileSync(browserConfigPath, 'utf-8')).toBe(corrupt);
+ });
+ });
});