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

10
src/store/utils/connectedInputs.ts

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

Loading…
Cancel
Save