mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-23 14:45:46 +00:00
fix(line): narrow plugin-sdk seams after refactor
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { type OpenClawConfig, tryReadSecretFileSync } from "openclaw/plugin-sdk/core";
|
||||
import {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
normalizeAccountId as normalizeSharedAccountId,
|
||||
normalizeOptionalAccountId,
|
||||
} from "openclaw/plugin-sdk/account-id";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/account-resolution";
|
||||
import { resolveAccountEntry } from "openclaw/plugin-sdk/account-resolution";
|
||||
import { tryReadSecretFileSync } from "../../../src/infra/secret-file.js";
|
||||
import type {
|
||||
LineAccountConfig,
|
||||
LineConfig,
|
||||
|
||||
@@ -5,11 +5,15 @@ import type { LineAccountConfig } from "./types.js";
|
||||
|
||||
// Avoid pulling in globals/pairing/media dependencies; this suite only asserts
|
||||
// allowlist/groupPolicy gating and message-context wiring.
|
||||
vi.mock("openclaw/plugin-sdk/runtime-env", () => ({
|
||||
danger: (text: string) => text,
|
||||
logVerbose: () => {},
|
||||
shouldLogVerbose: () => false,
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/runtime-env", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/runtime-env")>();
|
||||
return {
|
||||
...actual,
|
||||
danger: (text: string) => text,
|
||||
logVerbose: () => {},
|
||||
shouldLogVerbose: () => false,
|
||||
};
|
||||
});
|
||||
|
||||
const { readAllowFromStoreMock, upsertPairingRequestMock } = vi.hoisted(() => ({
|
||||
readAllowFromStoreMock: vi.fn(async () => [] as string[]),
|
||||
@@ -700,10 +704,7 @@ describe("handleLineWebhookEvents", () => {
|
||||
|
||||
it("records unmentioned group messages as pending history", async () => {
|
||||
const processMessage = vi.fn();
|
||||
const groupHistories = new Map<
|
||||
string,
|
||||
HistoryEntry[]
|
||||
>();
|
||||
const groupHistories = new Map<string, HistoryEntry[]>();
|
||||
const event = createTestMessageEvent({
|
||||
message: { id: "m-hist-1", type: "text", text: "hello history", quoteToken: "q-hist-1" },
|
||||
timestamp: 1700000000000,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
|
||||
import { z } from "zod";
|
||||
import { buildChannelConfigSchema } from "openclaw/plugin-sdk/core";
|
||||
|
||||
const DmPolicySchema = z.enum(["open", "allowlist", "pairing", "disabled"]);
|
||||
const GroupPolicySchema = z.enum(["open", "allowlist", "disabled"]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/core";
|
||||
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/account-resolution";
|
||||
import { resolveAccountEntry } from "openclaw/plugin-sdk/account-resolution";
|
||||
import type { LineConfig, LineGroupConfig } from "./types.js";
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { messagingApi } from "@line/bot-sdk";
|
||||
import { stripMarkdown } from "openclaw/plugin-sdk/text-runtime";
|
||||
import { createReceiptCard, toFlexMessage, type FlexBubble } from "./flex-templates.js";
|
||||
export { stripMarkdown } from "openclaw/plugin-sdk/text-runtime";
|
||||
|
||||
type FlexMessage = messagingApi.FlexMessage;
|
||||
type FlexComponent = messagingApi.FlexComponent;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { createLineBotMock, registerPluginHttpRouteMock, unregisterHttpMock } = vi.hoisted(() => ({
|
||||
createLineBotMock: vi.fn(() => ({
|
||||
@@ -20,11 +20,15 @@ vi.mock("openclaw/plugin-sdk/reply-runtime", () => ({
|
||||
dispatchReplyWithBufferedBlockDispatcher: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/runtime-env", () => ({
|
||||
danger: (value: unknown) => String(value),
|
||||
logVerbose: vi.fn(),
|
||||
waitForAbortSignal: vi.fn(),
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/runtime-env", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/runtime-env")>();
|
||||
return {
|
||||
...actual,
|
||||
danger: (value: unknown) => String(value),
|
||||
logVerbose: vi.fn(),
|
||||
waitForAbortSignal: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/channel-reply-pipeline", () => ({
|
||||
createChannelReplyPipeline: vi.fn(() => ({})),
|
||||
|
||||
@@ -63,9 +63,13 @@ vi.mock("openclaw/plugin-sdk/infra-runtime", () => ({
|
||||
recordChannelActivity: recordChannelActivityMock,
|
||||
}));
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/runtime-env", () => ({
|
||||
logVerbose: logVerboseMock,
|
||||
}));
|
||||
vi.mock("openclaw/plugin-sdk/runtime-env", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/runtime-env")>();
|
||||
return {
|
||||
...actual,
|
||||
logVerbose: logVerboseMock,
|
||||
};
|
||||
});
|
||||
|
||||
let sendModule: typeof import("./send.js");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user