mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-25 10:42:45 +00:00
* feat(plugins): add local plugin surfaces and RPCs Keep plugin execution scoped to its daemon while allowing one local TypeScript entry point to contribute validated RPCs and native client surfaces. Paseo owns host selection, navigation chrome, and per-installation query caches. * feat(plugins): add Linear attachment source * fix(nix): refresh npm dependency hash * test(server): exclude internal sessions from Hub counts * test(server): distinguish Hub execution sessions * feat(plugins): make local plugins explicitly opt-in Keep plugin loading dormant until configuration enables it, and collect unsupported examples under one directory. * refactor(plugins): establish host boundaries * fix(nix): refresh plugin dependency hash * fix(plugins): complete packaging and startup rollback * feat(plugins): add managed local lifecycle Make trusted local plugins recoverable and authorable through daemon-owned lifecycle operations, host settings, and a capability-gated CLI. Reloads fully stop the previous plugin before starting new code, while generated projects provide strict TSX checking without changing runtime dependency ownership. * fix(nix): refresh plugin dependency hash
80 lines
2.4 KiB
TypeScript
80 lines
2.4 KiB
TypeScript
/**
|
|
* @vitest-environment jsdom
|
|
*/
|
|
import React, { act, useEffect, useState } from "react";
|
|
import { createRoot } from "react-dom/client";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { Text } from "react-native";
|
|
import { SurfaceErrorBoundary } from "./surface-error-boundary";
|
|
|
|
let oldSurfaceCleanups = 0;
|
|
function FailingSurface() {
|
|
const [failed, setFailed] = useState(false);
|
|
useEffect(() => {
|
|
setFailed(true);
|
|
return () => {
|
|
oldSurfaceCleanups += 1;
|
|
};
|
|
}, []);
|
|
if (failed) throw new Error("old render exploded");
|
|
return <Text>Old surface mounted</Text>;
|
|
}
|
|
function CorrectedSurface() {
|
|
return <Text>Corrected surface</Text>;
|
|
}
|
|
const oldInstallation = {};
|
|
const correctedInstallation = {};
|
|
|
|
describe("SurfaceErrorBoundary", () => {
|
|
const roots: Array<ReturnType<typeof createRoot>> = [];
|
|
const containers: HTMLElement[] = [];
|
|
|
|
afterEach(() => {
|
|
for (const root of roots.splice(0)) act(() => root.unmount());
|
|
for (const container of containers.splice(0)) container.remove();
|
|
vi.restoreAllMocks();
|
|
vi.unstubAllGlobals();
|
|
oldSurfaceCleanups = 0;
|
|
});
|
|
|
|
it("recovers a mounted failed route when its installation and surface are replaced", async () => {
|
|
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
|
|
vi.spyOn(console, "warn").mockImplementation(() => undefined);
|
|
vi.spyOn(console, "error").mockImplementation(() => undefined);
|
|
const container = document.createElement("div");
|
|
containers.push(container);
|
|
document.body.appendChild(container);
|
|
const root = createRoot(container);
|
|
roots.push(root);
|
|
|
|
await act(async () => {
|
|
root.render(
|
|
<SurfaceErrorBoundary
|
|
key="host/plugin/surface"
|
|
installation={oldInstallation}
|
|
Surface={FailingSurface}
|
|
>
|
|
<FailingSurface />
|
|
</SurfaceErrorBoundary>,
|
|
);
|
|
});
|
|
expect(container.textContent).toBe("Plugin failed: old render exploded");
|
|
expect(oldSurfaceCleanups).toBe(1);
|
|
|
|
await act(async () => {
|
|
root.render(
|
|
<SurfaceErrorBoundary
|
|
key="host/plugin/surface"
|
|
installation={correctedInstallation}
|
|
Surface={CorrectedSurface}
|
|
>
|
|
<CorrectedSurface />
|
|
</SurfaceErrorBoundary>,
|
|
);
|
|
});
|
|
|
|
expect(container.textContent).toBe("Corrected surface");
|
|
expect(oldSurfaceCleanups).toBe(1);
|
|
});
|
|
});
|