chore: init monorepo snapshot
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildSearchRequest } from "./request";
|
||||
|
||||
describe("buildSearchRequest", () => {
|
||||
it("combines标题过滤与时间范围", () => {
|
||||
const payload = buildSearchRequest({
|
||||
workspaceId: "ws-1",
|
||||
activeDocumentId: "doc-1",
|
||||
query: "demo",
|
||||
filters: {
|
||||
titleOnly: true,
|
||||
exact: false,
|
||||
onlyCurrentPage: false,
|
||||
includeOcr: false,
|
||||
timeField: "updated",
|
||||
customRange: undefined,
|
||||
},
|
||||
timeRange: "7d",
|
||||
});
|
||||
|
||||
expect(payload).not.toBeNull();
|
||||
expect(payload?.filters.titleOnly).toBe(true);
|
||||
expect(payload?.filters.timeRange).toBe("7d");
|
||||
});
|
||||
|
||||
it("自动重置仅当前页面过滤条件", () => {
|
||||
const payload = buildSearchRequest({
|
||||
workspaceId: "ws-2",
|
||||
activeDocumentId: null,
|
||||
query: "",
|
||||
filters: {
|
||||
titleOnly: false,
|
||||
exact: false,
|
||||
onlyCurrentPage: true,
|
||||
includeOcr: false,
|
||||
timeField: "created",
|
||||
customRange: { from: "2025-02-01", to: "2025-02-07" },
|
||||
},
|
||||
timeRange: "any",
|
||||
});
|
||||
|
||||
expect(payload?.filters.onlyCurrentPage).toBe(false);
|
||||
expect(payload?.documentId).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user