fix: clarify browser application guidance

This commit is contained in:
vorotamoroz
2026-07-30 05:53:42 +00:00
parent d4994fdd05
commit b21c3114e5
5 changed files with 180 additions and 13 deletions
@@ -0,0 +1,34 @@
import { LOG_LEVEL_INFO } from "@vrtmrz/livesync-commonlib/compat/common/types";
import type { IStorageEventWatchHandlers } from "@vrtmrz/livesync-commonlib/compat/managers/adapters";
import { afterEach, describe, expect, it, vi } from "vitest";
import { FSAPIStorageEventManagerAdapter } from "@/apps/webapp/managers/FSAPIStorageEventManagerAdapter";
import type { FSAPIFile } from "@/apps/webapp/adapters/FSAPITypes";
afterEach(() => {
vi.unstubAllGlobals();
});
describe("WebApp file watching guidance", () => {
it("offers a capability-based manual fallback when FileSystemObserver is unavailable", async () => {
vi.stubGlobal("FileSystemObserver", undefined);
const addLog = vi.fn();
const adapter = new FSAPIStorageEventManagerAdapter({} as FileSystemDirectoryHandle, addLog);
const handlers = {
onCreate: vi.fn(),
onChange: vi.fn(),
onDelete: vi.fn(),
onRename: vi.fn(),
onRaw: vi.fn(),
} satisfies IStorageEventWatchHandlers<FSAPIFile>;
await adapter.watch.beginWatch(handlers);
expect(addLog).toHaveBeenCalledWith(
"Use 'Scan local files' after external changes",
LOG_LEVEL_INFO,
"fsapi-watch"
);
expect(addLog.mock.calls.map(([message]) => String(message)).join("\n")).not.toMatch(/Chrome \d+/);
});
});