Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

test(web): restore plugin host globals

tianma-if016058254d58
diff --git a/apps/web/src/lib/plugins/plugin-host.test.mjs b/apps/web/src/lib/plugins/plugin-host.test.mjs
index c901e042..11f8a6fe 100644
--- a/apps/web/src/lib/plugins/plugin-host.test.mjs
+++ b/apps/web/src/lib/plugins/plugin-host.test.mjs
@@ -1,4 +1,8 @@
-import { beforeEach, describe, expect, test } from "bun:test";
+import { afterAll, beforeEach, describe, expect, test } from "bun:test";
+
+const originalWindow = globalThis.window;
+const originalDocument = globalThis.document;
+const originalMutationObserver = globalThis.MutationObserver;
const values = new Map();
const styles = new Map();
@@ -41,6 +45,12 @@ const { sha256Hex } = await import("./github-plugin-distribution.ts");
const { withRepositoryMutationEvents } = await import("../repository-events.ts");
const { results: capabilityResults } = await import('./plugin-capabilities.fixture.mjs');
+afterAll(() => {
+ globalThis.window = originalWindow;
+ globalThis.document = originalDocument;
+ globalThis.MutationObserver = originalMutationObserver;
+});
+
const repository = {
listMemos: async () => ({ memos: [], totalCount: 0, nextCursor: null }),
};
diff --git a/apps/web/src/lib/plugins/plugin-lifecycle.test.mjs b/apps/web/src/lib/plugins/plugin-lifecycle.test.mjs
index a780f3c7..067bd8c3 100644
--- a/apps/web/src/lib/plugins/plugin-lifecycle.test.mjs
+++ b/apps/web/src/lib/plugins/plugin-lifecycle.test.mjs
@@ -1,9 +1,17 @@
-import { expect, test } from 'bun:test';
+import { afterAll, expect, test } from 'bun:test';
+const originalWindow = globalThis.window;
+const originalDocument = globalThis.document;
+const originalMutationObserver = globalThis.MutationObserver;
const values = new Map();
globalThis.window = { location: { href: 'https://example.test' }, localStorage: { getItem: key => values.get(key) ?? null, setItem: (key, value) => values.set(key, String(value)), removeItem: key => values.delete(key) }, addEventListener() {}, removeEventListener() {} };
globalThis.document = { documentElement: { classList: { contains: () => false }, dataset: {}, style: { setProperty() {}, removeProperty() {} }, removeAttribute() {} } };
globalThis.MutationObserver = class { observe() {} disconnect() {} };
const { EdgeEverPluginHost } = await import('./plugin-host');
+afterAll(() => {
+ globalThis.window = originalWindow;
+ globalThis.document = originalDocument;
+ globalThis.MutationObserver = originalMutationObserver;
+});
function setup() {
values.clear();
let release, entered, calls = 0;