Browse Source

素材拖拽问题

feature/handle
TianYun 1 month ago
parent
commit
5f9a29a3e5
  1. 14
      src/components/__tests__/GenerationComposer.test.tsx
  2. 1
      src/store/utils/__tests__/connectedInputs.test.ts
  3. 10
      src/store/utils/connectedInputs.ts

14
src/components/__tests__/GenerationComposer.test.tsx

@ -1641,17 +1641,17 @@ describe("GenerationComposer", () => {
setData: (type: string, value: string) => dataTransferStore.set(type, value), setData: (type: string, value: string) => dataTransferStore.set(type, value),
getData: (type: string) => dataTransferStore.get(type) ?? "", getData: (type: string) => dataTransferStore.get(type) ?? "",
}; };
const videoMaterial = screen.getByTitle("@视频2"); const videoMaterial = screen.getByLabelText("@视频2");
const imageMaterial = screen.getByTitle("Reference image 1"); const imageMaterial = screen.getByLabelText("参考图片 1");
const prompt = screen.getByDisplayValue("use @图1 and @视频2") as HTMLTextAreaElement; const prompt = screen.getByDisplayValue("use @图1 and @视频2") as HTMLTextAreaElement;
fireEvent.dragStart(videoMaterial, { dataTransfer }); fireEvent.dragStart(videoMaterial, { dataTransfer });
fireEvent.drop(imageMaterial, { dataTransfer }); fireEvent.drop(imageMaterial, { dataTransfer });
expect(prompt).toHaveValue("use @图2 and @视频1"); expect(prompt).toHaveValue("use @图2 and @视频1");
expect(screen.getByTitle("@视频1")).toBeInTheDocument(); expect(screen.getByLabelText("@视频1")).toBeInTheDocument();
expect(screen.getByTitle("Reference image 2")).toBeInTheDocument(); expect(screen.getByLabelText("参考图片 2")).toBeInTheDocument();
fireEvent.click(screen.getByLabelText("Generate")); fireEvent.click(screen.getByLabelText(/Generate|生成/));
await waitFor(() => { await waitFor(() => {
expect(useWorkflowStore.getState().regenerateNode).toHaveBeenCalledWith("vid-1"); expect(useWorkflowStore.getState().regenerateNode).toHaveBeenCalledWith("vid-1");
@ -1662,14 +1662,14 @@ describe("GenerationComposer", () => {
id: 1, id: 1,
type: "video", type: "video",
url: "https://static.popi.art/ref.mp4", url: "https://static.popi.art/ref.mp4",
name: "@视频1", name: "视频1",
duration: 5.033, duration: 5.033,
}, },
{ {
id: 2, id: 2,
type: "image", type: "image",
url: "https://static.popi.art/ref.jpg", url: "https://static.popi.art/ref.jpg",
name: "@图2", name: "图2",
}, },
]); ]);
}); });

1
src/store/utils/__tests__/connectedInputs.test.ts

@ -305,6 +305,7 @@ describe("getConnectedInputsPure", () => {
}] as WorkflowEdge[]; }] as WorkflowEdge[];
const result = getConnectedInputsPure("gen", nodes, edges); const result = getConnectedInputsPure("gen", nodes, edges);
expect(result.videos).toEqual(["data:video/mp4;base64,v"]); expect(result.videos).toEqual(["data:video/mp4;base64,v"]);
expect(result.videoItems).toEqual([{ url: "data:video/mp4;base64,v" }]);
expect(result.dynamicInputs).toEqual({ video_urls: "data:video/mp4;base64,v" }); expect(result.dynamicInputs).toEqual({ video_urls: "data:video/mp4;base64,v" });
}); });

10
src/store/utils/connectedInputs.ts

@ -267,12 +267,10 @@ export function getConnectedInputsPure(
} else if (type === "video") { } else if (type === "video") {
videos.push(value); videos.push(value);
const duration = sourceNode ? getNodeVideoDurationSeconds(sourceNode) : null; const duration = sourceNode ? getNodeVideoDurationSeconds(sourceNode) : null;
if (targetHandle === SINGLE_INPUT_HANDLE_ID) { videoItems.push({
videoItems.push({ url: value,
url: value, ...(duration !== null && duration > 0 ? { duration } : {}),
...(duration !== null && duration > 0 ? { duration } : {}), });
});
}
} else if (type === "audio") { } else if (type === "audio") {
audio.push(value); audio.push(value);
} else if (type === "text") { } else if (type === "text") {

Loading…
Cancel
Save