docs: add ai prereq handling

This commit is contained in:
2026-01-26 12:25:40 +08:00
parent 8b44767f11
commit 54f55a072e
2 changed files with 29 additions and 35 deletions

View File

@@ -1,25 +1,25 @@
# Implementation Plan: AI UI Test Readiness # Implementation Plan: AI Auto-Handling Prereqs
**Branch**: `main` | **Date**: 2026-01-26 | **Spec**: `docs/seed_verification.md` **Branch**: `main` | **Date**: 2026-01-26 | **Spec**: `docs/seed_verification.md`
**Input**: 验证 AI 浏览器自动化遗漏点并修复,更新 `AGENTS.md` 指引 **Input**: AI 自动处理 seed/tenantCode/localStorage 前置问题
**Note**: 本计划遵循 `docs/templates/plan-template.md` **Note**: 本计划遵循 `docs/templates/plan-template.md`
## Summary ## Summary
逐项验证 AI 浏览器自动化的遗漏点代理、登录、tenantCode、断言、错误检测补齐相关配置或文档并在 `AGENTS.md` 中列出 AI 测试应参考的关键文件 补充文档指导 AI 在开始页面测试前自动执行seed 检查/执行、DB 查询获取 tenantCode、清理浏览器存储
## Technical Context ## Technical Context
**Language/Version**: Go 1.22 + Vite + Chrome DevTools MCP **Language/Version**: Go 1.22 + Vite + Chrome DevTools MCP + PostgreSQL
**Primary Dependencies**: Vite proxy, seeded data **Primary Dependencies**: seed command, DB query, DevTools MCP
**Storage**: PostgreSQL **Storage**: PostgreSQL
**Testing**: 页面自动化 (MCP) **Testing**: 页面自动化 (MCP)
**Target Platform**: local/staging **Target Platform**: local/staging
**Project Type**: Web application **Project Type**: Web application
**Performance Goals**: N/A **Performance Goals**: N/A
**Constraints**: 不修改生成文件 **Constraints**: 不修改生成文件
**Scale/Scope**: 文档与种子数据/配置修复 **Scale/Scope**: 文档增强
## Constitution Check ## Constitution Check
@@ -33,57 +33,39 @@
```text ```text
docs/ docs/
├── plan.md ├── plan.md
── seed_verification.md ── seed_verification.md
└── plans/
```
### Source Code (repository root)
```text
backend/app/commands/seed/seed.go
AGENTS.md
``` ```
## Plan Phases ## Plan Phases
### Phase 1: 缺口验证 ### Phase 1: 自动化前置补充
- 逐项验证代理、登录、tenantCode、断言、错误检测 - 添加 seed 检查/执行、tenantCode 查询、存储清理说明
### Phase 2: 修复与补充 ### Phase 2: 复核
- 通过 seed/文档补齐缺口,更新 `AGENTS.md` - 确认文档覆盖自动化前置
### Phase 3: 复核与归档
- 复核覆盖面,完成 plan 归档。
## Tasks ## Tasks
**Format**: `[ID] [P?] [Story] Description` **Format**: `[ID] [P?] [Story] Description`
### Phase 1 ### Phase 1
- [ ] T001 [US0] 校验代理/端口与登录细节 - [x] T001 [US0] 增加 seed/tenantCode 自动处理说明
- [ ] T002 [US0] 校验 tenantCode 获取方式与断言点 - [x] T002 [US0] 增加 storage 清理说明
- [ ] T003 [US0] 校验错误检测与 console 监控指引
### Phase 2 ### Phase 2
- [ ] T010 [US1] 修复 seed/配置/文档缺口 - [x] T010 [US1] 复核文档与示例
- [ ] T011 [US1] 更新 `AGENTS.md` AI 测试参考文件
### Phase 3
- [ ] T020 [US2] 复核并归档计划
## Dependencies ## Dependencies
- Phase 1 → Phase 2 → Phase 3 - Phase 1 → Phase 2。
## Acceptance Criteria ## Acceptance Criteria
- 文档包含完整 AI 自动化前置与断言说明 - 文档明确 AI 自动化处理三个前置问题
- `AGENTS.md` 指明 AI 测试参考文件。
- 计划已归档并清空 `docs/plan.md`
## Risks ## Risks
- Staging 环境不可访问导致验证不足 - DB 连接无法访问
## Complexity Tracking ## Complexity Tracking

View File

@@ -14,6 +14,18 @@
- Use MCP to connect at `http://10.1.1.104:9222` (SSH forwarded DevTools port). - Use MCP to connect at `http://10.1.1.104:9222` (SSH forwarded DevTools port).
- Open target URLs via MCP and run page-level assertions (no API-level calls required). - Open target URLs via MCP and run page-level assertions (no API-level calls required).
## AI Auto-Handling Prereqs
- **Seed 检查/执行**
- DB 查询(示例):`SELECT COUNT(*) FROM tenants;`
- 若结果为 0执行 `go run ./backend/main.go seed` 后再继续。
- **tenantCode 获取**
- DB 查询:`SELECT code FROM tenants ORDER BY id DESC LIMIT 1;`
- 将结果注入到 Portal URL `/t/:tenantCode`
- **清理浏览器存储**
- 在 MCP 中执行脚本:清理 `localStorage` / `sessionStorage`,并清除 cookies。
- 示例:`chrome-devtools_evaluate_script``() => { localStorage.clear(); sessionStorage.clear(); document.cookie.split(';').forEach(c => document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/')); }`
### MCP Example Flow (AI Guidance) ### MCP Example Flow (AI Guidance)
1. **Open Portal Home** 1. **Open Portal Home**