0.3.1 UI修复
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
|
||||
describe("file-tree clipboard payload", () => {
|
||||
it("可编码/解码", () => {
|
||||
const payload = { type: "mnote-file-tree", version: 1 as const, action: "copy" as const, rowIds: ["doc:a", "asset:x"] };
|
||||
const payload = { type: "mnote-file-tree" as const, version: 1 as const, action: "copy" as const, rowIds: ["doc:a", "asset:x"] };
|
||||
const text = encodeFileTreeClipboardPayload(payload);
|
||||
expect(decodeFileTreeClipboardPayload(text)).toEqual(payload);
|
||||
expect(decodeFileTreeClipboardPayload("not-a-payload")).toBeNull();
|
||||
|
||||
@@ -25,10 +25,10 @@ describe("computeFileTreeDeleteTargets", () => {
|
||||
const docA = makeDoc("A", null);
|
||||
const docB = makeDoc("B", "A");
|
||||
const rows: FileTreeRow[] = [
|
||||
{ rowId: "doc:A", kind: "doc", docId: "A", node: docA, depth: 0, hasChildren: true, isExpanded: true },
|
||||
{ rowId: "index:A", kind: "index", docId: "A", node: docA, depth: 1 },
|
||||
{ rowId: "doc:B", kind: "doc", docId: "B", node: docB, depth: 1, hasChildren: false, isExpanded: false },
|
||||
{ rowId: "index:B", kind: "index", docId: "B", node: docB, depth: 2 },
|
||||
{ rowId: "doc:A", kind: "doc", docId: "A", parentDocId: null, node: docA, depth: 0, hasChildren: true, isExpanded: true },
|
||||
{ rowId: "index:A", kind: "index", docId: "A", parentDocId: "A", node: docA, depth: 1 },
|
||||
{ rowId: "doc:B", kind: "doc", docId: "B", parentDocId: "A", node: docB, depth: 1, hasChildren: false, isExpanded: false },
|
||||
{ rowId: "index:B", kind: "index", docId: "B", parentDocId: "B", node: docB, depth: 2 },
|
||||
];
|
||||
const parentById = buildParentById([
|
||||
{ id: "A", parentId: null },
|
||||
@@ -43,8 +43,8 @@ describe("computeFileTreeDeleteTargets", () => {
|
||||
it("选中 index 行等价于选中页面本身(去重)", () => {
|
||||
const docA = makeDoc("A", null);
|
||||
const rows: FileTreeRow[] = [
|
||||
{ rowId: "doc:A", kind: "doc", docId: "A", node: docA, depth: 0, hasChildren: false, isExpanded: false },
|
||||
{ rowId: "index:A", kind: "index", docId: "A", node: docA, depth: 1 },
|
||||
{ rowId: "doc:A", kind: "doc", docId: "A", parentDocId: null, node: docA, depth: 0, hasChildren: false, isExpanded: false },
|
||||
{ rowId: "index:A", kind: "index", docId: "A", parentDocId: "A", node: docA, depth: 1 },
|
||||
];
|
||||
const parentById = buildParentById([{ id: "A", parentId: null }]);
|
||||
const selectedRowIds = new Set(["doc:A", "index:A"]);
|
||||
@@ -55,15 +55,16 @@ describe("computeFileTreeDeleteTargets", () => {
|
||||
it("如果页面被删除,则跳过同页面下的附件删除(避免重复/无效操作)", () => {
|
||||
const docA = makeDoc("A", null);
|
||||
const rows: FileTreeRow[] = [
|
||||
{ rowId: "doc:A", kind: "doc", docId: "A", node: docA, depth: 0, hasChildren: true, isExpanded: true },
|
||||
{ rowId: "index:A", kind: "index", docId: "A", node: docA, depth: 1 },
|
||||
{ rowId: "doc:A", kind: "doc", docId: "A", parentDocId: null, node: docA, depth: 0, hasChildren: true, isExpanded: true },
|
||||
{ rowId: "index:A", kind: "index", docId: "A", parentDocId: "A", node: docA, depth: 1 },
|
||||
{
|
||||
rowId: "asset:1",
|
||||
kind: "asset",
|
||||
docId: "A",
|
||||
node: docA,
|
||||
parentDocId: "A",
|
||||
asset: {
|
||||
id: "1",
|
||||
workspace_id: "w1",
|
||||
document_id: "A",
|
||||
asset_type: "file",
|
||||
file_url: "https://example.com/1",
|
||||
|
||||
@@ -4,9 +4,18 @@ import { buildParentById, filterTopLevelDocIds, inferDropTargetDocId, isInvalidD
|
||||
|
||||
describe("file-tree/dnd", () => {
|
||||
test("inferDropTargetDocId", () => {
|
||||
const docRow = { kind: "doc", rowId: "doc:a", docId: "a", depth: 0, isExpanded: false, hasChildren: false, node: {} as any } as FileTreeRow;
|
||||
const indexRow = { kind: "index", rowId: "index:a", docId: "a", depth: 1, node: {} as any } as FileTreeRow;
|
||||
const assetRow = { kind: "asset", rowId: "asset:x", docId: "a", depth: 1, asset: {} as any } as FileTreeRow;
|
||||
const docRow: FileTreeRow = {
|
||||
kind: "doc",
|
||||
rowId: "doc:a",
|
||||
docId: "a",
|
||||
parentDocId: null,
|
||||
depth: 0,
|
||||
isExpanded: false,
|
||||
hasChildren: false,
|
||||
node: {} as any,
|
||||
};
|
||||
const indexRow: FileTreeRow = { kind: "index", rowId: "index:a", docId: "a", parentDocId: "a", depth: 1, node: {} as any };
|
||||
const assetRow: FileTreeRow = { kind: "asset", rowId: "asset:x", docId: "a", parentDocId: "a", depth: 1, asset: {} as any };
|
||||
expect(inferDropTargetDocId(docRow)).toBe("a");
|
||||
expect(inferDropTargetDocId(indexRow)).toBe("a");
|
||||
expect(inferDropTargetDocId(assetRow)).toBe("a");
|
||||
@@ -35,4 +44,3 @@ describe("file-tree/dnd", () => {
|
||||
expect(isInvalidDocDrop({ sourceDocIds: ["b"], targetParentId: "a", parentById })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user