From f7e83241e74cf2fe7fa74e869874e4a3aa53469c Mon Sep 17 00:00:00 2001 From: weige <772752726@qq.com> Date: Tue, 26 May 2026 17:31:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=9B=BE=E7=89=87=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E8=8A=82=E7=82=B9=E6=9C=AA=E5=AE=9E=E7=8E=B0=E7=9A=84?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/page.tsx | 2 +- .../__tests__/ImageInputNode.test.tsx | 23 +++++- src/components/nodes/ImageInputNode.tsx | 71 ++----------------- src/store/__tests__/userStore.test.ts | 39 ++++++++++ src/store/userStore.ts | 8 ++- src/types/user.ts | 5 +- 6 files changed, 77 insertions(+), 71 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 4b6725f0..d3e94c3d 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -34,7 +34,7 @@ function CanvasPageContent() { useEffect(() => { if (token || getStoredLoginToken()) { - void fetchUserInfo(token); + void fetchUserInfo(token, { forceRefresh: true }); } }, [fetchUserInfo, token]); diff --git a/src/components/__tests__/ImageInputNode.test.tsx b/src/components/__tests__/ImageInputNode.test.tsx index 1913f7a7..64f2f19e 100644 --- a/src/components/__tests__/ImageInputNode.test.tsx +++ b/src/components/__tests__/ImageInputNode.test.tsx @@ -400,6 +400,27 @@ describe("ImageInputNode", () => { expect(screen.getByLabelText("Remove image")).toBeInTheDocument(); }); + it("should hide unavailable image editing and asset actions", () => { + render( + + + + ); + + expect(screen.queryByLabelText("Choose from assets")).not.toBeInTheDocument(); + expect(screen.queryByLabelText("Crop")).not.toBeInTheDocument(); + expect(screen.queryByLabelText("Draw")).not.toBeInTheDocument(); + expect(screen.queryByLabelText("Multi-angle")).not.toBeInTheDocument(); + expect(screen.queryByLabelText("Enhance")).not.toBeInTheDocument(); + expect(screen.queryByLabelText("Lighting")).not.toBeInTheDocument(); + expect(screen.queryByLabelText("Repaint")).not.toBeInTheDocument(); + expect(screen.queryByLabelText("Grid")).not.toBeInTheDocument(); + expect(screen.getAllByLabelText("Replace")).toHaveLength(2); + expect(screen.getByLabelText("Download image")).toBeInTheDocument(); + expect(screen.getAllByLabelText("Open preview")).toHaveLength(2); + expect(screen.getByLabelText("Remove image")).toBeInTheDocument(); + }); + it("should call updateNodeData to clear image when remove button is clicked", () => { render( @@ -558,7 +579,7 @@ describe("ImageInputNode", () => { const fileInput = document.querySelector('input[type="file"]') as HTMLInputElement; const clickSpy = vi.spyOn(fileInput, "click"); - fireEvent.click(screen.getByLabelText("Replace")); + fireEvent.click(screen.getAllByLabelText("Replace")[0]); expect(clickSpy).toHaveBeenCalled(); }); diff --git a/src/components/nodes/ImageInputNode.tsx b/src/components/nodes/ImageInputNode.tsx index f89adadc..6ba094db 100644 --- a/src/components/nodes/ImageInputNode.tsx +++ b/src/components/nodes/ImageInputNode.tsx @@ -43,14 +43,6 @@ function EmptyImageIcon() { } type ImageToolbarIconKind = - | "crop" - | "draw" - | "multiAngle" - | "enhance" - | "lighting" - | "repaint" - | "grid" - | "folder" | "download" | "focus" | "delete" @@ -66,22 +58,6 @@ function ImageToolbarIcon({ kind }: { kind: ImageToolbarIconKind }) { }; switch (kind) { - case "crop": - return ; - case "draw": - return ; - case "multiAngle": - return ; - case "enhance": - return ; - case "lighting": - return ; - case "repaint": - return ; - case "grid": - return ; - case "folder": - return ; case "download": return ; case "focus": @@ -93,23 +69,6 @@ function ImageToolbarIcon({ kind }: { kind: ImageToolbarIconKind }) { } } -function ToolbarDivider() { - return