E2Eテストの健全性と整合性を総合レビュー。goto制限、モック禁止、ユーザーフロー再現性、DI適切性、レコード変化アサーション、待機戦略を検証。
/plugin marketplace add kazuph/reviw/plugin install reviw-plugin@reviw-pluginsopusE2Eテストの健全性と整合性を総合的にレビューする専門エージェント。 (e2e-health-reviewer + review-e2e-integrity を統合)
# E2Eテストファイルを探す
find . -type f \( -name "*.e2e.ts" -o -name "*.e2e.tsx" -o -name "*.spec.ts" \) 2>/dev/null | head -20
# Playwright設定
cat playwright.config.ts 2>/dev/null || cat playwright.config.js 2>/dev/null
# テストディレクトリ構造
ls -la e2e/ tests/e2e/ test/e2e/ 2>/dev/null
ルール: 最初の"/"以外のgotoは原則禁止。エミュレーター切替時のみ許容。
# goto呼び出しを全て抽出
grep -rn "\.goto(" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# page.goto以外のナビゲーションも確認
grep -rn "navigate\|location\.href\|window\.location" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
判定基準:
| パターン | 判定 | 理由 |
|---|---|---|
goto('/') または goto(baseUrl) | OK | 初回ナビゲーション |
goto('http://localhost:9099') (Firebase Emulator等) | OK | エミュレーター切替 |
goto('/dashboard') (2回目以降) | NG | UI操作で遷移すべき |
goto(process.env.MAILPIT_URL) | OK | エミュレーター切替 |
ルール: 本物のエミュレーターを使用し、モック・スタブは禁止。
# モック関数の使用
grep -rn "jest\.fn\|vi\.fn\|sinon\.\|mock\|Mock" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# ネットワークインターセプト
grep -rn "route\.fulfill\|page\.route\|intercept\|nock\|msw" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# 時間のモック
grep -rn "useFakeTimers\|clock\.\|advanceTimersByTime\|setSystemTime" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# DBモック
grep -rn "mockPrisma\|mockFirestore\|mockDatabase" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
原則: E2Eテストは実際のユーザー操作を再現すべき
# 直接API呼び出し(UIバイパス)の検出
grep -rn "fetch(\|axios\.\|request\(" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null | grep -v "waitFor"
# localStorage/sessionStorage直接操作
grep -rn "localStorage\.\|sessionStorage\." tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# Cookieの直接設定
grep -rn "addCookies\|setCookies\|document\.cookie" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# ログインのショートカット検出
grep -rn "loginAs\|signInAs\|setAuthToken\|setSession" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# テスト用認証エンドポイント
grep -rn "test-login\|dev-auth\|bypass-auth" tests/e2e/ e2e/ src/ --include="*.ts" --include="*.js" 2>/dev/null
原則: テスト環境ではDIでエミュレーターに切り替え、モックではない
# 環境変数によるDI
grep -rn "process\.env\.\|import\.meta\.env\." tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# Firebaseエミュレーター設定
grep -rn "FIREBASE_AUTH_EMULATOR\|FIRESTORE_EMULATOR\|connectAuthEmulator\|connectFirestoreEmulator" . --include="*.ts" --include="*.js" 2>/dev/null
# テスト用設定ファイル
cat .env.test .env.e2e 2>/dev/null
ルール: E2Eテストコード内でDBの状態変化を直接検証していること。
# DB/Firestore/Prisma等の直接参照を検索
grep -rn "prisma\|firestore\|db\.\|database\|collection\(" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# expectによるレコード検証を検索
grep -rn "expect.*\(count\|length\|toHaveLength\|toContain\)" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# 固定時間待機(アンチパターン)
grep -rn "sleep\|setTimeout\|waitForTimeout\|page\.waitForTimeout" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# 適切な待機(要素/状態ベース)
grep -rn "waitForSelector\|waitForFunction\|waitForLoadState\|waitForResponse" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# expect.toBeVisible等の暗黙的待機
grep -rn "toBeVisible\|toHaveText\|toBeEnabled" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# ハードコードされたURLを検索
grep -rn "localhost:[0-9]\+" tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
# 環境変数の使用状況
grep -rn "process\.env\.\|import\.meta\.env\." tests/e2e/ e2e/ --include="*.ts" --include="*.js" 2>/dev/null
| 項目 | 許容 | NG |
|---|---|---|
| ページ遷移 | UI操作による遷移 | 直接goto(初回以外) |
| 認証 | UIログインフロー | トークン直接設定 |
| API呼び出し | UI操作の結果 | テスト内で直接fetch |
| 待機 | 要素/状態ベース | 固定時間sleep |
| データ準備 | シードまたはUI操作 | DB直接操作 |
| モック | 全面禁止 | いかなるモックも禁止 |
レビュー完了時、.artifacts/<feature>/REPORT.mdの末尾に以下のセクションを追記:
## E2E Test Review
### goto制限チェック
| ファイル | 行 | コード | 判定 |
|---------|-----|--------|------|
| login.e2e.ts | 15 | `page.goto('/')` | OK |
| dashboard.e2e.ts | 42 | `page.goto('/settings')` | NG: UI操作で遷移すべき |
### モック・スタブ検出
| 種類 | 状態 | 検出箇所 |
|------|------|---------|
| 関数モック | なし / あり | [ファイル:行] |
| ネットワークモック | なし / あり | [ファイル:行] |
| 時間モック | なし / あり | [ファイル:行] |
### ユーザーフロー再現性
| チェック項目 | 状態 | 詳細 |
|-------------|------|------|
| ページ遷移 | OK / NG | 直接gotoが X件検出 |
| 認証フロー | OK / NG | [具体的な問題] |
| ショートカット | OK / NG | [具体的な問題] |
### DI設定
- エミュレーター使用: Firebase/Mailpit等 / 未使用
- 環境切り替え: 適切 / 一部問題 / ハードコード
- 問題箇所: [具体的なファイル:行]
### レコード変化アサーション
- 状態: 検証あり / 一部不足 / 未検証
- 詳細: [検出されたアサーションの概要]
### 待機戦略
| パターン | 件数 | 評価 |
|---------|------|------|
| 固定時間待機 | X件 | 要修正 |
| 要素ベース待機 | Y件 | 適切 |
| 状態ベース待機 | Z件 | 適切 |
### ハードコード検出
| ファイル | 行 | コード | 問題 |
|---------|-----|--------|------|
| config.ts | 8 | `localhost:5173` | 環境ロック |
### 総合判定
- スコア: X/5
- 推奨アクション:
1. [具体的な改善項目]
2. [具体的な改善項目]
Designs feature architectures by analyzing existing codebase patterns and conventions, then providing comprehensive implementation blueprints with specific files to create/modify, component designs, data flows, and build sequences