Config: schema-driven channels and settings
This commit is contained in:
committed by
Peter Steinberger
parent
bcfc9bead5
commit
1ad26d6fea
@@ -36,4 +36,52 @@ describe("config schema", () => {
|
||||
);
|
||||
expect(res.uiHints["plugins.entries.voice-call.config.twilio.authToken"]?.sensitive).toBe(true);
|
||||
});
|
||||
|
||||
it("merges plugin + channel schemas", () => {
|
||||
const res = buildConfigSchema({
|
||||
plugins: [
|
||||
{
|
||||
id: "voice-call",
|
||||
name: "Voice Call",
|
||||
configSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
provider: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
channels: [
|
||||
{
|
||||
id: "matrix",
|
||||
label: "Matrix",
|
||||
configSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
accessToken: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const schema = res.schema as {
|
||||
properties?: Record<string, unknown>;
|
||||
};
|
||||
const pluginsNode = schema.properties?.plugins as Record<string, unknown> | undefined;
|
||||
const entriesNode = pluginsNode?.properties as Record<string, unknown> | undefined;
|
||||
const entriesProps = entriesNode?.entries as Record<string, unknown> | undefined;
|
||||
const entryProps = entriesProps?.properties as Record<string, unknown> | undefined;
|
||||
const pluginEntry = entryProps?.["voice-call"] as Record<string, unknown> | undefined;
|
||||
const pluginConfig = pluginEntry?.properties as Record<string, unknown> | undefined;
|
||||
const pluginConfigSchema = pluginConfig?.config as Record<string, unknown> | undefined;
|
||||
const pluginConfigProps = pluginConfigSchema?.properties as Record<string, unknown> | undefined;
|
||||
expect(pluginConfigProps?.provider).toBeTruthy();
|
||||
|
||||
const channelsNode = schema.properties?.channels as Record<string, unknown> | undefined;
|
||||
const channelsProps = channelsNode?.properties as Record<string, unknown> | undefined;
|
||||
const channelSchema = channelsProps?.matrix as Record<string, unknown> | undefined;
|
||||
const channelProps = channelSchema?.properties as Record<string, unknown> | undefined;
|
||||
expect(channelProps?.accessToken).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user