@@ -286,6 +287,7 @@ export function ContactSection() {
id="name"
placeholder="请输入您的姓名"
required
+ data-testid="name-input"
value={formData.name}
onChange={(e) => handleChange('name', e.target.value)}
onBlur={(e) => handleBlur('name', e.target.value)}
@@ -297,6 +299,7 @@ export function ContactSection() {
type="tel"
placeholder="请输入您的电话"
required
+ data-testid="phone-input"
value={formData.phone}
onChange={(e) => handleChange('phone', e.target.value)}
onBlur={(e) => handleBlur('phone', e.target.value)}
@@ -309,6 +312,7 @@ export function ContactSection() {
type="email"
placeholder="请输入您的邮箱"
required
+ data-testid="email-input"
value={formData.email}
onChange={(e) => handleChange('email', e.target.value)}
onBlur={(e) => handleBlur('email', e.target.value)}
@@ -320,6 +324,7 @@ export function ContactSection() {
placeholder="请输入您想咨询的内容"
rows={5}
required
+ data-testid="message-input"
value={formData.message}
onChange={(e) => handleChange('message', e.target.value)}
onBlur={(e) => handleBlur('message', e.target.value)}
@@ -330,6 +335,7 @@ export function ContactSection() {
size="lg"
className="w-full group mt-auto min-h-[52px] md:min-h-0"
disabled={isSubmitting}
+ data-testid="submit-button"
>
{isSubmitting ? (
<>
diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx
index 29e6ac0..03da059 100644
--- a/src/components/ui/input.tsx
+++ b/src/components/ui/input.tsx
@@ -4,6 +4,7 @@ import { cn } from "@/lib/utils"
export interface InputProps extends React.InputHTMLAttributes
{
label?: string
error?: string
+ 'data-testid'?: string
}
const Input = React.forwardRef(
@@ -27,6 +28,7 @@ const Input = React.forwardRef(
type={type}
id={inputId}
data-slot="input"
+ data-testid={props['data-testid']}
className={cn(
"file:text-foreground placeholder:text-[#8C8C8C] selection:bg-[#1C1C1C] selection:text-white h-14 min-h-[56px] w-full min-w-0 rounded-lg border border-[#E5E5E5] bg-[#FAFAFA] px-4 py-3 text-base text-[#1C1C1C] shadow-sm transition-all duration-300 outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 touch-manipulation md:h-12 md:min-h-[44px] md:py-2",
"focus-visible:border-[#1C1C1C] focus-visible:ring-2 focus-visible:ring-[#1C1C1C]/50 focus-visible:shadow-lg focus-visible:shadow-[#1C1C1C]/20",
@@ -41,7 +43,7 @@ const Input = React.forwardRef(
{...props}
/>
{error && (
-
+
{error}
)}
diff --git a/src/components/ui/textarea.tsx b/src/components/ui/textarea.tsx
index 3ae19c3..ac71607 100644
--- a/src/components/ui/textarea.tsx
+++ b/src/components/ui/textarea.tsx
@@ -4,6 +4,7 @@ import { cn } from "@/lib/utils"
export interface TextareaProps extends React.TextareaHTMLAttributes {
label?: string
error?: string
+ 'data-testid'?: string
}
const Textarea = React.forwardRef(
@@ -26,6 +27,7 @@ const Textarea = React.forwardRef(