mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:10:51 +00:00
test: use synthetic cli provider fixtures
This commit is contained in:
@@ -17,7 +17,7 @@ vi.mock("node:fs", async () => {
|
||||
});
|
||||
|
||||
vi.mock("../channels/ids.js", () => ({
|
||||
CHAT_CHANNEL_ORDER: ["telegram", "discord"],
|
||||
CHAT_CHANNEL_ORDER: ["quietchat", "forum"],
|
||||
}));
|
||||
|
||||
describe("resolveCliChannelOptions", () => {
|
||||
@@ -28,10 +28,10 @@ describe("resolveCliChannelOptions", () => {
|
||||
|
||||
it("uses precomputed startup metadata when available", async () => {
|
||||
readFileSyncMock.mockReturnValue(
|
||||
JSON.stringify({ channelOptions: ["cached", "telegram", "cached"] }),
|
||||
JSON.stringify({ channelOptions: ["cached", "quietchat", "cached"] }),
|
||||
);
|
||||
|
||||
expect(resolveCliChannelOptions()).toEqual(["cached", "telegram"]);
|
||||
expect(resolveCliChannelOptions()).toEqual(["cached", "quietchat"]);
|
||||
});
|
||||
|
||||
it("falls back to core channel order when metadata is missing", async () => {
|
||||
@@ -39,14 +39,14 @@ describe("resolveCliChannelOptions", () => {
|
||||
throw new Error("ENOENT");
|
||||
});
|
||||
|
||||
expect(resolveCliChannelOptions()).toEqual(["telegram", "discord"]);
|
||||
expect(resolveCliChannelOptions()).toEqual(["quietchat", "forum"]);
|
||||
});
|
||||
|
||||
it("ignores external catalog env during CLI bootstrap", async () => {
|
||||
process.env.OPENCLAW_PLUGIN_CATALOG_PATHS = "/tmp/plugins-catalog.json";
|
||||
readFileSyncMock.mockReturnValue(JSON.stringify({ channelOptions: ["cached", "telegram"] }));
|
||||
readFileSyncMock.mockReturnValue(JSON.stringify({ channelOptions: ["cached", "quietchat"] }));
|
||||
|
||||
expect(resolveCliChannelOptions()).toEqual(["cached", "telegram"]);
|
||||
expect(resolveCliChannelOptions()).toEqual(["cached", "quietchat"]);
|
||||
delete process.env.OPENCLAW_PLUGIN_CATALOG_PATHS;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -61,8 +61,8 @@ describe("plugin-registry-loader", () => {
|
||||
});
|
||||
|
||||
it("forwards explicit config snapshots to plugin loading", async () => {
|
||||
const config = { channels: { telegram: { enabled: true } } } as never;
|
||||
const activationSourceConfig = { channels: { telegram: { enabled: true } } } as never;
|
||||
const config = { channels: { quietchat: { enabled: true } } } as never;
|
||||
const activationSourceConfig = { channels: { quietchat: { enabled: true } } } as never;
|
||||
|
||||
await ensureCliPluginRegistryLoaded({
|
||||
scope: "configured-channels",
|
||||
|
||||
@@ -96,7 +96,7 @@ describe("resolveMissingPluginCommandMessage", () => {
|
||||
expect(
|
||||
resolveMissingPluginCommandMessage("browser", {
|
||||
plugins: {
|
||||
allow: ["telegram"],
|
||||
allow: ["quietchat"],
|
||||
},
|
||||
}),
|
||||
).toContain('`plugins.allow` excludes "browser"');
|
||||
@@ -187,7 +187,7 @@ describe("resolveMissingPluginCommandMessage", () => {
|
||||
"wiki",
|
||||
{
|
||||
plugins: {
|
||||
allow: ["telegram"],
|
||||
allow: ["quietchat"],
|
||||
},
|
||||
},
|
||||
{ registry: memoryWikiCommandAliasRegistry },
|
||||
|
||||
@@ -44,8 +44,8 @@ describe("buildProviderStatusIndex", () => {
|
||||
throw new Error("should not be used when inspectAccount exists");
|
||||
});
|
||||
const plugin = {
|
||||
id: "slack",
|
||||
meta: { label: "Slack" },
|
||||
id: "workchat",
|
||||
meta: { label: "WorkChat" },
|
||||
config: {
|
||||
listAccountIds: () => ["work"],
|
||||
inspectAccount,
|
||||
@@ -62,8 +62,8 @@ describe("buildProviderStatusIndex", () => {
|
||||
|
||||
expect(resolveAccount).not.toHaveBeenCalled();
|
||||
expect(inspectAccount).toHaveBeenCalledWith({}, "work");
|
||||
expect(map.get("slack:work")).toMatchObject({
|
||||
provider: "slack",
|
||||
expect(map.get("workchat:work")).toMatchObject({
|
||||
provider: "workchat",
|
||||
accountId: "work",
|
||||
state: "linked",
|
||||
configured: true,
|
||||
@@ -74,8 +74,8 @@ describe("buildProviderStatusIndex", () => {
|
||||
|
||||
it("records accounts that throw during read-only resolution as not configured", async () => {
|
||||
const plugin = {
|
||||
id: "telegram",
|
||||
meta: { label: "Telegram" },
|
||||
id: "quietchat",
|
||||
meta: { label: "QuietChat" },
|
||||
config: {
|
||||
listAccountIds: () => ["default"],
|
||||
resolveAccount: () => {
|
||||
@@ -91,9 +91,9 @@ describe("buildProviderStatusIndex", () => {
|
||||
await expect(buildProviderStatusIndex({} as OpenClawConfig)).resolves.toEqual(
|
||||
new Map([
|
||||
[
|
||||
"telegram:default",
|
||||
"quietchat:default",
|
||||
{
|
||||
provider: "telegram",
|
||||
provider: "quietchat",
|
||||
accountId: "default",
|
||||
state: "not configured",
|
||||
configured: false,
|
||||
@@ -105,8 +105,8 @@ describe("buildProviderStatusIndex", () => {
|
||||
|
||||
it("rethrows unexpected read-only account resolution errors", async () => {
|
||||
const plugin = {
|
||||
id: "telegram",
|
||||
meta: { label: "Telegram" },
|
||||
id: "quietchat",
|
||||
meta: { label: "QuietChat" },
|
||||
config: {
|
||||
listAccountIds: () => ["default"],
|
||||
resolveAccount: () => {
|
||||
|
||||
@@ -20,7 +20,7 @@ describe("buildStatusCommandReportLines", () => {
|
||||
pairingRecoveryLines: ["pairing needed"],
|
||||
securityAuditLines: ["audit line"],
|
||||
channelsColumns: [{ key: "Channel", header: "Channel" }],
|
||||
channelsRows: [{ Channel: "telegram" }],
|
||||
channelsRows: [{ Channel: "quietchat" }],
|
||||
sessionsColumns: [{ key: "Key", header: "Key" }],
|
||||
sessionsRows: [{ Key: "main" }],
|
||||
systemEventsRows: [{ Event: "queued" }],
|
||||
@@ -81,7 +81,7 @@ describe("buildStatusCommandReportLines", () => {
|
||||
pairingRecoveryLines: [],
|
||||
securityAuditLines: ["audit line"],
|
||||
channelsColumns: [{ key: "Channel", header: "Channel" }],
|
||||
channelsRows: [{ Channel: "telegram" }],
|
||||
channelsRows: [{ Channel: "quietchat" }],
|
||||
sessionsColumns: [{ key: "Key", header: "Key" }],
|
||||
sessionsRows: [{ Key: "main" }],
|
||||
footerLines: ["FAQ"],
|
||||
|
||||
Reference in New Issue
Block a user