* refactor(marketplace): drive auto-seeding from signed verified registry Retires the hard-coded DEFAULT_PLUGIN_IDS list and makes the signed verified registry the single source of truth for what lands in a fresh install. Publishing a plugin to the verified registry now auto-seeds it; no code change required to add new defaults. Also fixes the diagnosed plugins-404: fortiguard and nz-traffic-cameras were in the static list but not published to npm, causing every fresh boot to hit manifest 404s. Those entries are gone with the list. - Delete src/lib/marketplace/defaultPlugins.ts (legacy static list). - Seeder iterates getVerifiedPluginIds() from registryClient. - Skip markSeeded when the verified set is empty so a registry outage doesn't lock fresh installs into zero plugins; the next request retries (5-min cache in registryClient bounds the request rate). - Stamp every seeded plugin as trust=verified by definition. - Tests rewritten against a fake verified set; new test asserts empty-registry deferral. - Sync marketplace-architecture rule + migrate-legacy-plugin skill with the new model. - Patch bump: 2.15.15 -> 2.15.16. * fix(engine): resolve plugin 404s and local engine routing (#fix/diagnose-plugins-404) - fix: engineManifest + resolveEngineUrl: port 5001→5000 to match docker-compose binding; removed NEXT_PUBLIC_WWV_PLUGIN_DATA_ENGINE_URL from local engine detection — it was poisoning local routing with the production engine URL (Patch) - fix: WsClient: added normalizePluginId() converting underscore IDs to kebab-case so engine WebSocket messages route to the correct frontend plugin (Patch) - fix: docker-compose: added ./local-seeders:/app/seeders volume mount to wwv-data-engine so locally-developed seeders are visible to the engine (Patch) - feat: sync-local-plugins: added wwvHostRedirectPlugin — Vite plugin that intercepts @/ host-app imports in local plugin builds and redirects them to runtime host globals, preventing full app tree from being bundled into plugins (Minor) - docs: plugin-architecture.md: added Plugin Data Delivery Types section (REST-only, WS-only, hybrid), peerDependencies rule, .tsx extension rule, mapWebsocketPayload signature contract (Patch) - docs: data-engine-architecture.md: added §7 WebSocket Payload Format Contract documenting WsClient's three payload handling cases and the silent-drop footgun for plugins that send object payloads without mapWebsocketPayload (Patch) - docs: worldwideview-plugin-creation SKILL.md: fixed ISS example which was missing mapWebsocketPayload and would have silently dropped all WS data; clarified mapWebsocketPayload requirement for non-array payloads; fixed architecture decision tree (Patch) - docs: cesium-rendering.md: added Sizing Conventions table with defaults/ranges for point/billboard/model, cross-plugin parity rules, and silent-ignore footgun warning for size on billboard entities (Patch) - docs: added ADR-0002 documenting seeder exported name as canonical plugin ID (Patch) Version bumps: fix × 3 (Patch), feat × 1 (Minor) → 2.15.16 → 2.16.0 Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * test(engine): update resolveEngineUrl test assertion from port 5001 to 5000 Follows the port correction in engineManifest.ts and resolveEngineUrl.ts. The test was asserting the old default (5001) instead of the corrected local engine port (5000), causing the Unit Tests CI check to fail. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
99 lines
3.0 KiB
TypeScript
99 lines
3.0 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
import {
|
|
describe, it, expect, vi, beforeEach
|
|
} from "vitest";
|
|
import { pluginManager } from "@/core/plugins/PluginManager";
|
|
import { fetchLocalEngineManifest, localEngineHasPlugin, resetManifestCache } from "./engineManifest";
|
|
import { resolveEngineUrl } from "./resolveEngineUrl";
|
|
|
|
// Mock PluginManager
|
|
vi.mock("@/core/plugins/PluginManager", () => ({
|
|
pluginManager: {
|
|
getPlugin: vi.fn(),
|
|
getManifest: vi.fn(),
|
|
},
|
|
}));
|
|
|
|
describe("EngineManifest", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
resetManifestCache();
|
|
global.fetch = vi.fn() as any;
|
|
});
|
|
|
|
it("should fetch manifest from local engine and cache it", async () => {
|
|
(global.fetch as any).mockResolvedValue({
|
|
ok: true,
|
|
json: async () => ({ plugins: ["plugin-a", "plugin-b"] }),
|
|
});
|
|
|
|
const plugins = await fetchLocalEngineManifest();
|
|
expect(plugins).toEqual(["plugin-a", "plugin-b"]);
|
|
expect(localEngineHasPlugin("plugin-a")).toBe(true);
|
|
expect(localEngineHasPlugin("plugin-c")).toBe(false);
|
|
|
|
// Second call should used cache
|
|
await fetchLocalEngineManifest();
|
|
expect(global.fetch).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("should return null and cache failure if local engine is missing", async () => {
|
|
(global.fetch as any).mockRejectedValue(new Error("Connection refused"));
|
|
|
|
const plugins = await fetchLocalEngineManifest();
|
|
expect(plugins).toBeNull();
|
|
|
|
// Should not retry fetch
|
|
await fetchLocalEngineManifest();
|
|
expect(global.fetch).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|
|
|
|
describe("resolveEngineUrl", () => {
|
|
beforeEach(() => {
|
|
resetManifestCache();
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("should prioritize local engine if plugin is found there", async () => {
|
|
// Setup local manifest
|
|
(global.fetch as any).mockResolvedValue({
|
|
ok: true,
|
|
json: async () => ({ plugins: ["plugin-local"] }),
|
|
});
|
|
await fetchLocalEngineManifest();
|
|
|
|
const url = resolveEngineUrl("plugin-local");
|
|
expect(url).toContain("localhost:5000/stream");
|
|
});
|
|
|
|
it("should fall back to plugin's custom streamUrl if not local", () => {
|
|
(pluginManager.getPlugin as any).mockReturnValue({
|
|
plugin: {
|
|
getServerConfig: () => ({ streamUrl: "ws://custom-engine/stream" })
|
|
}
|
|
});
|
|
|
|
const url = resolveEngineUrl("plugin-custom");
|
|
expect(url).toBe("ws://custom-engine/stream");
|
|
});
|
|
|
|
it("should fall back to manifest streamUrl if provided", () => {
|
|
(pluginManager.getPlugin as any).mockReturnValue(undefined);
|
|
(pluginManager.getManifest as any).mockReturnValue({
|
|
dataSource: { streamUrl: "ws://manifest-engine/stream" }
|
|
});
|
|
|
|
const url = resolveEngineUrl("plugin-manifest");
|
|
expect(url).toBe("ws://manifest-engine/stream");
|
|
});
|
|
|
|
it("should use default cloud engine as last resort", () => {
|
|
(pluginManager.getPlugin as any).mockReturnValue(undefined);
|
|
(pluginManager.getManifest as any).mockReturnValue(undefined);
|
|
|
|
const url = resolveEngineUrl("unknown-plugin");
|
|
expect(url).toContain("worldwideview.dev/stream");
|
|
});
|
|
});
|