Reprocess stored documents after reflection filters change

This commit is contained in:
vorotamoroz
2026-07-22 06:23:16 +00:00
parent aad0e56f09
commit 87152244d7
5 changed files with 159 additions and 7 deletions
@@ -0,0 +1,25 @@
import { describe, expect, it, vi } from "vitest";
import type { EntryDoc } from "@vrtmrz/livesync-commonlib/compat/common/types";
import { ReplicateResultProcessor } from "./ReplicateResultProcessor";
describe("ReplicateResultProcessor target-filter reprocessing", () => {
it("scans normal-file metadata without loading chunk documents and requeues it", async () => {
const documents = [
{ _id: "first", _rev: "1-a", type: "plain", path: "first.md" },
{ _id: "second", _rev: "1-b", type: "plain", path: "second.md" },
] as unknown as PouchDB.Core.ExistingDocument<EntryDoc>[];
const findAllNormalDocs = vi.fn(async function* () {
yield* documents;
});
const processor = new ReplicateResultProcessor({
core: { localDatabase: { findAllNormalDocs } },
} as never);
const enqueueAll = vi.spyOn(processor, "enqueueAll").mockImplementation(() => undefined);
await expect(processor.reprocessStoredDocuments()).resolves.toBe(2);
expect(findAllNormalDocs).toHaveBeenCalledOnce();
expect(enqueueAll).toHaveBeenCalledOnce();
expect(enqueueAll).toHaveBeenCalledWith(documents);
});
});