# Playwright CDP E2E Create-User Closure

- Date: 2026-03-26
- Scope: PRD `5.2 用户信息管理 -> 创建用户`
- Environment: Windows PowerShell, external Chromium CDP, isolated backend/frontend ports, isolated SQLite runtime database

## Commands Executed

```powershell
$env:GOCACHE=Join-Path $env:TEMP 'ums-verify-go-build'
$env:GOMODCACHE=Join-Path $env:TEMP 'ums-verify-go-mod'
$env:GOPATH=Join-Path $env:TEMP 'ums-verify-go-path'
New-Item -ItemType Directory -Force $env:GOCACHE,$env:GOMODCACHE,$env:GOPATH | Out-Null

go test ./... -count=1
go build ./cmd/server

cd D:\project\frontend\admin
npm.cmd run lint
npm.cmd run test:run -- src/services/users.test.ts src/pages/admin/UsersPage/CreateUserModal.test.tsx
npm.cmd run build
powershell -ExecutionPolicy Bypass -File .\scripts\run-playwright-auth-e2e.ps1
```

## Validated Results

- `go test ./... -count=1`: passed under temporary writable Go caches
- `go build ./cmd/server`: passed
- `npm.cmd run lint`: passed
- `npm.cmd run test:run -- src/services/users.test.ts src/pages/admin/UsersPage/CreateUserModal.test.tsx`: passed
- `npm.cmd run build`: passed after fixing the Windows/Vite native-loader root path issue by using `vite build . --configLoader native`
- `run-playwright-auth-e2e.ps1`: passed

## Browser Scenarios Verified

- `login-surface`
- `auth-workflow`
  - admin login
  - user detail drawer
  - assign roles modal
  - create user modal
  - created user search and list verification
  - role permissions modal
  - logout
- `responsive-login`
- `desktop-mobile-navigation`

## Isolation Hardening Added

- `frontend/admin/scripts/run-playwright-auth-e2e.ps1` now starts its own backend and frontend on isolated ports
- the script now uses an isolated SQLite database under `%TEMP%` instead of reusing ambient `./data/user_management.db`
- `frontend/admin/vite.config.js` now reads `VITE_API_PROXY_TARGET`
- `frontend/admin/.env.development` now defaults to `/api/v1`, so the dev proxy is not bypassed by a hardcoded backend URL
- `tools/init_admin.go` and `tools/verify_admin.go` now honor runtime SQLite path overrides instead of assuming `./data/user_management.db`

## Real Boundary Notes

- The create-user API returned success and the created user was verified again from the real list page.
- In the supported CDP + `chrome-headless-shell` path, the Ant Design modal entered the `leave` transition state but the node was not a reliable DOM-removal signal; the E2E harness now validates transition initiation plus post-create data verification instead of treating hidden-node retention as a product failure.
- This remains browser-level validation, not OS-level desktop automation.

## Conclusion

PRD `5.2 用户信息管理 -> 创建用户` is now closed at backend, frontend, and supported real-browser E2E levels in the current environment.
