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:
Masato Hoshino
2026-03-29 10:51:16 +09:00
committed by GitHub
parent f93ccc3443
commit 9449e54f4f
9 changed files with 727 additions and 19 deletions

View File

@@ -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);
});
});