--- name: UI 测试方法 description: Desktop 界面 Playwright E2E 测试方法 type: reference originSessionId: 74c25b75-4539-4e2e-befc-145f81f71d59 --- # Desktop UI 测试方法 ## 测试位置 ``` apps/desktop/tests/ ├── e2e/ # Playwright 端到端测试 ├── unit/ # Python 后端单元测试 └── conftest.py ``` ## 关键命令 ```bash uv run playwright install chromium # 首次安装 uv run pytest tests/e2e/ -v # 运行 E2E 测试 uv run pytest tests/e2e/ --headed -v # 调试模式 ``` ## 技术要点 - 所有可交互元素使用 `data-testid` 标识 - 开发时 Vite dev server (`localhost:5173`),生产用 `dist/index.html` - 测试时可 mock `window.pywebview.api` - Playwright 自动等待元素,无需手动 sleep