mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
fix(doctor): restore group config drift migrations (#77465)
This commit is contained in:
@@ -182,7 +182,56 @@ describe("legacy migrate audio transcription", () => {
|
||||
});
|
||||
|
||||
describe("legacy migrate mention routing", () => {
|
||||
it("does not rewrite removed routing.groupChat.requireMention migrations", () => {
|
||||
it("moves legacy routing group chat settings into current channel and message config", () => {
|
||||
const res = migrateLegacyConfigForTest({
|
||||
routing: {
|
||||
allowFrom: ["+15550001111"],
|
||||
groupChat: {
|
||||
requireMention: false,
|
||||
historyLimit: 12,
|
||||
mentionPatterns: ["@openclaw"],
|
||||
},
|
||||
},
|
||||
channels: {
|
||||
whatsapp: {},
|
||||
telegram: {
|
||||
groups: {
|
||||
"*": { requireMention: true },
|
||||
},
|
||||
},
|
||||
imessage: {},
|
||||
},
|
||||
});
|
||||
|
||||
const migratedConfig = res.config as Record<string, unknown> | null;
|
||||
expect(migratedConfig?.routing).toBeUndefined();
|
||||
expect(res.config?.channels?.whatsapp?.allowFrom).toEqual(["+15550001111"]);
|
||||
expect(res.config?.channels?.whatsapp?.groups).toEqual({
|
||||
"*": { requireMention: false },
|
||||
});
|
||||
expect(res.config?.channels?.telegram?.groups).toEqual({
|
||||
"*": { requireMention: true },
|
||||
});
|
||||
expect(res.config?.channels?.imessage?.groups).toEqual({
|
||||
"*": { requireMention: false },
|
||||
});
|
||||
expect(res.config?.messages?.groupChat).toEqual({
|
||||
historyLimit: 12,
|
||||
mentionPatterns: ["@openclaw"],
|
||||
});
|
||||
expect(res.changes).toEqual(
|
||||
expect.arrayContaining([
|
||||
"Moved routing.allowFrom → channels.whatsapp.allowFrom.",
|
||||
'Moved routing.groupChat.requireMention → channels.whatsapp.groups."*".requireMention.',
|
||||
'Removed routing.groupChat.requireMention (channels.telegram.groups."*" already set).',
|
||||
'Moved routing.groupChat.requireMention → channels.imessage.groups."*".requireMention.',
|
||||
"Moved routing.groupChat.historyLimit → messages.groupChat.historyLimit.",
|
||||
"Moved routing.groupChat.mentionPatterns → messages.groupChat.mentionPatterns.",
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it("removes legacy routing requireMention when no compatible channel exists", () => {
|
||||
const res = migrateLegacyConfigForTest({
|
||||
routing: {
|
||||
groupChat: {
|
||||
@@ -191,11 +240,14 @@ describe("legacy migrate mention routing", () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.changes).toEqual([]);
|
||||
expect(res.config).toBeNull();
|
||||
const migratedConfig = res.config as Record<string, unknown> | null;
|
||||
expect(migratedConfig?.routing).toBeUndefined();
|
||||
expect(res.changes).toEqual([
|
||||
"Removed routing.groupChat.requireMention (no configured WhatsApp, Telegram, or iMessage channel found).",
|
||||
]);
|
||||
});
|
||||
|
||||
it("does not rewrite removed channels.telegram.requireMention migrations", () => {
|
||||
it("moves channels.telegram.requireMention into the wildcard group default", () => {
|
||||
const res = migrateLegacyConfigForTest({
|
||||
channels: {
|
||||
telegram: {
|
||||
@@ -204,8 +256,14 @@ describe("legacy migrate mention routing", () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.changes).toEqual([]);
|
||||
expect(res.config).toBeNull();
|
||||
expect(res.config?.channels?.telegram).toEqual({
|
||||
groups: {
|
||||
"*": { requireMention: false },
|
||||
},
|
||||
});
|
||||
expect(res.changes).toContain(
|
||||
'Moved channels.telegram.requireMention → channels.telegram.groups."*".requireMention.',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user