1832640e8f
修复了 RippleButton 组件因 CVA 默认样式与自定义 className 冲突导致的文字不可见问题。 同时修复了项目中的 TypeScript 类型错误和 ESLint 规范问题。 主要修改: 1. 按钮显示修复:为使用红色文字的按钮添加 variant=outline, 为使用白色背景的按钮添加 variant=secondary 2. TypeScript 类型修复:修复 subtle-dots.tsx 中的类型定义错误, 删除不必要的 jest-dom.d.ts 文件 3. ESLint 规范修复:修复 React Hooks 使用规范问题, 将 useRef+forceUpdate 反模式改为 useState, 使用 eslint-disable 注释处理合理的 setState in effect 场景 4. 测试增强:添加按钮显示验证脚本和全面的页面按钮检查脚本
94 lines
4.2 KiB
Python
94 lines
4.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
验证按钮显示修复效果
|
|
检查软件开发服务页面的三个CTA按钮是否正常显示文字
|
|
"""
|
|
|
|
from playwright.sync_api import sync_playwright
|
|
import sys
|
|
|
|
def verify_buttons():
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True)
|
|
page = browser.new_page()
|
|
|
|
try:
|
|
# 访问软件开发服务页面
|
|
print("🔍 正在访问软件开发服务页面...")
|
|
page.goto('http://localhost:3000/services/software', timeout=30000)
|
|
page.wait_for_load_state('networkidle')
|
|
|
|
# 截图保存
|
|
screenshot_path = 'test-results/service-page-buttons.png'
|
|
page.screenshot(path=screenshot_path, full_page=True)
|
|
print(f"📸 页面截图已保存: {screenshot_path}")
|
|
|
|
# 查找所有 RippleButton(通过文本内容识别)
|
|
buttons_to_check = [
|
|
{"text": "预约演示", "expected": "outline variant with red text"},
|
|
{"text": "免费咨询", "expected": "solid red background with white text"},
|
|
{"text": "了解详情", "expected": "outline variant with red text"}
|
|
]
|
|
|
|
print("\n✅ 按钮验证结果:")
|
|
all_buttons_found = True
|
|
|
|
for button_info in buttons_to_check:
|
|
try:
|
|
# 查找包含指定文本的按钮
|
|
button = page.locator(f'a:has-text("{button_info["text"]}"), button:has-text("{button_info["text"]}")').first
|
|
|
|
if button.count() > 0:
|
|
# 获取按钮的样式信息
|
|
button_text = button.inner_text()
|
|
is_visible = button.is_visible()
|
|
|
|
# 检查按钮是否有可见的文本
|
|
text_color = button.evaluate('el => window.getComputedStyle(el).color')
|
|
bg_color = button.evaluate('el => window.getComputedStyle(el).backgroundColor')
|
|
|
|
print(f"\n ✓ 按钮 '{button_text}':")
|
|
print(f" - 可见性: {'✅ 可见' if is_visible else '❌ 不可见'}")
|
|
print(f" - 文字颜色: {text_color}")
|
|
print(f" - 背景颜色: {bg_color}")
|
|
print(f" - 预期样式: {button_info['expected']}")
|
|
|
|
# 检查文字是否可见(文字颜色不应与背景色相同)
|
|
if is_visible and button_text:
|
|
print(f" - 状态: ✅ 正常显示")
|
|
else:
|
|
print(f" - 状态: ❌ 可能存在问题")
|
|
all_buttons_found = False
|
|
else:
|
|
print(f"\n ❌ 未找到按钮: '{button_info['text']}'")
|
|
all_buttons_found = False
|
|
|
|
except Exception as e:
|
|
print(f"\n ❌ 检查按钮 '{button_info['text']}' 时出错: {e}")
|
|
all_buttons_found = False
|
|
|
|
# 额外检查:确保按钮文字不是透明的
|
|
print("\n🔍 额外检查:按钮文字透明度...")
|
|
all_buttons = page.locator('a:has-text("预约演示"), a:has-text("免费咨询"), a:has-text("了解详情")').all()
|
|
|
|
for button in all_buttons:
|
|
text = button.inner_text()
|
|
opacity = button.evaluate('el => window.getComputedStyle(el).opacity')
|
|
print(f" - '{text}' 透明度: {opacity}")
|
|
|
|
if all_buttons_found:
|
|
print("\n🎉 验证成功!所有按钮都正常显示文字。")
|
|
return 0
|
|
else:
|
|
print("\n⚠️ 部分按钮可能存在问题,请检查截图。")
|
|
return 1
|
|
|
|
except Exception as e:
|
|
print(f"\n❌ 验证过程中出错: {e}")
|
|
return 1
|
|
finally:
|
|
browser.close()
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(verify_buttons())
|