|
1 | 1 | import fs from "node:fs"; |
2 | 2 | import path from "node:path"; |
3 | 3 | import { afterEach, describe, expect, it, vi } from "vitest"; |
| 4 | +import { collectChannelSchemaMetadata } from "../config/channel-config-metadata.js"; |
| 5 | +import { collectBundledChannelConfigs } from "./bundled-channel-config-metadata.js"; |
4 | 6 | import type { PluginCandidate } from "./discovery.js"; |
5 | 7 | import { |
6 | 8 | clearPluginManifestRegistryCache, |
@@ -630,6 +632,107 @@ describe("loadPluginManifestRegistry", () => { |
630 | 632 | }); |
631 | 633 | }); |
632 | 634 |
|
| 635 | + it("hydrates bundled channel config metadata from plugin-local config surfaces", () => { |
| 636 | + const dir = makeTempDir(); |
| 637 | + writeManifest(dir, { |
| 638 | + id: "alpha", |
| 639 | + channels: ["alpha"], |
| 640 | + configSchema: { type: "object" }, |
| 641 | + channelConfigs: { |
| 642 | + alpha: { |
| 643 | + schema: { |
| 644 | + type: "object", |
| 645 | + properties: { |
| 646 | + manifestOnly: { type: "boolean" }, |
| 647 | + }, |
| 648 | + }, |
| 649 | + uiHints: { |
| 650 | + manifestOnly: { help: "manifest hint" }, |
| 651 | + }, |
| 652 | + }, |
| 653 | + }, |
| 654 | + }); |
| 655 | + writeTextFile(dir, "index.ts", "export {};\n"); |
| 656 | + writeTextFile( |
| 657 | + dir, |
| 658 | + "src/config-schema.js", |
| 659 | + [ |
| 660 | + "export const AlphaChannelConfigSchema = {", |
| 661 | + " schema: {", |
| 662 | + " type: 'object',", |
| 663 | + " properties: {", |
| 664 | + " generatedOnly: { type: 'string' },", |
| 665 | + " },", |
| 666 | + " additionalProperties: false,", |
| 667 | + " },", |
| 668 | + " uiHints: {", |
| 669 | + " generatedOnly: { label: 'Generated only' },", |
| 670 | + " },", |
| 671 | + "};", |
| 672 | + ].join("\n"), |
| 673 | + ); |
| 674 | + |
| 675 | + const candidate = createPluginCandidate({ |
| 676 | + idHint: "alpha", |
| 677 | + rootDir: dir, |
| 678 | + origin: "bundled", |
| 679 | + packageDir: dir, |
| 680 | + packageManifest: { |
| 681 | + channel: { |
| 682 | + id: "alpha", |
| 683 | + label: "Alpha", |
| 684 | + blurb: "Alpha channel", |
| 685 | + }, |
| 686 | + }, |
| 687 | + }); |
| 688 | + expect(loadRegistry([candidate]).plugins[0]?.channelConfigs?.alpha?.schema).toEqual({ |
| 689 | + type: "object", |
| 690 | + properties: { |
| 691 | + manifestOnly: { type: "boolean" }, |
| 692 | + }, |
| 693 | + }); |
| 694 | + |
| 695 | + const registry = loadPluginManifestRegistry({ |
| 696 | + cache: false, |
| 697 | + bundledChannelConfigCollector: collectBundledChannelConfigs, |
| 698 | + candidates: [candidate], |
| 699 | + }); |
| 700 | + |
| 701 | + expect(registry.plugins[0]?.channelConfigs?.alpha).toEqual({ |
| 702 | + schema: { |
| 703 | + type: "object", |
| 704 | + properties: { |
| 705 | + generatedOnly: { type: "string" }, |
| 706 | + }, |
| 707 | + additionalProperties: false, |
| 708 | + }, |
| 709 | + label: "Alpha", |
| 710 | + description: "Alpha channel", |
| 711 | + uiHints: { |
| 712 | + generatedOnly: { label: "Generated only" }, |
| 713 | + manifestOnly: { help: "manifest hint" }, |
| 714 | + }, |
| 715 | + }); |
| 716 | + expect(collectChannelSchemaMetadata(registry)).toEqual([ |
| 717 | + { |
| 718 | + id: "alpha", |
| 719 | + label: "Alpha", |
| 720 | + description: "Alpha channel", |
| 721 | + configSchema: { |
| 722 | + type: "object", |
| 723 | + properties: { |
| 724 | + generatedOnly: { type: "string" }, |
| 725 | + }, |
| 726 | + additionalProperties: false, |
| 727 | + }, |
| 728 | + configUiHints: { |
| 729 | + generatedOnly: { label: "Generated only" }, |
| 730 | + manifestOnly: { help: "manifest hint" }, |
| 731 | + }, |
| 732 | + }, |
| 733 | + ]); |
| 734 | + }); |
| 735 | + |
633 | 736 | it("reports non-bundled providerAuthEnvVars as deprecated compat metadata", () => { |
634 | 737 | const dir = makeTempDir(); |
635 | 738 | writeManifest(dir, { |
|
0 commit comments