test(matrix): isolate approval reaction runtime (#105251)

This commit is contained in:
Peter Steinberger
2026-07-12 10:43:00 +01:00
committed by GitHub
parent 1bea458124
commit 7a4cfa3764
2 changed files with 9 additions and 3 deletions
@@ -1,5 +1,5 @@
// Matrix tests cover approval reactions plugin behavior.
import { afterEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
buildMatrixApprovalReactionHint,
clearMatrixApprovalReactionTargetsForTest,
@@ -8,7 +8,7 @@ import {
resolveMatrixApprovalReactionTargetWithPersistence as resolveMatrixApprovalReactionTargetWithPersistenceRaw,
unregisterMatrixApprovalReactionTarget as unregisterMatrixApprovalReactionTargetRaw,
} from "./approval-reactions.js";
import { setMatrixRuntime } from "./runtime.js";
import { clearMatrixRuntime, setMatrixRuntime } from "./runtime.js";
type RegisterTargetParams = Parameters<typeof registerMatrixApprovalReactionTargetRaw>[0];
type ResolveTargetParams = Parameters<
@@ -53,8 +53,13 @@ function createRuntimeLogger(overrides: { warn?: ReturnType<typeof vi.fn> } = {}
};
}
beforeEach(() => {
clearMatrixRuntime();
});
afterEach(() => {
clearMatrixApprovalReactionTargetsForTest();
clearMatrixRuntime();
vi.restoreAllMocks();
});
+2 -1
View File
@@ -4,6 +4,7 @@ import type { PluginRuntime } from "./runtime-api.js";
const {
setRuntime: setMatrixRuntime,
clearRuntime: clearMatrixRuntime,
getRuntime: getMatrixRuntime,
tryGetRuntime: getOptionalMatrixRuntime,
} = createPluginRuntimeStore<PluginRuntime>({
@@ -11,4 +12,4 @@ const {
errorMessage: "Matrix runtime not initialized",
});
export { getMatrixRuntime, getOptionalMatrixRuntime, setMatrixRuntime };
export { clearMatrixRuntime, getMatrixRuntime, getOptionalMatrixRuntime, setMatrixRuntime };