mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 10:00:35 +00:00
refactor(test): extract shared doctor migration test setup
This commit is contained in:
@@ -13,6 +13,15 @@ describe("normalizeLegacyConfigValues", () => {
|
||||
fs.writeFileSync(path.join(dir, "creds.json"), JSON.stringify({ me: {} }));
|
||||
};
|
||||
|
||||
const expectNoWhatsAppConfigForLegacyAuth = (setup?: () => void) => {
|
||||
setup?.();
|
||||
const res = normalizeLegacyConfigValues({
|
||||
messages: { ackReaction: "👀", ackReactionScope: "group-mentions" },
|
||||
});
|
||||
expect(res.config.channels?.whatsapp).toBeUndefined();
|
||||
expect(res.changes).toEqual([]);
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
previousOauthDir = process.env.OPENCLAW_OAUTH_DIR;
|
||||
tempOauthDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-oauth-"));
|
||||
@@ -57,39 +66,24 @@ describe("normalizeLegacyConfigValues", () => {
|
||||
});
|
||||
|
||||
it("does not add whatsapp config when only auth exists (issue #900)", () => {
|
||||
const credsDir = path.join(tempOauthDir ?? "", "whatsapp", "default");
|
||||
writeCreds(credsDir);
|
||||
|
||||
const res = normalizeLegacyConfigValues({
|
||||
messages: { ackReaction: "👀", ackReactionScope: "group-mentions" },
|
||||
expectNoWhatsAppConfigForLegacyAuth(() => {
|
||||
const credsDir = path.join(tempOauthDir ?? "", "whatsapp", "default");
|
||||
writeCreds(credsDir);
|
||||
});
|
||||
|
||||
expect(res.config.channels?.whatsapp).toBeUndefined();
|
||||
expect(res.changes).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not add whatsapp config when only legacy auth exists (issue #900)", () => {
|
||||
const credsPath = path.join(tempOauthDir ?? "", "creds.json");
|
||||
fs.writeFileSync(credsPath, JSON.stringify({ me: {} }));
|
||||
|
||||
const res = normalizeLegacyConfigValues({
|
||||
messages: { ackReaction: "👀", ackReactionScope: "group-mentions" },
|
||||
expectNoWhatsAppConfigForLegacyAuth(() => {
|
||||
const credsPath = path.join(tempOauthDir ?? "", "creds.json");
|
||||
fs.writeFileSync(credsPath, JSON.stringify({ me: {} }));
|
||||
});
|
||||
|
||||
expect(res.config.channels?.whatsapp).toBeUndefined();
|
||||
expect(res.changes).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not add whatsapp config when only non-default auth exists (issue #900)", () => {
|
||||
const credsDir = path.join(tempOauthDir ?? "", "whatsapp", "work");
|
||||
writeCreds(credsDir);
|
||||
|
||||
const res = normalizeLegacyConfigValues({
|
||||
messages: { ackReaction: "👀", ackReactionScope: "group-mentions" },
|
||||
expectNoWhatsAppConfigForLegacyAuth(() => {
|
||||
const credsDir = path.join(tempOauthDir ?? "", "whatsapp", "work");
|
||||
writeCreds(credsDir);
|
||||
});
|
||||
|
||||
expect(res.config.channels?.whatsapp).toBeUndefined();
|
||||
expect(res.changes).toEqual([]);
|
||||
});
|
||||
|
||||
it("copies legacy ack reaction when authDir override exists", () => {
|
||||
|
||||
Reference in New Issue
Block a user