mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
Scope plugin config bridge reads to invocation company
This commit is contained in:
parent
1580e3b755
commit
8969a713a1
2 changed files with 52 additions and 2 deletions
42
server/src/__tests__/plugin-config-bridge.test.ts
Normal file
42
server/src/__tests__/plugin-config-bridge.test.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { describe, expect, it, vi } from "vitest";
|
||||
import { createHostClientHandlers } from "../../../packages/plugins/sdk/src/host-client-factory.js";
|
||||
|
||||
describe("plugin config bridge scoping", () => {
|
||||
it("falls back to the invocation company scope for config.get when the worker omits companyId", async () => {
|
||||
const getConfig = vi.fn(async (params: { companyId?: string | null }) => ({
|
||||
scope: params.companyId ?? null,
|
||||
}));
|
||||
|
||||
const handlers = createHostClientHandlers({
|
||||
pluginId: "test.plugin",
|
||||
capabilities: [],
|
||||
services: {
|
||||
config: { get: getConfig },
|
||||
} as never,
|
||||
});
|
||||
|
||||
await expect(
|
||||
handlers["config.get"]({}, { invocationScope: { companyId: "company-a" } }),
|
||||
).resolves.toEqual({ scope: "company-a" });
|
||||
expect(getConfig).toHaveBeenCalledWith({ companyId: "company-a" });
|
||||
});
|
||||
|
||||
it("preserves an explicit global config.get request even inside a company-scoped invocation", async () => {
|
||||
const getConfig = vi.fn(async (params: { companyId?: string | null }) => ({
|
||||
scope: params.companyId ?? null,
|
||||
}));
|
||||
|
||||
const handlers = createHostClientHandlers({
|
||||
pluginId: "test.plugin",
|
||||
capabilities: [],
|
||||
services: {
|
||||
config: { get: getConfig },
|
||||
} as never,
|
||||
});
|
||||
|
||||
await expect(
|
||||
handlers["config.get"]({ companyId: null }, { invocationScope: { companyId: "company-a" } }),
|
||||
).resolves.toEqual({ scope: null });
|
||||
expect(getConfig).toHaveBeenCalledWith({ companyId: null });
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue