From b57e58ff87d6f28fb3b7b5fde8bb6ee7c1749ecf Mon Sep 17 00:00:00 2001 From: Huarch Date: Thu, 30 Jul 2026 19:07:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=E8=B0=83=E6=95=B4=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E5=8C=BA=E6=93=8D=E4=BD=9C=E6=8C=89=E9=92=AE=E5=B8=83?= =?UTF-8?q?=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chat/AgentComposer.test.tsx | 61 ++++++++++++++++ src/components/chat/AgentComposer.tsx | 83 ++++++++++------------ 2 files changed, 98 insertions(+), 46 deletions(-) create mode 100644 src/components/chat/AgentComposer.test.tsx diff --git a/src/components/chat/AgentComposer.test.tsx b/src/components/chat/AgentComposer.test.tsx new file mode 100644 index 0000000..32c0004 --- /dev/null +++ b/src/components/chat/AgentComposer.test.tsx @@ -0,0 +1,61 @@ +/* eslint-disable @next/next/no-img-element */ +import React from "react"; +import { render, screen } from "@testing-library/react"; +import { ThemeProvider, createTheme } from "@mui/material/styles"; + +import { AgentComposer } from "./AgentComposer"; + +jest.mock("next/image", () => ({ + __esModule: true, + default: (props: React.ImgHTMLAttributes) => ( + {props.alt + ), +})); + +jest.mock("framer-motion", () => ({ + AnimatePresence: ({ children }: { children: React.ReactNode }) => <>{children}, + motion: { + div: ({ + children, + animate: _animate, + exit: _exit, + initial: _initial, + transition: _transition, + ...props + }: React.HTMLAttributes & Record) => ( +
{children}
+ ), + }, +})); + +describe("AgentComposer", () => { + it("places voice input immediately before send without an attachment action", () => { + render( + + + , + ); + + const voiceButton = screen.getByRole("button", { name: "语音输入" }); + const sendButton = screen.getByRole("button", { name: "发送" }); + + expect(screen.queryByRole("button", { name: "上传附件" })).not.toBeInTheDocument(); + expect(screen.getByTitle("快捷指令图标")).toBeInTheDocument(); + expect(screen.queryByAltText("TJWater Agent")).not.toBeInTheDocument(); + expect(voiceButton.nextElementSibling?.contains(sendButton)).toBe(true); + }); +}); diff --git a/src/components/chat/AgentComposer.tsx b/src/components/chat/AgentComposer.tsx index d40a5c1..a6e0b16 100644 --- a/src/components/chat/AgentComposer.tsx +++ b/src/components/chat/AgentComposer.tsx @@ -23,7 +23,6 @@ import StopRounded from "@mui/icons-material/StopRounded"; import MicRounded from "@mui/icons-material/MicRounded"; import KeyboardArrowDownRounded from "@mui/icons-material/KeyboardArrowDownRounded"; import KeyboardArrowUpRounded from "@mui/icons-material/KeyboardArrowUpRounded"; -import AttachFileRounded from "@mui/icons-material/AttachFileRounded"; import BoltRounded from "@mui/icons-material/BoltRounded"; import AutoAwesomeRounded from "@mui/icons-material/AutoAwesomeRounded"; import VerifiedUserRounded from "@mui/icons-material/VerifiedUserRounded"; @@ -125,16 +124,10 @@ export const AgentComposer = React.forwardRef - TJWater Agent + 管网分析快捷指令 @@ -230,41 +223,6 @@ export const AgentComposer = React.forwardRef - - - - {isSttSupported ? ( - isListening ? ( - - - - - - ) : ( - - - - ) - ) : null}