mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:28:38 +00:00
test: share slack config snapshot helper
This commit is contained in:
@@ -15,6 +15,18 @@ vi.mock("./runtime.js", () => ({
|
|||||||
|
|
||||||
import { slackPlugin } from "./channel.js";
|
import { slackPlugin } from "./channel.js";
|
||||||
|
|
||||||
|
async function getSlackConfiguredState(cfg: OpenClawConfig) {
|
||||||
|
const account = slackPlugin.config.resolveAccount(cfg, "default");
|
||||||
|
return {
|
||||||
|
configured: slackPlugin.config.isConfigured?.(account, cfg),
|
||||||
|
snapshot: await slackPlugin.status?.buildAccountSnapshot?.({
|
||||||
|
account,
|
||||||
|
cfg,
|
||||||
|
runtime: undefined,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
describe("slackPlugin actions", () => {
|
describe("slackPlugin actions", () => {
|
||||||
it("prefers session lookup for announce target routing", () => {
|
it("prefers session lookup for announce target routing", () => {
|
||||||
expect(slackPlugin.meta.preferSessionLookupForAnnounceTarget).toBe(true);
|
expect(slackPlugin.meta.preferSessionLookupForAnnounceTarget).toBe(true);
|
||||||
@@ -189,13 +201,7 @@ describe("slackPlugin config", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const account = slackPlugin.config.resolveAccount(cfg, "default");
|
const { configured, snapshot } = await getSlackConfiguredState(cfg);
|
||||||
const configured = slackPlugin.config.isConfigured?.(account, cfg);
|
|
||||||
const snapshot = await slackPlugin.status?.buildAccountSnapshot?.({
|
|
||||||
account,
|
|
||||||
cfg,
|
|
||||||
runtime: undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(configured).toBe(true);
|
expect(configured).toBe(true);
|
||||||
expect(snapshot?.configured).toBe(true);
|
expect(snapshot?.configured).toBe(true);
|
||||||
@@ -211,13 +217,7 @@ describe("slackPlugin config", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const account = slackPlugin.config.resolveAccount(cfg, "default");
|
const { configured, snapshot } = await getSlackConfiguredState(cfg);
|
||||||
const configured = slackPlugin.config.isConfigured?.(account, cfg);
|
|
||||||
const snapshot = await slackPlugin.status?.buildAccountSnapshot?.({
|
|
||||||
account,
|
|
||||||
cfg,
|
|
||||||
runtime: undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(configured).toBe(false);
|
expect(configured).toBe(false);
|
||||||
expect(snapshot?.configured).toBe(false);
|
expect(snapshot?.configured).toBe(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user