























@@ -7,12 +7,23 @@ const cliMocks = vi.hoisted(() => ({
77registerMatrixCli: vi.fn(),
88}));
9910+const runtimeMocks = vi.hoisted(() => ({
11+ensureMatrixCryptoRuntime: vi.fn(async () => {}),
12+handleVerificationBootstrap: vi.fn(async () => {}),
13+handleVerificationStatus: vi.fn(async () => {}),
14+handleVerifyRecoveryKey: vi.fn(async () => {}),
15+setMatrixRuntime: vi.fn(),
16+}));
17+1018vi.mock("./src/cli.js", () => {
1119return {
1220registerMatrixCli: cliMocks.registerMatrixCli,
1321};
1422});
152324+vi.mock("./plugin-entry.handlers.runtime.js", () => runtimeMocks);
25+vi.mock("./runtime-api.js", () => ({ setMatrixRuntime: runtimeMocks.setMatrixRuntime }));
26+1627describe("matrix plugin", () => {
1728it("registers matrix CLI through a descriptor-backed lazy registrar", async () => {
1829const registerCli = vi.fn();
@@ -56,4 +67,35 @@ describe("matrix plugin", () => {
5667expect(entry.id).toBe("matrix");
5768expect(entry.name).toBe("Matrix");
5869});
70+71+it("registers subagent lifecycle hooks during full registration", () => {
72+const on = vi.fn();
73+const registerChannel = vi.fn();
74+const registerGatewayMethod = vi.fn();
75+const api = createTestPluginApi({
76+id: "matrix",
77+name: "Matrix",
78+source: "test",
79+config: {},
80+runtime: {} as never,
81+registrationMode: "full",
82+ on,
83+ registerChannel,
84+ registerGatewayMethod,
85+});
86+87+entry.register(api);
88+89+expect(registerChannel).toHaveBeenCalledWith({
90+plugin: expect.objectContaining({ id: "matrix" }),
91+});
92+expect(on.mock.calls.map(([hookName]) => hookName)).toEqual([
93+"subagent_spawning",
94+"subagent_ended",
95+"subagent_delivery_target",
96+]);
97+for (const [, handler] of on.mock.calls) {
98+expect(handler).toEqual(expect.any(Function));
99+}
100+});
59101});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。