mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-31 03:41:51 +00:00
feat(line): add outbound media support for image, video, and audio
pnpm install --frozen-lockfile pnpm build pnpm check pnpm vitest run extensions/line/src/channel.sendPayload.test.ts extensions/line/src/send.test.ts extensions/line/src/outbound-media.test.ts Co-authored-by: masatohoshino <246810661+masatohoshino@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { createEmptyPluginRegistry } from "./registry.js";
|
||||
import type { PluginHttpRouteRegistration } from "./registry.js";
|
||||
import {
|
||||
getActivePluginHttpRouteRegistryVersion,
|
||||
getActivePluginRegistryVersion,
|
||||
@@ -132,3 +133,91 @@ describe("plugin runtime route registry", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const makeRoute = (path: string): PluginHttpRouteRegistration => ({
|
||||
path,
|
||||
handler: () => {},
|
||||
auth: "gateway",
|
||||
match: "exact",
|
||||
});
|
||||
|
||||
describe("setActivePluginRegistry", () => {
|
||||
beforeEach(() => {
|
||||
resetPluginRuntimeStateForTest();
|
||||
setActivePluginRegistry(createEmptyPluginRegistry());
|
||||
});
|
||||
|
||||
it("does not carry forward httpRoutes when new registry has none", () => {
|
||||
const oldRegistry = createEmptyPluginRegistry();
|
||||
const fakeRoute = makeRoute("/test");
|
||||
oldRegistry.httpRoutes.push(fakeRoute);
|
||||
setActivePluginRegistry(oldRegistry);
|
||||
expect(getActivePluginRegistry()?.httpRoutes).toHaveLength(1);
|
||||
|
||||
const newRegistry = createEmptyPluginRegistry();
|
||||
expect(newRegistry.httpRoutes).toHaveLength(0);
|
||||
setActivePluginRegistry(newRegistry);
|
||||
expect(getActivePluginRegistry()?.httpRoutes).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("does not carry forward when new registry already has routes", () => {
|
||||
const oldRegistry = createEmptyPluginRegistry();
|
||||
oldRegistry.httpRoutes.push(makeRoute("/old"));
|
||||
setActivePluginRegistry(oldRegistry);
|
||||
|
||||
const newRegistry = createEmptyPluginRegistry();
|
||||
const newRoute = makeRoute("/new");
|
||||
newRegistry.httpRoutes.push(newRoute);
|
||||
setActivePluginRegistry(newRegistry);
|
||||
expect(getActivePluginRegistry()?.httpRoutes).toHaveLength(1);
|
||||
expect(getActivePluginRegistry()?.httpRoutes[0]).toEqual(newRoute);
|
||||
});
|
||||
|
||||
it("does not carry forward when same registry is set again", () => {
|
||||
const registry = createEmptyPluginRegistry();
|
||||
registry.httpRoutes.push(makeRoute("/test"));
|
||||
setActivePluginRegistry(registry);
|
||||
setActivePluginRegistry(registry);
|
||||
expect(getActivePluginRegistry()?.httpRoutes).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setActivePluginRegistry", () => {
|
||||
beforeEach(() => {
|
||||
setActivePluginRegistry(createEmptyPluginRegistry());
|
||||
});
|
||||
|
||||
it("does not carry forward httpRoutes when new registry has none", () => {
|
||||
const oldRegistry = createEmptyPluginRegistry();
|
||||
const fakeRoute = makeRoute("/test");
|
||||
oldRegistry.httpRoutes.push(fakeRoute);
|
||||
setActivePluginRegistry(oldRegistry);
|
||||
expect(getActivePluginRegistry()?.httpRoutes).toHaveLength(1);
|
||||
|
||||
const newRegistry = createEmptyPluginRegistry();
|
||||
expect(newRegistry.httpRoutes).toHaveLength(0);
|
||||
setActivePluginRegistry(newRegistry);
|
||||
expect(getActivePluginRegistry()?.httpRoutes).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("does not carry forward when new registry already has routes", () => {
|
||||
const oldRegistry = createEmptyPluginRegistry();
|
||||
oldRegistry.httpRoutes.push(makeRoute("/old"));
|
||||
setActivePluginRegistry(oldRegistry);
|
||||
|
||||
const newRegistry = createEmptyPluginRegistry();
|
||||
const newRoute = makeRoute("/new");
|
||||
newRegistry.httpRoutes.push(newRoute);
|
||||
setActivePluginRegistry(newRegistry);
|
||||
expect(getActivePluginRegistry()?.httpRoutes).toHaveLength(1);
|
||||
expect(getActivePluginRegistry()?.httpRoutes[0]).toEqual(newRoute);
|
||||
});
|
||||
|
||||
it("does not carry forward when same registry is set again", () => {
|
||||
const registry = createEmptyPluginRegistry();
|
||||
registry.httpRoutes.push(makeRoute("/test"));
|
||||
setActivePluginRegistry(registry);
|
||||
setActivePluginRegistry(registry);
|
||||
expect(getActivePluginRegistry()?.httpRoutes).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user