import { describe, expect, test } from "bun:test"; import { renderToStaticMarkup } from "react-dom/server"; import { ExtensionsView } from "../src/react-app/domains/settings/pages/extensions-view"; import type { PluginsExtensionsStore } from "../src/react-app/domains/settings/pages/plugins-view"; import type { ExtensionInventoryGroup } from "../src/react-app/domains/settings/extension-items"; import { countInventoryCardGroups, ExtensionStateTabs, filterInventoryCardsByState, } from "../src/react-app/domains/settings/pages/mcp-view"; const extensions: PluginsExtensionsStore = { pluginScope: "project", setPluginScope: () => {}, refreshPlugins: () => {}, pluginConfigPath: () => null, pluginConfig: () => null, pluginList: () => [], pluginInput: () => "", setPluginInput: () => {}, pluginStatus: () => null, addPlugin: () => {}, removePlugin: () => {}, isPluginInstalledByName: () => false, activePluginGuide: () => null, setActivePluginGuide: () => {}, }; describe("Library state tabs", () => { test("renders the Ready to use count without a connected-app chip", () => { const counts = countInventoryCardGroups([ "ready", "needs_signin", "ready", "needs_admin_setup", "ready", ]); const html = renderToStaticMarkup( {}} mcpView={() => ( {}} /> )} />, ); expect(html).toContain("Skills, commands, agents, connections, and tools your agent can use."); expect(html).toContain("Ready to use"); expect(html).toContain(">3"); expect(html.toLowerCase()).not.toContain("app connected"); expect(html.toLowerCase()).not.toContain("apps connected"); }); test("selecting Ready filters the assembled cards to ready rows", () => { const cards: Array<{ name: string; group: ExtensionInventoryGroup }> = [ { name: "Local skill", group: "ready" }, { name: "Calendar", group: "needs_signin" }, { name: "Installed plugin", group: "ready" }, ]; expect(filterInventoryCardsByState(cards, "ready")).toEqual([ cards[0], cards[2], ]); }); });