





















@@ -1,6 +1,8 @@
11import { describe, expect, it, vi } from "vitest";
22import type { OpenClawConfig, PluginRuntime } from "../api.js";
3-import { linePlugin } from "./channel.js";
3+import { lineConfigAdapter } from "./config-adapter.js";
4+import { resolveLineGroupRequireMention } from "./group-policy.js";
5+import { lineOutboundAdapter } from "./outbound.js";
46import { setLineRuntime } from "./runtime.js";
5768type LineRuntimeMocks = {
@@ -87,43 +89,7 @@ function createRuntime(): { runtime: PluginRuntime; mocks: LineRuntimeMocks } {
8789};
8890}
899190-describe("linePlugin outbound.sendPayload", () => {
91-it("preserves resolved accountId when pairing notifications push directly", async () => {
92-const { runtime, mocks } = createRuntime();
93-setLineRuntime(runtime);
94-const cfg = {
95-channels: {
96-line: {
97-accounts: {
98-primary: {
99-channelAccessToken: "token-primary",
100-},
101-},
102-},
103-},
104-} as OpenClawConfig;
105-mocks.resolveLineAccount.mockReturnValue({
106-accountId: "primary",
107-channelAccessToken: "token-primary",
108-config: {},
109-});
110-111-await linePlugin.pairing!.notifyApproval!({
112- cfg,
113-id: "line:user:1",
114-});
115-116-expect(mocks.pushMessageLine).toHaveBeenCalledWith(
117-"line:user:1",
118-"OpenClaw: your access has been approved.",
119-{
120- cfg,
121-accountId: "primary",
122-channelAccessToken: "token-primary",
123-},
124-);
125-});
126-92+describe("line outbound sendPayload", () => {
12793it("sends flex message without dropping text", async () => {
12894const { runtime, mocks } = createRuntime();
12995setLineRuntime(runtime);
@@ -141,7 +107,7 @@ describe("linePlugin outbound.sendPayload", () => {
141107},
142108};
143109144-await linePlugin.outbound!.sendPayload!({
110+await lineOutboundAdapter.sendPayload!({
145111to: "line:group:1",
146112text: payload.text,
147113 payload,
@@ -178,7 +144,7 @@ describe("linePlugin outbound.sendPayload", () => {
178144},
179145};
180146181-await linePlugin.outbound!.sendPayload!({
147+await lineOutboundAdapter.sendPayload!({
182148to: "line:user:1",
183149text: payload.text,
184150 payload,
@@ -212,7 +178,7 @@ describe("linePlugin outbound.sendPayload", () => {
212178},
213179};
214180215-await linePlugin.outbound!.sendPayload!({
181+await lineOutboundAdapter.sendPayload!({
216182to: "line:user:2",
217183text: "",
218184 payload,
@@ -251,7 +217,7 @@ describe("linePlugin outbound.sendPayload", () => {
251217},
252218};
253219254-await linePlugin.outbound!.sendPayload!({
220+await lineOutboundAdapter.sendPayload!({
255221to: "line:user:3",
256222text: payload.text,
257223 payload,
@@ -285,7 +251,7 @@ describe("linePlugin outbound.sendPayload", () => {
285251setLineRuntime(runtime);
286252const cfg = { channels: { line: {} } } as OpenClawConfig;
287253288-await linePlugin.outbound!.sendPayload!({
254+await lineOutboundAdapter.sendPayload!({
289255to: "line:user:4",
290256text: "",
291257payload: {
@@ -308,7 +274,7 @@ describe("linePlugin outbound.sendPayload", () => {
308274setLineRuntime(runtime);
309275const cfg = { channels: { line: {} } } as OpenClawConfig;
310276311-await linePlugin.outbound!.sendPayload!({
277+await lineOutboundAdapter.sendPayload!({
312278to: "line:user:5",
313279text: "",
314280payload: {
@@ -354,7 +320,7 @@ describe("linePlugin outbound.sendPayload", () => {
354320},
355321};
356322357-await linePlugin.outbound!.sendPayload!({
323+await lineOutboundAdapter.sendPayload!({
358324to: "line:user:3",
359325text: payload.text,
360326 payload,
@@ -386,7 +352,7 @@ describe("linePlugin outbound.sendPayload", () => {
386352},
387353};
388354389-await linePlugin.outbound!.sendPayload!({
355+await lineOutboundAdapter.sendPayload!({
390356to: "line:group:C123",
391357text: payload.text,
392358 payload,
@@ -426,7 +392,7 @@ describe("linePlugin outbound.sendPayload", () => {
426392},
427393};
428394429-await linePlugin.outbound!.sendPayload!({
395+await lineOutboundAdapter.sendPayload!({
430396to: "line:user:U123",
431397text: payload.text,
432398 payload,
@@ -466,7 +432,7 @@ describe("linePlugin outbound.sendPayload", () => {
466432};
467433468434await expect(
469-linePlugin.outbound!.sendPayload!({
435+lineOutboundAdapter.sendPayload!({
470436to: "line:user:U123",
471437text: payload.text,
472438 payload,
@@ -479,7 +445,7 @@ describe("linePlugin outbound.sendPayload", () => {
479445480446describe("linePlugin config.formatAllowFrom", () => {
481447it("strips line:user: prefixes without lowercasing", () => {
482-const formatted = linePlugin.config.formatAllowFrom!({
448+const formatted = lineConfigAdapter.formatAllowFrom!({
483449cfg: {} as OpenClawConfig,
484450allowFrom: ["line:user:UABC", "line:UDEF"],
485451});
@@ -509,7 +475,7 @@ describe("linePlugin groups.resolveRequireMention", () => {
509475},
510476} as OpenClawConfig;
511477512-const requireMention = linePlugin.groups!.resolveRequireMention!({
478+const requireMention = resolveLineGroupRequireMention({
513479 cfg,
514480accountId: "primary",
515481groupId: "group-1",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。