Download web/src/plugins/registry.test.ts from SaylorTwift/hermes-agent: direct link, hf CLI and curl.
- Browser
- Download file 2.19 kB
-
https://huggingface.co/SaylorTwift/hermes-agent/resolve/main/web/src/plugins/registry.test.ts
- Command line
-
hf download hf://SaylorTwift/hermes-agent/web/src/plugins/registry.test.ts
-
curl -L -o registry.test.ts https://huggingface.co/SaylorTwift/hermes-agent/resolve/main/web/src/plugins/registry.test.ts
2.19 kB
| /** | |
| * 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<string, unknown> }).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<string, unknown>; hooks: Record<string, unknown> } } }).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<string, unknown>; hooks: Record<string, unknown> } } }).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"); | |
| }); | |
| }); |