feat(mappings): 完成 M05 字段映射与规则判断

映射和判断规则共用一个不可变版本,试算可以直接取已选查询的结果。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
unknownandCursor committed 2026-11-19 10:03:45 +08:00
1 parent be63e2fe5d
commit 252709709c
65 files changed
+5354 -22

No files matched your search

@@ -0,0 +1,19 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("@watchman/api", () => ({ requestJson: vi.fn() }));
import { requestJson } from "@watchman/api";
import { activateMappingVersion, saveMappingVersion } from "./client";
const mocked = vi.mocked(requestJson);
describe("mapping version client", () => {
beforeEach(() => { mocked.mockReset(); mocked.mockResolvedValue({}); });
it("saves columns and the shared condition tree together", async () => {
await saveMappingVersion("m1", { columns: [], condition_tree: { column: "n", operator: "eq", value: 1 } });
const [, init] = mocked.mock.calls[0];
expect(JSON.parse(String((init as RequestInit).body))).toEqual({ columns: [], condition_tree: { column: "n", operator: "eq", value: 1 } });
});
it("activates without sending a new tree", async () => {
await activateMappingVersion("m1", 2);
const [, init] = mocked.mock.calls[0];
expect((init as RequestInit).body).toBeUndefined();
});
});