fix(#105): corrige le contexte plugin pour hello-plugin

Ajoute logger, subscriptions et commandes scindées au contexte plugin
activé. Les plugins full-trust s'attendent à ce shape public.
This commit is contained in:
2026-07-29 17:59:14 +02:00
parent 3f27eb878b
commit 2c3a46e690
22 changed files with 1082 additions and 12 deletions

View File

@ -9,9 +9,19 @@ import { render, screen, waitFor, fireEvent, within } from "@testing-library/rea
import { MockPluginGateway, MockSystemGateway } from "@/adapters/mock";
import type { Gateways } from "@/ports";
import { DIProvider } from "@/app/di";
import { PluginRuntimeRegistry } from "@/plugins/runtime";
import { PluginsPanel } from "./PluginsPanel";
import { PluginRuntimeProvider, type PluginRuntimeContextValue } from "./PluginRuntimeProvider";
function renderPanel(plugin?: MockPluginGateway, system?: MockSystemGateway) {
function renderPanel(
plugin?: MockPluginGateway,
system?: MockSystemGateway,
runtimeValue: PluginRuntimeContextValue = {
registry: new PluginRuntimeRegistry(),
failures: [],
loading: false,
},
) {
const p = plugin ?? new MockPluginGateway();
const s = system ?? new MockSystemGateway();
const gateways = { plugin: p, system: s } as unknown as Gateways;
@ -20,7 +30,9 @@ function renderPanel(plugin?: MockPluginGateway, system?: MockSystemGateway) {
system: s,
...render(
<DIProvider gateways={gateways}>
<PluginsPanel />
<PluginRuntimeProvider value={runtimeValue}>
<PluginsPanel />
</PluginRuntimeProvider>
</DIProvider>,
),
};
@ -32,6 +44,19 @@ describe("PluginsPanel", () => {
expect(await screen.findByText("Aucun plugin installé.")).toBeTruthy();
});
it("keeps the Plugins panel rendered when a runtime bundle fails to load", async () => {
renderPanel(undefined, undefined, {
registry: new PluginRuntimeRegistry(),
failures: [{ pluginId: "com.example.hello-plugin", reason: "Cannot use import statement outside a module" }],
loading: false,
});
expect(await screen.findByText("Aucun plugin installé.")).toBeTruthy();
expect(screen.getByText("Certains plugins installés n'ont pas pu être chargés.")).toBeTruthy();
expect(screen.getByText("com.example.hello-plugin")).toBeTruthy();
expect(screen.getByText(/Cannot use import statement outside a module/)).toBeTruthy();
});
it("installs from an archive via the review dialog, mentioning full-trust", async () => {
renderPanel();
await screen.findByText("Aucun plugin installé.");