From 1d2021a71f26ebca12d6a1a86d84656ff1e03566 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Wed, 23 Sep 2026 04:26:01 -0700 Subject: [PATCH] test: restore the dashboard plugin SDK dialog/toast surface guard dropped by #120071 exposePluginSDK() is the runtime API third-party dashboard plugins consume from window.__HERMES_PLUGIN_SDK__; nothing else exercises it. Restored web/src/plugins/registry.test.ts (#50547): Dialog family, ConfirmDialog and Toast on components; useToast/useConfirmDelete (and the React hooks) on hooks. --- web/src/plugins/registry.test.ts | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 web/src/plugins/registry.test.ts diff --git a/web/src/plugins/registry.test.ts b/web/src/plugins/registry.test.ts new file mode 100644 index 0000000000..13b5e4c57a --- /dev/null +++ b/web/src/plugins/registry.test.ts @@ -0,0 +1,46 @@ +/** + * Smoke test for the plugin SDK surface additions. + * + * Verifies that `exposePluginSDK()` writes the new dialog/toast primitives to + * `window.__HERMES_PLUGIN_SDK__`. Each new key is checked individually so a + * regression in one helper doesn't mask the others. + * + * Companion to the additive PR "feat(plugins): expose Dialog/ConfirmDialog/ + * Toast/useToast/useConfirmDelete on the plugin SDK". See issue #50547. + */ +import { beforeEach, describe, expect, it } from "vitest"; +import { exposePluginSDK } from "./registry"; + +describe("plugin SDK dialog/toast surface", () => { + beforeEach(() => { + // Reset window between tests so exposePluginSDK() writes fresh. + (globalThis as unknown as { window: Record }).window = { + __HERMES_PLUGINS__: undefined, + __HERMES_PLUGIN_SDK__: undefined, + }; + }); + + it("exposes Dialog + subcomponents on components", () => { + exposePluginSDK(); + const sdk = (globalThis as unknown as { window: { __HERMES_PLUGIN_SDK__: { components: Record; hooks: Record } } }).window.__HERMES_PLUGIN_SDK__; + expect(sdk.components.Dialog).toBeDefined(); + expect(sdk.components.DialogContent).toBeDefined(); + expect(sdk.components.DialogHeader).toBeDefined(); + expect(sdk.components.DialogTitle).toBeDefined(); + expect(sdk.components.DialogDescription).toBeDefined(); + expect(sdk.components.DialogFooter).toBeDefined(); + expect(sdk.components.DialogClose).toBeDefined(); + expect(sdk.components.ConfirmDialog).toBeDefined(); + expect(sdk.components.Toast).toBeDefined(); + }); + + it("exposes useToast and useConfirmDelete on hooks", () => { + exposePluginSDK(); + const sdk = (globalThis as unknown as { window: { __HERMES_PLUGIN_SDK__: { components: Record; hooks: Record } } }).window.__HERMES_PLUGIN_SDK__; + expect(typeof sdk.hooks.useToast).toBe("function"); + expect(typeof sdk.hooks.useConfirmDelete).toBe("function"); + // Original React hooks still present (no accidental removal). + expect(typeof sdk.hooks.useState).toBe("function"); + expect(typeof sdk.hooks.useCallback).toBe("function"); + }); +}); \ No newline at end of file