mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-28 12:12:47 +00:00
* feat(plugin): allow composer pill contributions Keep pill presentation host-owned while plugin components render contextual content. Pill callbacks reuse the selected host's API, RPC, surface, and registered-panel navigation capabilities without exposing router or workspace layout internals. * fix(plugin): place composer pills in track bar * fix(plugin): make composer pills client-owned
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { QueryClient } from "@tanstack/react-query";
|
|
import { describe, expect, it } from "vitest";
|
|
import type { InstalledPlugin } from "./types";
|
|
import { groupPluginSidebarContributions } from "./sidebar-groups";
|
|
|
|
function installed(serverId: string, contributionId = "main"): InstalledPlugin {
|
|
return {
|
|
id: "example",
|
|
cleanup: () => undefined,
|
|
serverId,
|
|
clientBundle: serverId,
|
|
queryClient: new QueryClient(),
|
|
surfaces: [{ id: "surface", Component: () => null }],
|
|
sidebarItems: [
|
|
{
|
|
id: contributionId,
|
|
title: "Example",
|
|
icon: "Blocks",
|
|
surface: "surface",
|
|
},
|
|
],
|
|
workspacePanels: [],
|
|
commandCenterItems: [],
|
|
clientSide: null,
|
|
attachmentSources: [],
|
|
themes: [],
|
|
timelineTransformers: [],
|
|
timelineRenderers: [],
|
|
};
|
|
}
|
|
|
|
describe("groupPluginSidebarContributions", () => {
|
|
it("coalesces the same plugin contribution across hosts", () => {
|
|
const groups = groupPluginSidebarContributions([installed("host-a"), installed("host-b")]);
|
|
|
|
expect(groups).toHaveLength(1);
|
|
expect(groups[0]?.targets.map((target) => target.plugin.serverId)).toEqual([
|
|
"host-a",
|
|
"host-b",
|
|
]);
|
|
});
|
|
|
|
it("keeps different contribution ids separate", () => {
|
|
const groups = groupPluginSidebarContributions([
|
|
installed("host-a", "main"),
|
|
installed("host-b", "settings"),
|
|
]);
|
|
|
|
expect(groups.map((group) => group.key)).toEqual([
|
|
"example/sidebar/main",
|
|
"example/sidebar/settings",
|
|
]);
|
|
});
|
|
});
|