mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
Follow-up to the plugins framework (#3041): wires the plugin hooks end-to-end and adds full test coverage. - Wires `onRequest` / `onResponse` / `onError` hooks into the chat pipeline (`chatCore` now imports from the unified `hooks` registry). - Loads active plugins on server startup (`pluginManager.loadAll()` in `server-init`) so they survive restarts. - Ships a `welcome-banner` example plugin (`examples/plugins/`) + test fixture. - Adds a comprehensive plugin test suite (manifest, db, config, hooks, manager lifecycle, loader IPC, permissions, scanner, welcome-banner e2e). Integration fixes applied during review: - `manager.install` now removes an orphaned `destDir` (DB row gone but files left on disk) before the atomic rename, guarded by path containment — it previously failed with `ENOTEMPTY` (a regression surfaced by the new lifecycle test). - `plugins-db` / `plugins-manager-lifecycle` tests now initialize the DB via the real migration `076` (`getDbInstance`) rather than relying on ambient state, so a missing/renumbered migration fails loudly instead of being masked. 348/348 plugin tests pass; typecheck / cycles clean. Co-authored-by: oyi77 <14921983+oyi77@users.noreply.github.com>
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
// Test plugin API route structure and type contracts.
|
|
// Full HTTP integration tests require the Next.js test harness.
|
|
|
|
describe("plugin API routes", () => {
|
|
describe("route modules exist", () => {
|
|
it("main plugins route exports GET and POST", async () => {
|
|
const mod = await import("../../src/app/api/plugins/route.ts");
|
|
assert.equal(typeof mod.GET, "function");
|
|
assert.equal(typeof mod.POST, "function");
|
|
});
|
|
|
|
it("[name] route exports GET and DELETE", async () => {
|
|
const mod = await import("../../src/app/api/plugins/[name]/route.ts");
|
|
assert.equal(typeof mod.GET, "function");
|
|
assert.equal(typeof mod.DELETE, "function");
|
|
});
|
|
|
|
it("activate route exports POST", async () => {
|
|
const mod = await import("../../src/app/api/plugins/[name]/activate/route.ts");
|
|
assert.equal(typeof mod.POST, "function");
|
|
});
|
|
|
|
it("deactivate route exports POST", async () => {
|
|
const mod = await import("../../src/app/api/plugins/[name]/deactivate/route.ts");
|
|
assert.equal(typeof mod.POST, "function");
|
|
});
|
|
|
|
it("config route exports GET and PUT", async () => {
|
|
const mod = await import("../../src/app/api/plugins/[name]/config/route.ts");
|
|
assert.equal(typeof mod.GET, "function");
|
|
assert.equal(typeof mod.PUT, "function");
|
|
});
|
|
|
|
it("scan route exports POST", async () => {
|
|
const mod = await import("../../src/app/api/plugins/scan/route.ts");
|
|
assert.equal(typeof mod.POST, "function");
|
|
});
|
|
});
|
|
});
|