mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 18:00:21 +00:00
fix: repair ci test and loader regressions
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { nextcloudTalkPlugin } from "./channel.js";
|
||||
import { NextcloudTalkConfigSchema } from "./config-schema.js";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
escapeNextcloudTalkMarkdown,
|
||||
formatNextcloudTalkCodeBlock,
|
||||
@@ -28,6 +26,11 @@ import {
|
||||
} from "./signature.js";
|
||||
import type { CoreConfig } from "./types.js";
|
||||
|
||||
vi.mock("../../../src/config/bundled-channel-config-runtime.js", () => ({
|
||||
getBundledChannelRuntimeMap: () => new Map(),
|
||||
getBundledChannelConfigSchemaMap: () => new Map(),
|
||||
}));
|
||||
|
||||
const fetchWithSsrFGuard = vi.hoisted(() => vi.fn());
|
||||
const readFileSync = vi.hoisted(() => vi.fn());
|
||||
|
||||
@@ -39,6 +42,14 @@ vi.mock("../runtime-api.js", async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/infra-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
fetchWithSsrFGuard,
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("node:fs", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("node:fs")>();
|
||||
return {
|
||||
@@ -48,6 +59,14 @@ vi.mock("node:fs", async (importOriginal) => {
|
||||
});
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
let nextcloudTalkPlugin: typeof import("./channel.js").nextcloudTalkPlugin;
|
||||
let NextcloudTalkConfigSchema: typeof import("./config-schema.js").NextcloudTalkConfigSchema;
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
({ nextcloudTalkPlugin } = await import("./channel.js"));
|
||||
({ NextcloudTalkConfigSchema } = await import("./config-schema.js"));
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
fetchWithSsrFGuard.mockReset();
|
||||
@@ -406,6 +425,7 @@ describe("nextcloud talk core", () => {
|
||||
});
|
||||
|
||||
it("resolves direct rooms from the room info endpoint", async () => {
|
||||
vi.resetModules();
|
||||
const release = vi.fn(async () => {});
|
||||
fetchWithSsrFGuard.mockResolvedValue({
|
||||
response: {
|
||||
@@ -445,6 +465,7 @@ describe("nextcloud talk core", () => {
|
||||
});
|
||||
|
||||
it("reads the api password from a file and logs non-ok room info responses", async () => {
|
||||
vi.resetModules();
|
||||
const release = vi.fn(async () => {});
|
||||
const log = vi.fn();
|
||||
const error = vi.fn();
|
||||
@@ -480,6 +501,7 @@ describe("nextcloud talk core", () => {
|
||||
});
|
||||
|
||||
it("returns undefined from room info without credentials or base url", async () => {
|
||||
vi.resetModules();
|
||||
const { resolveNextcloudTalkRoomKind } = await import("./room-info.js");
|
||||
|
||||
await expect(
|
||||
|
||||
@@ -2,21 +2,18 @@ import type { ChannelSetupAdapter, ChannelSetupInput } from "openclaw/plugin-sdk
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
||||
import {
|
||||
applyAccountNameToChannelSection,
|
||||
createSetupInputPresenceValidator,
|
||||
patchScopedAccountConfig,
|
||||
} from "openclaw/plugin-sdk/setup";
|
||||
import {
|
||||
mergeAllowFromEntries,
|
||||
createTopLevelChannelDmPolicy,
|
||||
promptParsedAllowFromForAccount,
|
||||
resolveSetupAccountId,
|
||||
setSetupChannelEnabled,
|
||||
} from "openclaw/plugin-sdk/setup";
|
||||
import type { ChannelSetupDmPolicy } from "openclaw/plugin-sdk/setup";
|
||||
import { type ChannelSetupWizard } from "openclaw/plugin-sdk/setup";
|
||||
import { formatDocsLink } from "openclaw/plugin-sdk/setup";
|
||||
import type { WizardPrompter } from "openclaw/plugin-sdk/setup";
|
||||
type ChannelSetupDmPolicy,
|
||||
type ChannelSetupWizard,
|
||||
type WizardPrompter,
|
||||
} from "openclaw/plugin-sdk/setup-runtime";
|
||||
import { formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
|
||||
import { applyAccountNameToChannelSection, patchScopedAccountConfig } from "../runtime-api.js";
|
||||
import {
|
||||
listNextcloudTalkAccountIds,
|
||||
resolveDefaultNextcloudTalkAccountId,
|
||||
|
||||
@@ -14,19 +14,14 @@ import {
|
||||
startAccountAndTrackLifecycle,
|
||||
waitForStartedMocks,
|
||||
} from "../../../test/helpers/extensions/start-account-lifecycle.js";
|
||||
import { resolveNextcloudTalkAccount, type ResolvedNextcloudTalkAccount } from "./accounts.js";
|
||||
import { nextcloudTalkPlugin } from "./channel.js";
|
||||
import {
|
||||
clearNextcloudTalkAccountFields,
|
||||
nextcloudTalkDmPolicy,
|
||||
nextcloudTalkSetupAdapter,
|
||||
normalizeNextcloudTalkBaseUrl,
|
||||
setNextcloudTalkAccountConfig,
|
||||
validateNextcloudTalkBaseUrl,
|
||||
} from "./setup-core.js";
|
||||
import { nextcloudTalkSetupWizard } from "./setup-surface.js";
|
||||
import type { ResolvedNextcloudTalkAccount } from "./accounts.js";
|
||||
import type { CoreConfig } from "./types.js";
|
||||
|
||||
vi.mock("../../../src/config/bundled-channel-config-runtime.js", () => ({
|
||||
getBundledChannelRuntimeMap: () => new Map(),
|
||||
getBundledChannelConfigSchemaMap: () => new Map(),
|
||||
}));
|
||||
|
||||
const hoisted = vi.hoisted(() => ({
|
||||
monitorNextcloudTalkProvider: vi.fn(),
|
||||
loadConfig: vi.fn(),
|
||||
@@ -49,9 +44,13 @@ vi.mock("./monitor.js", async () => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./runtime.js", () => ({
|
||||
getNextcloudTalkRuntime: () => createSendCfgThreadingRuntime(hoisted),
|
||||
}));
|
||||
vi.mock("./runtime.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("./runtime.js")>();
|
||||
return {
|
||||
...actual,
|
||||
getNextcloudTalkRuntime: () => createSendCfgThreadingRuntime(hoisted),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./accounts.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("./accounts.js")>();
|
||||
@@ -80,7 +79,17 @@ vi.mock("openclaw/plugin-sdk/infra-runtime", async (importOriginal) => {
|
||||
const accountsActual = await vi.importActual<typeof import("./accounts.js")>("./accounts.js");
|
||||
hoisted.resolveNextcloudTalkAccount.mockImplementation(accountsActual.resolveNextcloudTalkAccount);
|
||||
|
||||
import { sendMessageNextcloudTalk, sendReactionNextcloudTalk } from "./send.js";
|
||||
let resolveNextcloudTalkAccount: typeof import("./accounts.js").resolveNextcloudTalkAccount;
|
||||
let nextcloudTalkPlugin: typeof import("./channel.js").nextcloudTalkPlugin;
|
||||
let clearNextcloudTalkAccountFields: typeof import("./setup-core.js").clearNextcloudTalkAccountFields;
|
||||
let nextcloudTalkDmPolicy: typeof import("./setup-core.js").nextcloudTalkDmPolicy;
|
||||
let nextcloudTalkSetupAdapter: typeof import("./setup-core.js").nextcloudTalkSetupAdapter;
|
||||
let normalizeNextcloudTalkBaseUrl: typeof import("./setup-core.js").normalizeNextcloudTalkBaseUrl;
|
||||
let setNextcloudTalkAccountConfig: typeof import("./setup-core.js").setNextcloudTalkAccountConfig;
|
||||
let validateNextcloudTalkBaseUrl: typeof import("./setup-core.js").validateNextcloudTalkBaseUrl;
|
||||
let nextcloudTalkSetupWizard: typeof import("./setup-surface.js").nextcloudTalkSetupWizard;
|
||||
let sendMessageNextcloudTalk: typeof import("./send.js").sendMessageNextcloudTalk;
|
||||
let sendReactionNextcloudTalk: typeof import("./send.js").sendReactionNextcloudTalk;
|
||||
|
||||
function buildAccount(): ResolvedNextcloudTalkAccount {
|
||||
return {
|
||||
@@ -114,6 +123,25 @@ function startNextcloudAccount(abortSignal?: AbortSignal) {
|
||||
}
|
||||
|
||||
describe("nextcloud talk setup", () => {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
({ resolveNextcloudTalkAccount } = await import("./accounts.js"));
|
||||
({ nextcloudTalkPlugin } = await import("./channel.js"));
|
||||
({
|
||||
clearNextcloudTalkAccountFields,
|
||||
nextcloudTalkDmPolicy,
|
||||
nextcloudTalkSetupAdapter,
|
||||
normalizeNextcloudTalkBaseUrl,
|
||||
setNextcloudTalkAccountConfig,
|
||||
validateNextcloudTalkBaseUrl,
|
||||
} = await import("./setup-core.js"));
|
||||
({ nextcloudTalkSetupWizard } = await import("./setup-surface.js"));
|
||||
({ sendMessageNextcloudTalk, sendReactionNextcloudTalk } = await import("./send.js"));
|
||||
hoisted.resolveNextcloudTalkAccount.mockImplementation(
|
||||
accountsActual.resolveNextcloudTalkAccount,
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
hoisted.resolveNextcloudTalkAccount.mockImplementation(
|
||||
|
||||
Reference in New Issue
Block a user