diff --git a/docs/superpowers/plans/2026-05-25-playwright-skill-restructure.md b/docs/superpowers/plans/2026-05-25-playwright-skill-restructure.md new file mode 100644 index 00000000..e45db06c --- /dev/null +++ b/docs/superpowers/plans/2026-05-25-playwright-skill-restructure.md @@ -0,0 +1,825 @@ +# Playwright スキル再構成 実装計画 + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** PR #18 の 6 スキル分割を、大原則 (再現可能テストスクリプト先行 / plugin 非依存 / エビデンス動画デフォルト ON) に基づいて 5 スキル + orchestrator に再構成する。 + +**Architecture:** 旧 evidence/overlay/quality の 3 スキルを `playwright-execution` に統合し、新規 `playwright-script-creation` を追加。`pytest_plugin.py` に `--pwk-no-video` オプションを追加し動画デフォルト ON を実現。`run.sh` にも `--video=on` フォールバックを追加。 + +**Tech Stack:** Python (pytest / pytest-playwright), Bash, YAML, Markdown (SKILL.md) + +**Spec:** `docs/superpowers/specs/2026-05-25-playwright-skill-restructure-design.md` + +--- + +## ファイル構成 + +### 新規作成 + +| ファイル | 責務 | +|---|---| +| `plugins/ndf/skills/playwright-script-creation/SKILL.md` | Phase 2 スキル: テストスクリプト作成ガイド | +| `plugins/ndf/skills/playwright-execution/SKILL.md` | Phase 3 スキル: テスト実行+エビデンス収集 (3 スキル統合) | +| `plugins/ndf/skills/playwright-kit-ops/tests/test_video_default.py` | `--pwk-no-video` オプションと動画デフォルト ON のテスト | + +### 変更 + +| ファイル | 変更内容 | +|---|---| +| `plugins/ndf/skills/playwright-kit-ops/playwright_kit/pytest_plugin.py` | `--pwk-no-video` CLI オプション追加 + `pytest_configure` で動画デフォルト ON | +| `plugins/ndf/skills/playwright-kit-ops/templates/run.sh` | `--video=on` フォールバック追加 | +| `plugins/ndf/skills/playwright-kit-ops/templates/conftest.py.template` | テストスクリプト存在チェック追加 | +| `plugins/ndf/skills/playwright-test-planning/SKILL.md` | 次フェーズ導線追加 | +| `plugins/ndf/skills/playwright-report/SKILL.md` | Drive 共有セクション削除 | +| `plugins/ndf/skills/playwright-scenario-test/SKILL.md` | 5 スキル案内テーブル更新 + 大原則記載 | +| `plugins/ndf/.claude-plugin/plugin.json` | skills 配列更新 (3 削除 + 2 追加) | + +### 削除 + +| ディレクトリ | 理由 | +|---|---| +| `plugins/ndf/skills/playwright-evidence/` | `playwright-execution` に統合 | +| `plugins/ndf/skills/playwright-overlay/` | `playwright-execution` に統合 | +| `plugins/ndf/skills/playwright-quality/` | `playwright-execution` に統合 | + +--- + +## Task 1: `--pwk-no-video` CLI オプション追加 + 動画デフォルト ON のテスト + +**Files:** +- Create: `plugins/ndf/skills/playwright-kit-ops/tests/test_video_default.py` + +- [ ] **Step 1: テストファイルを作成** + +`plugins/ndf/skills/playwright-kit-ops/tests/test_video_default.py` に以下を書く: + +```python +"""--pwk-no-video オプションと動画デフォルト ON の検証。 + +pytest-playwright の --video オプションが playwright_kit plugin 経由で +デフォルト 'on' に設定されること、および --pwk-no-video で 'off' に +切り替わることを pytester 経由で検証する。 +""" + +from __future__ import annotations + +import textwrap + + +def test_pwk_no_video_option_registered(pytester): + """--pwk-no-video が pytest -h に出ること。""" + pytester.makepyfile("def test_dummy(): pass\n") + res = pytester.runpytest("--help") + out = res.stdout.str() + assert "--pwk-no-video" in out + + +def test_video_default_on(pytester): + """--video 未指定時、playwright_kit が video='on' をデフォルト設定すること。""" + pytester.makepyfile( + textwrap.dedent( + """ + def test_video_config(pytestconfig): + video = pytestconfig.getoption("video", default=None) + assert video == "on", f"expected 'on', got {video!r}" + """ + ) + ) + res = pytester.runpytest("-q") + res.assert_outcomes(passed=1) + + +def test_pwk_no_video_sets_off(pytester): + """--pwk-no-video 指定時、video='off' になること。""" + pytester.makepyfile( + textwrap.dedent( + """ + def test_video_config(pytestconfig): + video = pytestconfig.getoption("video", default=None) + assert video == "off", f"expected 'off', got {video!r}" + """ + ) + ) + res = pytester.runpytest("-q", "--pwk-no-video") + res.assert_outcomes(passed=1) + + +def test_explicit_video_flag_takes_precedence(pytester): + """--video=retain-on-failure を明示指定した場合、pwk が上書きしないこと。""" + pytester.makepyfile( + textwrap.dedent( + """ + def test_video_config(pytestconfig): + video = pytestconfig.getoption("video", default=None) + assert video == "retain-on-failure", f"expected 'retain-on-failure', got {video!r}" + """ + ) + ) + res = pytester.runpytest("-q", "--video=retain-on-failure") + res.assert_outcomes(passed=1) +``` + +- [ ] **Step 2: テストを実行して FAIL を確認** + +Run: `cd /work/ai-plugins/plugins/ndf/skills/playwright-kit-ops && uv run pytest tests/test_video_default.py -v` + +Expected: `test_pwk_no_video_option_registered` → FAIL (`--pwk-no-video` がまだ登録されていない)。`test_video_default_on` → FAIL (デフォルトが `on` ではない)。`test_pwk_no_video_sets_off` → FAIL。`test_explicit_video_flag_takes_precedence` → 結果は pytest-playwright の状態に依存。 + +- [ ] **Step 3: コミット** + +```bash +git add plugins/ndf/skills/playwright-kit-ops/tests/test_video_default.py +git commit -m "test: --pwk-no-video オプションと動画デフォルト ON の failing tests 追加" +``` + +--- + +## Task 2: `pytest_plugin.py` に `--pwk-no-video` を実装して動画デフォルト ON にする + +**Files:** +- Modify: `plugins/ndf/skills/playwright-kit-ops/playwright_kit/pytest_plugin.py:44-93` (pytest_addoption) +- Modify: `plugins/ndf/skills/playwright-kit-ops/playwright_kit/pytest_plugin.py:110-137` (pytest_configure) + +- [ ] **Step 1: `pytest_addoption` に `--pwk-no-video` を追加** + +`plugins/ndf/skills/playwright-kit-ops/playwright_kit/pytest_plugin.py` の `pytest_addoption` 関数内、`--pwk-overlay` の直前に追加する: + +```python + group.addoption( + "--pwk-no-video", + action="store_true", + default=False, + help="動画収集を明示的に OFF にする (デフォルトは全テストで動画 ON)", + ) +``` + +- [ ] **Step 2: `pytest_configure` に動画デフォルト ON ロジックを追加** + +`pytest_configure` 関数内の既存コードの末尾(`config._pwk_config = cfg` 行の後、関数末尾)に以下を追加する: + +```python + # 動画デフォルト ON (大原則: エビデンス動画を常に取得) + # ユーザーが --video を CLI で明示指定した場合はそちらを優先する。 + # --pwk-no-video 指定時は video='off' に設定する。 + # --pwk-no-evidence 指定時も video='off' に設定する (全エビデンス OFF)。 + try: + video_opt = config.getoption("video", default=None) + no_video = config.getoption("pwk_no_video", default=False) + no_evidence = config.getoption("pwk_no_evidence", default=False) + if video_opt is None: + if no_video or no_evidence: + config.option.video = "off" + else: + config.option.video = "on" + except (ValueError, AttributeError): + pass +``` + +- [ ] **Step 3: テストを実行して PASS を確認** + +Run: `cd /work/ai-plugins/plugins/ndf/skills/playwright-kit-ops && uv run pytest tests/test_video_default.py -v` + +Expected: 4 テスト全て PASS。 + +- [ ] **Step 4: 既存テストが壊れていないことを確認** + +Run: `cd /work/ai-plugins/plugins/ndf/skills/playwright-kit-ops && uv run pytest -q` + +Expected: 全テスト PASS (テスト数は変動する可能性あり)。 + +- [ ] **Step 5: コミット** + +```bash +git add plugins/ndf/skills/playwright-kit-ops/playwright_kit/pytest_plugin.py +git commit -m "feat: --pwk-no-video オプション追加 + 動画デフォルト ON" +``` + +--- + +## Task 3: `run.sh` テンプレートに `--video=on` フォールバックを追加 + +**Files:** +- Modify: `plugins/ndf/skills/playwright-kit-ops/templates/run.sh:80-89` (pytest 実行部分) + +- [ ] **Step 1: `run.sh` の pytest 実行部分を変更** + +`plugins/ndf/skills/playwright-kit-ops/templates/run.sh` の末尾 pytest 実行部分を以下に置換する: + +```bash +# --- 3) pytest 実行 ------------------------------------------------ +cd "$RUNTIME_DIR" + +# --pwk-no-video が引数に含まれていなければ --video=on をデフォルト追加。 +# pytest_plugin.py 側でもデフォルト注入するが、run.sh 経由の場合は +# 明示的に渡すことで --video の優先度を確保する。 +VIDEO_FLAG="--video=on" +for arg in "$@"; do + case "$arg" in + --pwk-no-video|--pwk-no-evidence) VIDEO_FLAG="" ;; + esac +done + +exec uv run pytest \ + --pwk-config="${PWK_CONFIG:-./scenario.config.yaml}" \ + $VIDEO_FLAG \ + "$@" +``` + +- [ ] **Step 2: help テキストに `--pwk-no-video` を追加** + +`run.sh` の `--help` セクション (`cat </ +├── report.md # テスト結果サマリ +├── / +│ ├── video.mp4 # テスト動画 (デフォルト ON) +│ ├── trace.zip # Playwright Trace +│ ├── request.har # ネットワーク通信ログ +│ ├── body_check.jsonl # body_check 違反詳細 +│ └── screenshot-*.png # スクリーンショット +``` + +## CLI options + +| option | 役割 | +|---|---| +| `--pwk-config ` | `scenario.config.yaml` のパス | +| `--pwk-out-dir ` | 成果物出力先 (default: `reports//`) | +| `--pwk-no-video` | 動画収集を OFF (デフォルトは ON) | +| `--pwk-no-evidence` | HAR / trace / video の収集を全て OFF | +| `--pwk-har-mode {minimal,full,none}` | HAR 録画モード (default: minimal) | +| `--pwk-overlay` | overlay (赤丸カーソル + 字幕) を ON | + +## 関連 Skill + +- `/ndf:playwright-script-creation` — テストスクリプト作成 (実行の前段) +- `/ndf:playwright-report` — Markdown レポート生成 +- `/ndf:playwright-kit-ops` — スクリプト実行 (init_project / スキャン) +- `/ndf:playwright-scenario-test` — 全機能統括 +``` + +- [ ] **Step 2: コミット** + +```bash +git add plugins/ndf/skills/playwright-execution/SKILL.md +git commit -m "feat: playwright-execution スキル追加 (evidence+overlay+quality 統合)" +``` + +--- + +## Task 7: `playwright-script-creation/SKILL.md` を新規作成 + +**Files:** +- Create: `plugins/ndf/skills/playwright-script-creation/SKILL.md` + +- [ ] **Step 1: SKILL.md を作成** + +`plugins/ndf/skills/playwright-script-creation/SKILL.md`: + +```markdown +--- +name: playwright-script-creation +description: "再現可能な E2E テストスクリプトを作成するガイド。テンプレートを起点にテストコードを実装し、再現可能性レビューを経てからテスト実行フェーズに進む。ndf plugin 非依存で動作する。" +when_to_use: "E2E テストスクリプトの作成 / テストコードの実装 / テストテンプレートからのスクリプト生成が必要なとき。Triggers: 'テストスクリプト作成', 'テストコード作成', 'テスト実装', 'テストを書く', 'シナリオ作成', 'codegen', 'テンプレートからテスト', 'playwright codegen'" +allowed-tools: + - Read + - Edit + - Write + - Bash(uv *) + - Bash(playwright *) + - Bash(python *) +--- + +# Playwright Script Creation (テストスクリプト作成) + +再現可能なテストスクリプトを作成し、レビューを経てからテスト実行に進む。 + +## 大原則 + +**テストスクリプトを実装してからテストを実施する。** +スクリプトが完成・レビューを経るまで `/ndf:playwright-execution` に進まない。 + +## 前提条件 + +- テスト計画が完了していること (`/ndf:playwright-test-planning` で計画済み) +- `init_project.sh` でプロジェクトが初期化済みであること (`/ndf:playwright-kit-ops`) + +## ワークフロー + +``` +[A] テスト計画の確認 (チェックリスト / page role / テスト技法) + │ +[B] テンプレート選択 + │ tests/ 配下の test_*.py.template を起点にする + ▼ +[C] テストコード実装 + │ playwright codegen で操作を記録 → テスト関数に組み込む + │ または手動で expect() ベースの assertion を書く + ▼ +[D] 再現可能性レビュー (下記チェックリスト) + │ +[E] テスト実行へ → /ndf:playwright-execution +``` + +## テンプレート一覧 + +`init_project.sh` で以下のテンプレートが `tests/` に配置済み: + +| テンプレート | page role | 内容 | +|---|---|---| +| `test_auth.py` | auth | ログイン / ログアウトフロー | +| `test_list.py` | list | 一覧ページネーション / ソート | +| `test_form.py` | form | 入力 → 送信 → 結果検証 | +| `test_dashboard.py` | dashboard | KPI / リンク遷移 | + +## テストコードの書き方 + +### テンプレートを起点にする + +各 page role のテンプレートが `templates/test_*.py.template` に用意されている。 +`init_project.sh` 実行時に `tests/` へコピーされるので、プロジェクト固有の URL やセレクタを書き換えて使う。 + +→ コード例: `templates/test_form.py.template`, `templates/test_auth.py.template` 等を参照 + +### playwright codegen での操作記録 + +`uv run playwright codegen ` で操作を記録し、生成コードをテスト関数にコピーする。 +コピー後に `@pytest.mark.page_role()`, `@pytest.mark.role()`, `expect()` assertion, `pwk_config.base_url` を追加する。 + +### overlay 付きテスト + +overlay API (`set_caption`, `flash_click`) の使用例は `playwright_kit/overlay.py` を参照。 + +## fixture / marker 一覧 + +fixture / marker の完全な一覧は `playwright_kit/pytest_plugin.py` の `_PWK_MARKERS` 定義と `playwright_kit/fixtures/` 配下の各モジュールを参照。 + +主な fixture: `pwk_config`, `pwk_role_`, `pwk_evidence`, `pwk_accessibility_scan()`, `pwk_web_vitals_measure()` +主な marker: `@pytest.mark.page_role()`, `@pytest.mark.role()`, `@pytest.mark.phase()`, `@pytest.mark.priority()`, `@pytest.mark.no_body_check` + +## 再現可能性レビューチェックリスト + +スクリプト完成後、以下を全項目確認してからテスト実行に進む: + +- [ ] **再現可能性**: 同じ環境で同じ結果が得られるか (ランダム値・タイムスタンプに依存していないか) +- [ ] **テストデータ独立性**: 外部の状態に依存せず、テスト単体で成立するか +- [ ] **marker 付与**: `@pytest.mark.page_role()` が全テスト関数に付与されているか +- [ ] **role marker**: 認証が必要なテストに `@pytest.mark.role()` + `pwk_role_` fixture があるか +- [ ] **assertion 網羅性**: 正常系 + 少なくとも 1 つの異常系 (バリデーション等) が含まれるか +- [ ] **URL 構築**: ハードコードされた URL ではなく `pwk_config.base_url` を使用しているか +- [ ] **wait 戦略**: `wait_until="domcontentloaded"` 等の明示的な待機指定があるか +- [ ] **ndf plugin 非依存**: `scenario-test/` ディレクトリ単体で実行可能か + +## ndf plugin 非依存 + +`init_project.sh` で埋め込まれた `scenario-test/` は: +- `playwright_kit/` パッケージ本体を含む +- `pyproject.toml` で pytest11 entry-point を定義 +- `run.sh` でワンコマンド実行可能 + +→ ndf plugin 未インストール環境でも `./scenario-test/run.sh` で動作する。 + +## 関連 Skill + +- `/ndf:playwright-test-planning` — テスト計画 (前段) +- `/ndf:playwright-execution` — テスト実行 + エビデンス収集 (後段) +- `/ndf:playwright-kit-ops` — init_project / codegen 等のツール群 +- `/ndf:playwright-scenario-test` — 全機能統括 +``` + +- [ ] **Step 2: コミット** + +```bash +git add plugins/ndf/skills/playwright-script-creation/SKILL.md +git commit -m "feat: playwright-script-creation スキル追加 (テストスクリプト作成ガイド)" +``` + +--- + +## Task 8: `playwright-test-planning/SKILL.md` を改修 + +**Files:** +- Modify: `plugins/ndf/skills/playwright-test-planning/SKILL.md` + +- [ ] **Step 1: ワークフロー末尾に次フェーズ導線を追加** + +`plugins/ndf/skills/playwright-test-planning/SKILL.md` のワークフロー `[E]` の後に以下を追加する: + +```markdown + ▼ +[F] スクリプト作成へ → /ndf:playwright-script-creation + テスト計画が確定したら、テストスクリプトの作成に進む。 + テスト計画が完了するまでスクリプト作成には進まない。 +``` + +- [ ] **Step 2: 関連 Skill セクションを更新** + +既存の関連 Skill セクションを以下に置換する: + +```markdown +## 関連 Skill + +- `/ndf:playwright-script-creation` — テストスクリプト作成 (次のフェーズ) +- `/ndf:playwright-execution` — テスト実行 + エビデンス収集 +- `/ndf:playwright-scenario-test` — 全機能を統括したフルワークフロー +``` + +- [ ] **Step 3: コミット** + +```bash +git add plugins/ndf/skills/playwright-test-planning/SKILL.md +git commit -m "Update: playwright-test-planning にスクリプト作成フェーズへの導線追加" +``` + +--- + +## Task 9: `playwright-report/SKILL.md` から Drive 共有を削除 + +**Files:** +- Modify: `plugins/ndf/skills/playwright-report/SKILL.md` + +- [ ] **Step 1: Drive 関連セクションを削除** + +`plugins/ndf/skills/playwright-report/SKILL.md` から以下のセクションを削除する: +- `## Google Drive アップロード` セクション全体 (「### テスト実行時に自動アップロード」と「### 手動アップロード」を含む) + +- [ ] **Step 2: 関連 Skill セクションを更新** + +既存の関連 Skill セクションを以下に置換する: + +```markdown +## 関連 Skill + +- `/ndf:playwright-execution` — テスト実行 + エビデンス収集 +- `/ndf:playwright-kit-ops` — エビデンスアップロードツール (Drive 連携が必要な場合) +- `/ndf:playwright-scenario-test` — 全機能を統括したフルワークフロー +``` + +- [ ] **Step 3: コミット** + +```bash +git add plugins/ndf/skills/playwright-report/SKILL.md +git commit -m "Update: playwright-report から Drive 共有セクションを削除" +``` + +--- + +## Task 10: `playwright-scenario-test/SKILL.md` (orchestrator) を改修 + +**Files:** +- Modify: `plugins/ndf/skills/playwright-scenario-test/SKILL.md` + +- [ ] **Step 1: SKILL.md を全面改修** + +`plugins/ndf/skills/playwright-scenario-test/SKILL.md` の内容を以下に置換する (frontmatter を含めて全体を差し替え): + +```markdown +--- +name: playwright-scenario-test +description: "pytest-playwright ベースのフル E2E テストフレームワーク統括。テスト計画・スクリプト作成・エビデンス付きテスト実行・レポート生成の 4 フェーズを組み合わせた包括的なテストワークフローを提供する。個別機能のみ必要な場合は各専門 skill を直接参照。" +when_to_use: "フル E2E テストワークフロー (計画→スクリプト→実行→レポート) を一貫して行うとき / pytest-playwright 拡張 fixture (pwk_*) の全体像を把握したいとき / init_project.sh でプロジェクトをセットアップするとき。Triggers: 'pytest-playwright', 'pwk_role', 'pwk_evidence', 'init_project', 'シナリオテスト一式', 'フル E2E'" +allowed-tools: + - Read + - Bash(uv *) + - Bash(pytest *) + - Bash(playwright *) + - Bash(python *) +--- + +# Playwright シナリオテスト Skill (v0.6.0) + +Web アプリの E2E シナリオを **理論ベース** で計画し、**再現可能なテストスクリプトを実装してから**、**pytest-playwright** 上でエビデンス動画付きで実行、Markdown レポートを自動生成する一式の Skill。 + +## 大原則 + +1. **再現可能なテストスクリプトを実装してからテストを実施する** +2. **テストスクリプトは ndf plugin 非依存でプロジェクトフォルダに設置する** +3. **テスト実行はエビデンス動画を常に取得する** (オプションで明示的にスキップ可能) + +## フェーズ別 Skill + +| Phase | Skill | 機能 | +|---|---|---| +| 1 | `/ndf:playwright-test-planning` | テスト計画 (HTSM / page role / チェックリスト) | +| 2 | `/ndf:playwright-script-creation` | テストスクリプト作成 (テンプレート→実装→レビュー) | +| 3 | `/ndf:playwright-execution` | テスト実行 + エビデンス収集 (video/trace/overlay/quality) | +| 4 | `/ndf:playwright-report` | レポート生成 (Markdown) | +| -- | `/ndf:playwright-kit-ops` | ツール群 (init_project / スキャン / アップロード) | + +## 標準ワークフロー + +``` +[Phase 1] テスト計画 (/ndf:playwright-test-planning) + │ 対象 URL → page role 判定 → チェックリスト → テスト技法確定 + ▼ +[Phase 2] スクリプト作成 (/ndf:playwright-script-creation) + │ テンプレート選択 → テストコード実装 → 再現可能性レビュー + │ ※ スクリプトが完成するまでテスト実行に進まない + ▼ +[Phase 3] テスト実行 + エビデンス収集 (/ndf:playwright-execution) + │ 動画デフォルト ON → trace/HAR/overlay/a11y/CWV/body_check + │ ※ --pwk-no-video で動画のみスキップ可 + ▼ +[Phase 4] レポート生成 (/ndf:playwright-report) + │ reports//report.md 自動生成 + ▼ +[任意] ツール群 (/ndf:playwright-kit-ops) + init_project / スキャン / アップロード (任意タイミング) +``` + +## クイックスタート + +1. プロジェクト初期化: `./scripts/init_project.sh /path/to/your-app` +2. 設定編集: `scenario-test/scenario.config.yaml` +3. テストスクリプト作成: `scenario-test/tests/test_*.py` (→ `/ndf:playwright-script-creation`) +4. テスト実行 (動画デフォルト ON): `./scenario-test/run.sh` +5. 動画スキップ: `./scenario-test/run.sh --pwk-no-video` + +→ `your-app/scenario-test/` は ndf plugin 非依存。単体で完結する。 + +## 用語集・制約 + +用語集 (accessibility, web vitals, LCP, CLS, TTFB, HAR, trace, overlay, body_check, page role, pwk) と制約/注意事項は `playwright_kit/` パッケージの README (`templates/runtime-README.md`) および `pyproject.toml` (`templates/pyproject.toml.runtime`) を参照。 +``` + +- [ ] **Step 2: コミット** + +```bash +git add plugins/ndf/skills/playwright-scenario-test/SKILL.md +git commit -m "Update: playwright-scenario-test orchestrator を 5 スキル構成に改修" +``` + +--- + +## Task 11: `plugin.json` を更新 + +**Files:** +- Modify: `plugins/ndf/.claude-plugin/plugin.json` + +- [ ] **Step 1: skills 配列を更新** + +`plugins/ndf/.claude-plugin/plugin.json` の `skills` 配列から以下を削除: +```json + "./skills/playwright-evidence", + "./skills/playwright-overlay", + "./skills/playwright-quality", +``` + +同じ配列の `"./skills/playwright-test-planning"` の後に以下を追加: +```json + "./skills/playwright-script-creation", + "./skills/playwright-execution", +``` + +- [ ] **Step 2: description を更新** + +`description` フィールドを以下に変更: + +``` +"Integrated plugin with 8 specialized agents (model-tiered: opus/sonnet/haiku), 44 skills including official mcp-builder, on-demand loader for Anthropic official skills, generic workflow/principle skills, skill usage statistics, pytest-playwright E2E testing split into 5 focused skills (test-planning, script-creation, execution, report, kit-ops) + orchestrator with video-by-default evidence, Google Drive/Chat integration, and Codex CLI integration via /ndf:codex skill. Transcript retention is automatically kept at >= 90 days. Serena MCP is a separate plugin (mcp-serena)." +``` + +- [ ] **Step 3: version を 4.9.0 に更新** + +```json +"version": "4.9.0", +``` + +- [ ] **Step 4: コミット** + +```bash +git add plugins/ndf/.claude-plugin/plugin.json +git commit -m "Update: plugin.json を 5 スキル構成に更新 (v4.9.0)" +``` + +--- + +## Task 12: `claude plugin validate` で検証 + +**Files:** (なし — 検証のみ) + +- [ ] **Step 1: プラグイン検証を実行** + +Run: `cd /work/ai-plugins && claude plugin validate` + +Expected: 検証が通ること。エラーがあればその場で修正する。 + +- [ ] **Step 2: 全テストを実行** + +Run: `cd /work/ai-plugins/plugins/ndf/skills/playwright-kit-ops && uv run pytest -q` + +Expected: 全テスト PASS。 + +--- + +## Task 13: 実装プラン `issues/PLAN23_playwright-skill-split.md` を更新 + +**Files:** +- Modify: `issues/PLAN23_playwright-skill-split.md` + +- [ ] **Step 1: ステータスと内容を更新** + +`issues/PLAN23_playwright-skill-split.md` のステータスを更新し、再構成の概要を追記する: + +```markdown +# PLAN23: playwright-scenario-test を 5 機能 skill + 統括 skill に再構成 + +**Issue**: https://github.com/devbasex/ai-plugins/issues/17 +**Status**: 実装済み + +## Context + +`playwright-scenario-test` は 73 ファイル / 760KB の大型 skill。初回は 6 skill + orchestrator に分割したが、以下の大原則に基づいて 5 skill + orchestrator に再構成した。 + +### 大原則 + +1. 再現可能なテストスクリプトを実装してからテストを実施する +2. テストスクリプトは ndf plugin 非依存でプロジェクトフォルダに設置する +3. テスト実行はエビデンス動画を常に取得する (オプションでスキップ可能) + +## 実施内容 + +### 5 skill + orchestrator 構成 + +| # | Skill 名 | 責務 | +|---|---|---| +| 1 | `playwright-test-planning` | テスト計画 (HTSM/ISTQB/FEW HICCUPPS) | +| 2 | `playwright-script-creation` | テストスクリプト作成 (テンプレート→実装→レビュー) | +| 3 | `playwright-execution` | テスト実行 + エビデンス収集 (video/trace/overlay/quality 統合) | +| 4 | `playwright-report` | レポート生成 | +| 5 | `playwright-kit-ops` | ツール群 (init_project/スキャン/アップロード) | + +### 廃止 skill + +- `playwright-evidence` → `playwright-execution` に統合 +- `playwright-overlay` → `playwright-execution` に統合 +- `playwright-quality` → `playwright-execution` に統合 + +### コード変更 + +- `pytest_plugin.py`: `--pwk-no-video` オプション追加、動画デフォルト ON +- `run.sh`: `--video=on` フォールバック追加 +- `conftest.py.template`: テストスクリプト存在チェック追加 +- `plugin.json`: v4.8.0 → v4.9.0 (45 → 44 skills) + +## 設計書 + +`docs/superpowers/specs/2026-05-25-playwright-skill-restructure-design.md` +``` + +- [ ] **Step 2: コミット** + +```bash +git add issues/PLAN23_playwright-skill-split.md +git commit -m "Docs: PLAN23 を 5 スキル再構成に更新" +``` diff --git a/docs/superpowers/specs/2026-05-25-playwright-skill-restructure-design.md b/docs/superpowers/specs/2026-05-25-playwright-skill-restructure-design.md new file mode 100644 index 00000000..982f962d --- /dev/null +++ b/docs/superpowers/specs/2026-05-25-playwright-skill-restructure-design.md @@ -0,0 +1,203 @@ +# Playwright スキル再構成設計書 + +## 背景 + +PR #18 で `playwright-scenario-test` を 6 スキルに分割したが、以下の大原則を満たすために再構成が必要: + +1. **再現可能なテストスクリプトを実装してからテストを実施する** +2. **テストスクリプトは ndf plugin がインストールされていなくても動作するようプロジェクトフォルダに設置する** +3. **テスト実行はエビデンス動画を常に取得できるようにしておく** (オプションで明示的にスキップ可能) + +## スキル構成 + +### 変更前 (6 スキル + orchestrator) + +| スキル | 責務 | +|---|---| +| playwright-test-planning | テスト計画 | +| playwright-evidence | エビデンス収集 | +| playwright-overlay | 動画装飾 | +| playwright-quality | 品質計測 | +| playwright-report | レポート + Drive 共有 | +| playwright-kit-ops | ツール群 | +| playwright-scenario-test | orchestrator | + +### 変更後 (5 スキル + orchestrator) + +| # | スキル | 責務 | 元スキル | +|---|---|---|---| +| 1 | `playwright-test-planning` | テスト計画 (HTSM/page role/チェックリスト) | 既存改修 | +| 2 | `playwright-script-creation` | テストスクリプト作成 (テンプレート→実装→レビュー) | **新規** | +| 3 | `playwright-execution` | テスト実行+エビデンス収集 (video/trace/overlay/quality) | evidence + overlay + quality 統合 | +| 4 | `playwright-report` | レポート生成 (Drive 共有削除) | 既存改修 | +| 5 | `playwright-kit-ops` | ツール群 (init_project/スキャン/アップロード) | 維持 | +| -- | `playwright-scenario-test` | orchestrator (5 スキルへの案内) | 既存改修 | + +### 廃止スキル + +- `playwright-evidence` → `playwright-execution` に統合 +- `playwright-overlay` → `playwright-execution` に統合 +- `playwright-quality` → `playwright-execution` に統合 + +## ワークフロー (大原則の反映) + +``` +[Phase 1] テスト計画 (/ndf:playwright-test-planning) + │ page role 判定 → チェックリスト → テスト技法確定 + ▼ +[Phase 2] スクリプト作成 (/ndf:playwright-script-creation) + │ テンプレート選択 → テストコード実装 → 再現可能性レビュー + │ ※ スクリプトが完成するまでテスト実行に進まない + ▼ +[Phase 3] テスト実行+エビデンス収集 (/ndf:playwright-execution) + │ 動画デフォルトON → trace/HAR/overlay/a11y/CWV/body_check + │ ※ --pwk-no-video で動画のみスキップ可 + ▼ +[Phase 4] レポート生成 (/ndf:playwright-report) + │ report.md 自動生成 + ▼ +[任意] ツール群 (/ndf:playwright-kit-ops) + init_project / スキャン / アップロード (任意タイミング) +``` + +## コード変更 + +### A. pytest_plugin.py: 動画デフォルト ON + +`--video=on` を pytest_configure でデフォルト注入する。ユーザーが `--video` を明示指定した場合はそちらを優先。 + +```python +# 新規 CLI オプション +group.addoption( + "--pwk-no-video", + action="store_true", + default=False, + help="動画収集を明示的に OFF にする", +) +``` + +```python +def pytest_configure(config): + # ... 既存の marker 登録 ... + + # 動画デフォルト ON: ユーザーが --video を明示指定していない場合のみ + video_opt = config.getoption("video", default=None) + no_video = config.getoption("pwk_no_video", default=False) + if video_opt is None and not no_video: + config.option.video = "on" + elif no_video: + config.option.video = "off" +``` + +### B. run.sh: --video=on のフォールバック追加 + +pytest_plugin 側で制御するため run.sh は補助的な変更のみ: + +```bash +# --pwk-no-video が引数に含まれていなければ --video=on を追加 +VIDEO_FLAG="--video=on" +for arg in "$@"; do + case "$arg" in + --pwk-no-video) VIDEO_FLAG="" ;; + esac +done + +exec uv run pytest \ + --pwk-config="${PWK_CONFIG:-./scenario.config.yaml}" \ + $VIDEO_FLAG \ + "$@" +``` + +### C. conftest.py テンプレート: テストスクリプト存在チェック + +`conftest.py.template` にテストスクリプトの存在チェックを追加: + +```python +def pytest_collection_modifyitems(session, config, items): + """テストスクリプトが存在しない場合に警告を出す。""" + if not items: + import warnings + warnings.warn( + "[pwk] tests/ ディレクトリにテストスクリプトが見つかりません。" + "playwright-script-creation スキルでテストスクリプトを作成してください。", + stacklevel=1, + ) +``` + +### D. plugin.json + +- 廃止: `playwright-evidence`, `playwright-overlay`, `playwright-quality` (3 スキル削除) +- 追加: `playwright-script-creation`, `playwright-execution` (2 スキル追加) +- skills 数: 45 → 44 + +### E. SKILL.md ファイル操作 + +| ファイル | 操作 | +|---|---| +| `playwright-script-creation/SKILL.md` | 新規作成 | +| `playwright-execution/SKILL.md` | 新規作成 | +| `playwright-test-planning/SKILL.md` | 改修 (次フェーズ導線追加) | +| `playwright-report/SKILL.md` | 改修 (Drive 共有削除) | +| `playwright-scenario-test/SKILL.md` | 改修 (5 スキル案内テーブル更新) | +| `playwright-evidence/SKILL.md` | 削除 (ディレクトリごと) | +| `playwright-overlay/SKILL.md` | 削除 (ディレクトリごと) | +| `playwright-quality/SKILL.md` | 削除 (ディレクトリごと) | + +## 各スキル SKILL.md の要件 + +### playwright-test-planning (改修) + +- 既存の内容を維持 +- ワークフロー末尾に「次は `/ndf:playwright-script-creation` でスクリプトを作成」を追加 +- 「テスト計画が完了するまでスクリプト作成に進まない」を明記 + +### playwright-script-creation (新規) + +- テンプレート(test_*.py.template)を起点にテストスクリプトを作成するガイド +- `playwright codegen` での操作記録 → テストコード化の手順 +- スクリプト完成後のレビューチェックリスト: + - 再現可能性の確認 (同じ環境で同じ結果が得られるか) + - テストデータの独立性 (外部依存の排除) + - page_role / role marker の付与確認 + - assert / expect の網羅性 +- 「スクリプトが完成・レビューを経てから `/ndf:playwright-execution` に進む」を明記 +- ndf plugin 非依存で動作することの説明 (init_project.sh で埋め込み済みの場合) + +### playwright-execution (新規: 3 スキル統合) + +- エビデンス収集設定 (video/trace/screenshot/HAR) — 旧 playwright-evidence +- overlay (赤丸カーソル + 字幕) — 旧 playwright-overlay +- 品質計測 (axe-core/Web Vitals/body_check) — 旧 playwright-quality +- **動画はデフォルト ON** であることを明記 +- `--pwk-no-video` で動画のみスキップ可能 +- `--pwk-no-evidence` で HAR/trace も含めて全エビデンス OFF +- 実行コマンド例、成果物ディレクトリ構造の説明 + +### playwright-report (改修) + +- 既存の Markdown レポート自動生成を維持 +- Drive 共有関連のセクション・コマンド例を削除 +- (Drive アップロードが必要な場合は kit-ops を案内) + +### playwright-scenario-test (orchestrator 改修) + +- 5 スキルへの案内テーブルを更新 +- フェーズ順序 (計画→スクリプト→実行→レポート) を明記 +- 大原則 3 つを冒頭に記載 + +## 実装上の注意点 + +- `pytest_configure` での `config.option.video` 直接設定は pytest-playwright の内部実装に依存する。実装時に pytest-playwright の `pytest_configure` フックとの実行順序を検証し、必要に応じて `tryfirst=True` や `browser_context_args` fixture 経由での制御に切り替える。 +- `--pwk-no-video` と `--pwk-no-evidence` の関係: `--pwk-no-evidence` は既存の HAR/trace OFF フラグ。`--pwk-no-video` は動画のみの独立制御。両方指定した場合は全エビデンス OFF。 +- 旧スキルディレクトリ (`playwright-evidence/`, `playwright-overlay/`, `playwright-quality/`) は SKILL.md のみ含むため、ディレクトリごと削除可能。 + +## ndf plugin 非依存の保証 + +`init_project.sh` で埋め込まれた `scenario-test/` ランタイムは: + +1. `playwright_kit/` パッケージ本体を含む +2. `pyproject.toml` で pytest11 entry-point を定義 +3. `run.sh` でワンコマンド実行可能 +4. テストスクリプト (`tests/test_*.py`) はプロジェクトフォルダに配置 + +→ ndf plugin がインストールされていない環境でも `./scenario-test/run.sh` で動作する。 diff --git a/issues/PLAN23_playwright-skill-split.md b/issues/PLAN23_playwright-skill-split.md new file mode 100644 index 00000000..8dfbfef3 --- /dev/null +++ b/issues/PLAN23_playwright-skill-split.md @@ -0,0 +1,43 @@ +# PLAN23: playwright-scenario-test を 5 機能 skill + 統括 skill に再構成 + +**Issue**: https://github.com/devbasex/ai-plugins/issues/17 +**Status**: 実装済み + +## Context + +`playwright-scenario-test` は 73 ファイル / 760KB の大型 skill。初回は 6 skill + orchestrator に分割したが、以下の大原則に基づいて 5 skill + orchestrator に再構成した。 + +### 大原則 + +1. 再現可能なテストスクリプトを実装してからテストを実施する +2. テストスクリプトは ndf plugin 非依存でプロジェクトフォルダに設置する +3. テスト実行はエビデンス動画を常に取得する (オプションでスキップ可能) + +## 実施内容 + +### 5 skill + orchestrator 構成 + +| # | Skill 名 | 責務 | +|---|---|---| +| 1 | `playwright-test-planning` | テスト計画 (HTSM/ISTQB/FEW HICCUPPS) | +| 2 | `playwright-script-creation` | テストスクリプト作成 (テンプレート→実装→レビュー) | +| 3 | `playwright-execution` | テスト実行 + エビデンス収集 (video/trace/overlay/quality 統合) | +| 4 | `playwright-report` | レポート生成 | +| 5 | `playwright-kit-ops` | ツール群 (init_project/スキャン/アップロード) | + +### 廃止 skill + +- `playwright-evidence` → `playwright-execution` に統合 +- `playwright-overlay` → `playwright-execution` に統合 +- `playwright-quality` → `playwright-execution` に統合 + +### コード変更 + +- `pytest_plugin.py`: `--pwk-no-video` オプション追加、動画デフォルト ON +- `run.sh`: `--video=on` フォールバック追加 +- `conftest.py.template`: テストスクリプト存在チェック追加 +- `plugin.json`: v4.8.0 → v4.9.0 (45 → 44 skills) + +## 設計書 + +`docs/superpowers/specs/2026-05-25-playwright-skill-restructure-design.md` diff --git a/plugins/ndf/.claude-plugin/plugin.json b/plugins/ndf/.claude-plugin/plugin.json index c5f51ed4..4a249f56 100644 --- a/plugins/ndf/.claude-plugin/plugin.json +++ b/plugins/ndf/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "ndf", - "version": "4.7.5", - "description": "Integrated plugin with 8 specialized agents (model-tiered: opus/sonnet/haiku), 39 skills including official mcp-builder, on-demand loader for Anthropic official skills, generic workflow/principle skills, skill usage statistics, pytest-playwright based scenario E2E testing (v0.5.0: BREAKING — package renamed scenario_test → playwright_kit, fixtures/CLI ndf_*/--ndf-* → pwk_*/--pwk-*, all-in-one runtime layout enabling Skill-independent operation via init_project.sh + run.sh, accessibility/web vitals autouse, overlay (formerly HUD), report.md, Drive integration, body_check autouse enabled by default to detect server-rendered PHP/SSR errors leaked into HTML), Google Drive/Chat integration, and Codex CLI integration via /ndf:codex skill. Transcript retention is automatically kept at >= 90 days. BREAKING (v4.0.0): Codex MCP server is removed (use /ndf:codex skill); legacy CLAUDE.ndf.md detection hook and /ndf:cleanup skill are removed (obsolete since v3.0.0). Serena MCP is a separate plugin (mcp-serena).", + "version": "4.9.0", + "description": "Integrated plugin with 8 specialized agents (model-tiered: opus/sonnet/haiku), 44 skills including official mcp-builder, on-demand loader for Anthropic official skills, generic workflow/principle skills, skill usage statistics, pytest-playwright E2E testing split into 5 focused skills (test-planning, script-creation, execution, report, kit-ops) + orchestrator with video-by-default evidence, Google Drive/Chat integration, and Codex CLI integration via /ndf:codex skill. Transcript retention is automatically kept at >= 90 days. Serena MCP is a separate plugin (mcp-serena).", "author": { "name": "takemi-ohama", "url": "https://github.com/takemi-ohama" @@ -61,6 +61,11 @@ "./skills/browser-test", "./skills/codex", "./skills/skill-stats", + "./skills/playwright-test-planning", + "./skills/playwright-script-creation", + "./skills/playwright-execution", + "./skills/playwright-report", + "./skills/playwright-kit-ops", "./skills/playwright-scenario-test", "./skills/google-drive", "./skills/google-chat", diff --git a/plugins/ndf/skills/playwright-execution/SKILL.md b/plugins/ndf/skills/playwright-execution/SKILL.md new file mode 100644 index 00000000..0247137f --- /dev/null +++ b/plugins/ndf/skills/playwright-execution/SKILL.md @@ -0,0 +1,99 @@ +--- +name: playwright-execution +description: "Playwright E2E テストの実行 + エビデンス収集 (video/trace/screenshot/HAR) + overlay (赤丸カーソル+字幕) + 品質計測 (axe-core/Web Vitals/body_check) を統合した実行フェーズスキル。動画はデフォルト ON。" +when_to_use: "E2E テストの実行 / エビデンス収集 / 動画エビデンス / accessibility チェック / Core Web Vitals 計測が必要なとき。テストスクリプト作成済みであることが前提。Triggers: 'E2E テスト実行', 'テスト実行', '動画エビデンス', 'エビデンス収集', 'テスト証跡', 'a11y テスト', 'accessibility テスト', 'axe-core', 'WCAG', 'Core Web Vitals', 'Web Vitals', 'LCP', 'CLS', 'body_check', 'overlay', '字幕', 'カーソル'" +allowed-tools: + - Read + - Bash(uv *) + - Bash(pytest *) + - Bash(npx *) + - Bash(playwright *) + - Bash(python *) +--- + +# Playwright Execution (テスト実行 + エビデンス収集) + +テストスクリプト作成済みの状態で E2E テストを実行し、エビデンスを収集する。 + +## 前提条件 + +- テストスクリプトが `tests/` に作成済みであること (`/ndf:playwright-script-creation` で作成) +- `scenario.config.yaml` が設定済みであること + +## 大原則 + +**エビデンス動画はデフォルト ON**。全テストで常に動画を取得する。 +明示的にスキップする場合のみ `--pwk-no-video` を指定する。 + +## 実行コマンド + +```bash +./scenario-test/run.sh # 全テスト (動画 ON) +./scenario-test/run.sh -k test_admin # フィルタ +./scenario-test/run.sh --pwk-overlay # 字幕 + カーソル付き動画 +./scenario-test/run.sh --pwk-no-video # 動画のみ OFF +./scenario-test/run.sh --pwk-no-evidence # 全エビデンス OFF (HAR/trace/動画) +``` + +## エビデンス種別 + +| 種別 | デフォルト | OFF フラグ | 説明 | +|---|---|---|---| +| video | **ON** | `--pwk-no-video` | 全テストの動画を取得 | +| trace | ON (retain-on-failure) | `--pwk-no-evidence` | Playwright Trace (DOM + 操作ログ) | +| HAR | ON (minimal) | `--pwk-har-mode none` | ネットワーク通信ログ | +| screenshot | ON (only-on-failure) | `--pwk-no-evidence` | 失敗時スクリーンショット | + +## overlay (赤丸カーソル + 字幕) + +`--pwk-overlay` フラグで全テストの動画にオーバーレイが適用される。 + +API 詳細・使用例は `playwright_kit/overlay.py` を参照。主要関数: `set_caption()`, `flash_click()`, `hide_cursor()`。 + +## 品質計測 + +### accessibility (axe-core) + +`@pytest.mark.page_role` marker が付いたテストで auto_roles にマッチする場合に自動実行。 +設定は `scenario.config.yaml` の `accessibility:` セクションで制御。→ 設定例は `templates/scenario.config.yaml` を参照。 + +### Core Web Vitals + +`@pytest.mark.page_role` marker + auto_roles マッチで LCP/CLS/TTFB/longest_task を自動計測。 +設定は `scenario.config.yaml` の `web_vitals:` セクションで制御。→ 設定例は `templates/scenario.config.yaml` を参照。 + +### body_check (PHP/SSR エラー検出) + +`page.on("response")` で全 HTML レスポンスを監視し、`Fatal error` 等を検出。デフォルト有効。 +`@pytest.mark.no_body_check` で個別 opt-out 可能。→ 設定例は `templates/scenario.config.yaml` の `body_check:` セクションを参照。 + +## 成果物 + +``` +reports// +├── report.md # テスト結果サマリ +├── / +│ ├── video.mp4 # テスト動画 (デフォルト ON) +│ ├── trace.zip # Playwright Trace +│ ├── request.har # ネットワーク通信ログ +│ ├── body_check.jsonl # body_check 違反詳細 +│ └── screenshot-*.png # スクリーンショット +``` + +## CLI options + +| option | 役割 | +|---|---| +| `--pwk-config ` | `scenario.config.yaml` のパス | +| `--pwk-out-dir ` | 成果物出力先 (default: `reports//`) | +| `--pwk-no-video` | 動画収集を OFF (デフォルトは ON) | +| `--pwk-no-evidence` | HAR / trace / video の収集を全て OFF | +| `--pwk-har-mode {minimal,full,none}` | HAR 録画モード (default: minimal) | +| `--pwk-overlay` | overlay (赤丸カーソル + 字幕) を ON | + +## 関連 Skill + +- `/ndf:playwright-script-creation` — テストスクリプト作成 (実行の前段) +- `/ndf:playwright-report` — Markdown レポート生成 +- `/ndf:playwright-kit-ops` — スクリプト実行 (init_project / スキャン) +- `/ndf:playwright-scenario-test` — 全機能統括 diff --git a/plugins/ndf/skills/playwright-scenario-test/.gitignore b/plugins/ndf/skills/playwright-kit-ops/.gitignore similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/.gitignore rename to plugins/ndf/skills/playwright-kit-ops/.gitignore diff --git a/plugins/ndf/skills/playwright-kit-ops/SKILL.md b/plugins/ndf/skills/playwright-kit-ops/SKILL.md new file mode 100644 index 00000000..76ed24c5 --- /dev/null +++ b/plugins/ndf/skills/playwright-kit-ops/SKILL.md @@ -0,0 +1,108 @@ +--- +name: playwright-kit-ops +description: "playwright_kit の操作に特化した実行エージェント。プロジェクト初期化 (init_project)、テスト実行、page role 分類、a11y/CWV 単発スキャン、エビデンスアップロードなど、playwright_kit のスクリプト群を実行する。" +when_to_use: "playwright_kit のスクリプトを実行するとき / E2E テストプロジェクトの初期化 / page role 自動分類 / 単発 a11y・CWV スキャン / Google Drive エビデンスアップロードが必要なとき。Triggers: 'init_project', 'プロジェクト初期化', 'classify_page_role', 'run_a11y_scan', 'check_cwv', 'upload_evidence', 'record_scenario', 'playwright_kit 実行'" +allowed-tools: + - Read + - Bash(python *) + - Bash(uv *) + - Bash(pytest *) + - Bash(playwright *) + - Bash(./scripts/*) + - Bash(bash *) + - Bash(chmod *) +--- + +# playwright_kit 操作エージェント + +playwright_kit のスクリプト群を実行してテスト環境のセットアップ・テスト実行・エビデンス管理を行う。 + +## スクリプト一覧 + +| スクリプト | 用途 | カテゴリ | +|---|---|---| +| `scripts/init_project.sh` | 利用者プロジェクトに scenario-test ランタイムを埋め込む | セットアップ | +| `scripts/init_project.bat` | 同 (Windows) | セットアップ | +| `scripts/classify_page_role.py` | URL の a11y tree + パターンから page role を自動推定 | テスト計画 | +| `scripts/record_scenario.py` | Playwright codegen で操作を記録しテストコード化 | テスト計画 | +| `scripts/run_a11y_scan.py` | axe-core による単発 accessibility スキャン | 品質 | +| `scripts/check_cwv.py` | Core Web Vitals (LCP/CLS/TTFB) 単発計測 | 品質 | +| `scripts/upload_evidence.py` | エビデンスファイルを Google Drive にアップロード | レポート | +| `scripts/gdrive_upload_dir.py` | ディレクトリごと Drive にバッチアップロード | レポート | +| `scripts/upload_md_as_gdoc.py` | Markdown を Google Doc に変換・アップロード | レポート | +| `scripts/build_gdoc_with_drive_links.py` | Google Doc にエビデンスの Drive リンクを埋め込み | レポート | + +## セットアップ + +### プロジェクト初期化 + +```bash +# SKILL_DIR はこの skill のパス +./scripts/init_project.sh /path/to/your-app + +# ディレクトリ名をカスタマイズ +./scripts/init_project.sh /path/to/your-app --runtime-dir e2e + +# Windows +scripts\init_project.bat C:\path\to\your-app +``` + +→ `your-app/scenario-test/` に all-in-one ランタイムが作成され、Skill 非依存で動作する。 + +### テスト実行 + +```bash +cd /path/to/your-app +./scenario-test/run.sh # 全テスト +./scenario-test/run.sh -k test_admin # フィルタ +./scenario-test/run.sh --pwk-overlay # 字幕 + カーソル付き動画 +./scenario-test/run.sh --pwk-drive-folder= # Drive 自動アップロード +``` + +## テスト計画ツール + +```bash +# page role を自動推定 +python scripts/classify_page_role.py --url https://example.com/products + +# Playwright codegen で操作を記録 +python scripts/record_scenario.py https://example.com/login +``` + +## 品質スキャンツール + +```bash +# axe-core 単発スキャン +python scripts/run_a11y_scan.py --url https://example.com + +# Core Web Vitals 単発計測 +python scripts/check_cwv.py --url https://example.com +``` + +## エビデンスアップロードツール + +```bash +# 単一ファイルを Drive にアップロード +python scripts/upload_evidence.py reports/run-001/test_login/trace.zip --kind trace + +# ディレクトリごとアップロード +python scripts/gdrive_upload_dir.py reports/run-001/ --folder-id + +# Markdown → Google Doc 変換 +python scripts/upload_md_as_gdoc.py reports/run-001/report.md + +# Google Doc にエビデンス Drive リンクを埋め込み +python scripts/build_gdoc_with_drive_links.py reports/run-001/ +``` + +## パッケージ参照 + +playwright_kit Python パッケージ本体・templates・tests はこの skill ディレクトリ内に配置されている。 + +## 関連 Skill + +- `/ndf:playwright-test-planning` — テスト計画 (方法論 + チェックリスト) +- `/ndf:playwright-script-creation` — テストスクリプト作成 +- `/ndf:playwright-execution` — テスト実行 + エビデンス収集 (video/trace/overlay/quality) +- `/ndf:playwright-report` — レポート生成 +- `/ndf:playwright-scenario-test` — 全機能統括 diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/__init__.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/__init__.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/__init__.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/__init__.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/accessibility.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/accessibility.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/accessibility.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/accessibility.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/body_check.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/body_check.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/body_check.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/body_check.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/config.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/config.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/config.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/config.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/__init__.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/__init__.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/__init__.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/__init__.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/accessibility.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/accessibility.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/accessibility.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/accessibility.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/auth.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/auth.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/auth.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/auth.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/body_check.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/body_check.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/body_check.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/body_check.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/evidence.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/evidence.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/evidence.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/evidence.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/web_vitals.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/web_vitals.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/fixtures/web_vitals.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/fixtures/web_vitals.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/overlay.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/overlay.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/overlay.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/overlay.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/pytest_plugin.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/pytest_plugin.py similarity index 93% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/pytest_plugin.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/pytest_plugin.py index 48fe3b02..81d7dffa 100644 --- a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/pytest_plugin.py +++ b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/pytest_plugin.py @@ -74,6 +74,12 @@ def pytest_addoption(parser: pytest.Parser) -> None: "config の playwright.har_mode より優先。" ), ) + group.addoption( + "--pwk-no-video", + action="store_true", + default=False, + help="動画収集を明示的に OFF にする (デフォルトは全テストで動画 ON)", + ) group.addoption( "--pwk-overlay", action="store_true", @@ -136,6 +142,28 @@ def pytest_configure(config: pytest.Config) -> None: # session 中で再利用するためにキャッシュする。 config._pwk_config = cfg # type: ignore[attr-defined] + # 動画デフォルト ON (大原則: エビデンス動画を常に取得) + # ユーザーが --video を CLI で明示指定した場合はそちらを優先する。 + # --pwk-no-video 指定時は video='off' に設定する。 + # --pwk-no-evidence 指定時も video='off' に設定する (全エビデンス OFF)。 + # pytest-playwright の --video デフォルト値は 'off' であるため、 + # getoption() の返り値では明示指定の有無を判別できない。 + # invocation_params.args を走査して明示指定を検出する。 + try: + cli_args = list(config.invocation_params.args) + video_explicitly_set = any( + a == "--video" or a.startswith("--video=") for a in cli_args + ) + no_video = config.getoption("pwk_no_video", default=False) + no_evidence = config.getoption("pwk_no_evidence", default=False) + if not video_explicitly_set: + if no_video or no_evidence: + config.option.video = "off" + else: + config.option.video = "on" + except (ValueError, AttributeError): + pass + # --------------------------------------------------------------------------- # Reports / hooks diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/pytest_report.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/pytest_report.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/pytest_report.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/pytest_report.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/uploaders/__init__.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/uploaders/__init__.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/uploaders/__init__.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/uploaders/__init__.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/video.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/video.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/video.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/video.py diff --git a/plugins/ndf/skills/playwright-scenario-test/playwright_kit/web_vitals.py b/plugins/ndf/skills/playwright-kit-ops/playwright_kit/web_vitals.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/playwright_kit/web_vitals.py rename to plugins/ndf/skills/playwright-kit-ops/playwright_kit/web_vitals.py diff --git a/plugins/ndf/skills/playwright-scenario-test/pyproject.toml b/plugins/ndf/skills/playwright-kit-ops/pyproject.toml similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/pyproject.toml rename to plugins/ndf/skills/playwright-kit-ops/pyproject.toml diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/_drive_auth.py b/plugins/ndf/skills/playwright-kit-ops/scripts/_drive_auth.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/scripts/_drive_auth.py rename to plugins/ndf/skills/playwright-kit-ops/scripts/_drive_auth.py diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/build_gdoc_with_drive_links.py b/plugins/ndf/skills/playwright-kit-ops/scripts/build_gdoc_with_drive_links.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/scripts/build_gdoc_with_drive_links.py rename to plugins/ndf/skills/playwright-kit-ops/scripts/build_gdoc_with_drive_links.py diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/check_cwv.py b/plugins/ndf/skills/playwright-kit-ops/scripts/check_cwv.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/scripts/check_cwv.py rename to plugins/ndf/skills/playwright-kit-ops/scripts/check_cwv.py diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/classify_page_role.py b/plugins/ndf/skills/playwright-kit-ops/scripts/classify_page_role.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/scripts/classify_page_role.py rename to plugins/ndf/skills/playwright-kit-ops/scripts/classify_page_role.py diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/gdrive_upload_dir.py b/plugins/ndf/skills/playwright-kit-ops/scripts/gdrive_upload_dir.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/scripts/gdrive_upload_dir.py rename to plugins/ndf/skills/playwright-kit-ops/scripts/gdrive_upload_dir.py diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/init_project.bat b/plugins/ndf/skills/playwright-kit-ops/scripts/init_project.bat similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/scripts/init_project.bat rename to plugins/ndf/skills/playwright-kit-ops/scripts/init_project.bat diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/init_project.sh b/plugins/ndf/skills/playwright-kit-ops/scripts/init_project.sh similarity index 97% rename from plugins/ndf/skills/playwright-scenario-test/scripts/init_project.sh rename to plugins/ndf/skills/playwright-kit-ops/scripts/init_project.sh index e5986d30..080c934e 100755 --- a/plugins/ndf/skills/playwright-scenario-test/scripts/init_project.sh +++ b/plugins/ndf/skills/playwright-kit-ops/scripts/init_project.sh @@ -129,7 +129,7 @@ echo "[init] [1/4] playwright_kit / scripts / uv.lock をコピー" # rsync -n でも failed to read directory で abort するため)。 if [[ $DRY_RUN -eq 1 ]]; then echo " rsync $SKILL_DIR/playwright_kit -> $RUNTIME_DIR/playwright_kit" - echo " rsync $SKILL_DIR/scripts -> $RUNTIME_DIR/scripts" + echo " rsync $SKILL_DIR/scripts -> $RUNTIME_DIR/scripts" echo " cp $SKILL_DIR/uv.lock -> $RUNTIME_DIR/uv.lock" else RSYNC_OPTS=(-a @@ -137,7 +137,7 @@ else --exclude='reports' --exclude='*.egg-info' ) rsync "${RSYNC_OPTS[@]}" "$SKILL_DIR/playwright_kit" "$RUNTIME_DIR/" - rsync "${RSYNC_OPTS[@]}" "$SKILL_DIR/scripts" "$RUNTIME_DIR/" + rsync "${RSYNC_OPTS[@]}" "$SKILL_DIR/scripts" "$RUNTIME_DIR/" cp "$SKILL_DIR/uv.lock" "$RUNTIME_DIR/uv.lock" fi diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/record_scenario.py b/plugins/ndf/skills/playwright-kit-ops/scripts/record_scenario.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/scripts/record_scenario.py rename to plugins/ndf/skills/playwright-kit-ops/scripts/record_scenario.py diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/run_a11y_scan.py b/plugins/ndf/skills/playwright-kit-ops/scripts/run_a11y_scan.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/scripts/run_a11y_scan.py rename to plugins/ndf/skills/playwright-kit-ops/scripts/run_a11y_scan.py diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/upload_evidence.py b/plugins/ndf/skills/playwright-kit-ops/scripts/upload_evidence.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/scripts/upload_evidence.py rename to plugins/ndf/skills/playwright-kit-ops/scripts/upload_evidence.py diff --git a/plugins/ndf/skills/playwright-scenario-test/scripts/upload_md_as_gdoc.py b/plugins/ndf/skills/playwright-kit-ops/scripts/upload_md_as_gdoc.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/scripts/upload_md_as_gdoc.py rename to plugins/ndf/skills/playwright-kit-ops/scripts/upload_md_as_gdoc.py diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/conftest.py.template b/plugins/ndf/skills/playwright-kit-ops/templates/conftest.py.template similarity index 79% rename from plugins/ndf/skills/playwright-scenario-test/templates/conftest.py.template rename to plugins/ndf/skills/playwright-kit-ops/templates/conftest.py.template index f231604e..f9de18ec 100644 --- a/plugins/ndf/skills/playwright-scenario-test/templates/conftest.py.template +++ b/plugins/ndf/skills/playwright-kit-ops/templates/conftest.py.template @@ -29,3 +29,14 @@ import pytest # @pytest.fixture # def admin_dashboard_url(pwk_config): # return f"{pwk_config.base_url}/admin/dashboard" + + +def pytest_collection_modifyitems(session, config, items): + if not items: + import warnings + + warnings.warn( + "[pwk] tests/ にテストスクリプトが見つかりません。" + "テストスクリプトを作成してから実行してください。", + stacklevel=1, + ) diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/pyproject.toml.runtime b/plugins/ndf/skills/playwright-kit-ops/templates/pyproject.toml.runtime similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/templates/pyproject.toml.runtime rename to plugins/ndf/skills/playwright-kit-ops/templates/pyproject.toml.runtime diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/run.bat b/plugins/ndf/skills/playwright-kit-ops/templates/run.bat similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/templates/run.bat rename to plugins/ndf/skills/playwright-kit-ops/templates/run.bat diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/run.sh b/plugins/ndf/skills/playwright-kit-ops/templates/run.sh similarity index 87% rename from plugins/ndf/skills/playwright-scenario-test/templates/run.sh rename to plugins/ndf/skills/playwright-kit-ops/templates/run.sh index ea01aee2..f83d6016 100755 --- a/plugins/ndf/skills/playwright-scenario-test/templates/run.sh +++ b/plugins/ndf/skills/playwright-kit-ops/templates/run.sh @@ -33,6 +33,7 @@ scenario-test ランタイムランチャ --pwk-config scenario.config.yaml のパス (env PWK_CONFIG でも可) --pwk-out-dir 成果物出力先 (default: ./reports//) --pwk-no-evidence HAR / trace / 動画 を OFF + --pwk-no-video 動画収集を OFF (デフォルトは全テストで動画 ON) --pwk-har-mode {minimal,full,none} HAR 録画モード (default: minimal) --pwk-overlay 動画に赤丸カーソル + 字幕 (旧名 HUD) を焼き込む @@ -83,6 +84,18 @@ fi # --- 3) pytest 実行 ------------------------------------------------ cd "$RUNTIME_DIR" + +# --pwk-no-video / --pwk-no-evidence / --video=* が引数に含まれていなければ +# --video=on をデフォルト追加。pytest_plugin.py 側でもデフォルト注入するが、 +# run.sh 経由の場合は明示的に渡すことで --video の優先度を確保する。 +VIDEO_FLAG="--video=on" +for arg in "$@"; do + case "$arg" in + --pwk-no-video|--pwk-no-evidence|--video|--video=*) VIDEO_FLAG="" ;; + esac +done + exec uv run pytest \ --pwk-config="${PWK_CONFIG:-./scenario.config.yaml}" \ + $VIDEO_FLAG \ "$@" diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/runtime-README.md b/plugins/ndf/skills/playwright-kit-ops/templates/runtime-README.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/templates/runtime-README.md rename to plugins/ndf/skills/playwright-kit-ops/templates/runtime-README.md diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/runtime-gitignore b/plugins/ndf/skills/playwright-kit-ops/templates/runtime-gitignore similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/templates/runtime-gitignore rename to plugins/ndf/skills/playwright-kit-ops/templates/runtime-gitignore diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/scenario.config.yaml b/plugins/ndf/skills/playwright-kit-ops/templates/scenario.config.yaml similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/templates/scenario.config.yaml rename to plugins/ndf/skills/playwright-kit-ops/templates/scenario.config.yaml diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/test_auth.py.template b/plugins/ndf/skills/playwright-kit-ops/templates/test_auth.py.template similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/templates/test_auth.py.template rename to plugins/ndf/skills/playwright-kit-ops/templates/test_auth.py.template diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/test_dashboard.py.template b/plugins/ndf/skills/playwright-kit-ops/templates/test_dashboard.py.template similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/templates/test_dashboard.py.template rename to plugins/ndf/skills/playwright-kit-ops/templates/test_dashboard.py.template diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/test_form.py.template b/plugins/ndf/skills/playwright-kit-ops/templates/test_form.py.template similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/templates/test_form.py.template rename to plugins/ndf/skills/playwright-kit-ops/templates/test_form.py.template diff --git a/plugins/ndf/skills/playwright-scenario-test/templates/test_list.py.template b/plugins/ndf/skills/playwright-kit-ops/templates/test_list.py.template similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/templates/test_list.py.template rename to plugins/ndf/skills/playwright-kit-ops/templates/test_list.py.template diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/__init__.py b/plugins/ndf/skills/playwright-kit-ops/tests/__init__.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/__init__.py rename to plugins/ndf/skills/playwright-kit-ops/tests/__init__.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/conftest.py b/plugins/ndf/skills/playwright-kit-ops/tests/conftest.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/conftest.py rename to plugins/ndf/skills/playwright-kit-ops/tests/conftest.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_a11y_cwv_routing.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_a11y_cwv_routing.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_a11y_cwv_routing.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_a11y_cwv_routing.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_auth_cache.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_auth_cache.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_auth_cache.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_auth_cache.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_body_check.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_body_check.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_body_check.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_body_check.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_config_basic_auth.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_config_basic_auth.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_config_basic_auth.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_config_basic_auth.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_evidence_fixture.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_evidence_fixture.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_evidence_fixture.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_evidence_fixture.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_makereport_user_properties.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_makereport_user_properties.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_makereport_user_properties.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_makereport_user_properties.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_pytest_plugin_bootstrap.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_pytest_plugin_bootstrap.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_pytest_plugin_bootstrap.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_pytest_plugin_bootstrap.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_pytest_report.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_pytest_report.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_pytest_report.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_pytest_report.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_pytest_terminal_summary.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_pytest_terminal_summary.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_pytest_terminal_summary.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_pytest_terminal_summary.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_pytester_integration.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_pytester_integration.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_pytester_integration.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_pytester_integration.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_same_origin.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_same_origin.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_same_origin.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_same_origin.py diff --git a/plugins/ndf/skills/playwright-scenario-test/tests/test_upload_evidence.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_upload_evidence.py similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/tests/test_upload_evidence.py rename to plugins/ndf/skills/playwright-kit-ops/tests/test_upload_evidence.py diff --git a/plugins/ndf/skills/playwright-kit-ops/tests/test_video_default.py b/plugins/ndf/skills/playwright-kit-ops/tests/test_video_default.py new file mode 100644 index 00000000..4bb9ebcb --- /dev/null +++ b/plugins/ndf/skills/playwright-kit-ops/tests/test_video_default.py @@ -0,0 +1,63 @@ +"""--pwk-no-video オプションと動画デフォルト ON の検証。 + +pytest-playwright の --video オプションが playwright_kit plugin 経由で +デフォルト 'on' に設定されること、および --pwk-no-video で 'off' に +切り替わることを pytester 経由で検証する。 +""" + +from __future__ import annotations + +import textwrap + + +def test_pwk_no_video_option_registered(pytester): + """--pwk-no-video が pytest -h に出ること。""" + pytester.makepyfile("def test_dummy(): pass\n") + res = pytester.runpytest("--help") + out = res.stdout.str() + assert "--pwk-no-video" in out + + +def test_video_default_on(pytester): + """--video 未指定時、playwright_kit が video='on' をデフォルト設定すること。""" + pytester.makepyfile( + textwrap.dedent( + """ + def test_video_config(pytestconfig): + video = pytestconfig.getoption("video", default=None) + assert video == "on", f"expected 'on', got {video!r}" + """ + ) + ) + res = pytester.runpytest("-q") + res.assert_outcomes(passed=1) + + +def test_pwk_no_video_sets_off(pytester): + """--pwk-no-video 指定時、video='off' になること。""" + pytester.makepyfile( + textwrap.dedent( + """ + def test_video_config(pytestconfig): + video = pytestconfig.getoption("video", default=None) + assert video == "off", f"expected 'off', got {video!r}" + """ + ) + ) + res = pytester.runpytest("-q", "--pwk-no-video") + res.assert_outcomes(passed=1) + + +def test_explicit_video_flag_takes_precedence(pytester): + """--video=retain-on-failure を明示指定した場合、pwk が上書きしないこと。""" + pytester.makepyfile( + textwrap.dedent( + """ + def test_video_config(pytestconfig): + video = pytestconfig.getoption("video", default=None) + assert video == "retain-on-failure", f"expected 'retain-on-failure', got {video!r}" + """ + ) + ) + res = pytester.runpytest("-q", "--video=retain-on-failure") + res.assert_outcomes(passed=1) diff --git a/plugins/ndf/skills/playwright-scenario-test/uv.lock b/plugins/ndf/skills/playwright-kit-ops/uv.lock similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/uv.lock rename to plugins/ndf/skills/playwright-kit-ops/uv.lock diff --git a/plugins/ndf/skills/playwright-report/SKILL.md b/plugins/ndf/skills/playwright-report/SKILL.md new file mode 100644 index 00000000..aca64e87 --- /dev/null +++ b/plugins/ndf/skills/playwright-report/SKILL.md @@ -0,0 +1,49 @@ +--- +name: playwright-report +description: "Playwright テスト結果の Markdown レポート自動生成。テスト結果サマリ・エビデンスリンク・失敗詳細を report.md にまとめる。" +when_to_use: "テストレポートの生成 / テスト結果の共有が必要なとき。Triggers: 'テストレポート', 'report.md', 'テスト結果', 'テスト報告書', 'レポート生成', 'テスト結果まとめ'" +allowed-tools: + - Read + - Bash(uv *) + - Bash(pytest *) + - Bash(python *) +--- + +# Playwright Report (レポート生成) + +テスト実行後に **Markdown レポート** を自動生成する。 + +## 自動生成 + +`pytest_terminal_summary` hook で `reports//report.md` が自動生成される。特別な設定は不要。 + +```bash +./scenario-test/run.sh +# → reports//report.md が生成される +``` + +## レポート内容 + +| セクション | 内容 | +|---|---| +| サマリ表 | nodeid, role, page_role, 結果, 実行時間, エラー数 | +| 失敗詳細 | FAIL/ERROR のテストごとの詳細情報 | +| body_check 違反 | PHP/SSR エラー検出の詳細 (URL, パターン, スニペット) | +| エビデンスリンク | video, trace, HAR, screenshot へのパス | + +## レポート設定 + +`scenario.config.yaml` の `report` セクション: + +```yaml +report: + title: "シナリオ E2E テスト 実施報告書" + test_plan_link: "./test-plan.md" + phase_labels: {} +``` + +## 関連 Skill + +- `/ndf:playwright-execution` — テスト実行 + エビデンス収集 +- `/ndf:playwright-kit-ops` — エビデンスアップロードツール (Drive 連携が必要な場合) +- `/ndf:playwright-scenario-test` — 全機能を統括したフルワークフロー diff --git a/plugins/ndf/skills/playwright-scenario-test/SKILL.md b/plugins/ndf/skills/playwright-scenario-test/SKILL.md index fe888b04..3fefbe1b 100644 --- a/plugins/ndf/skills/playwright-scenario-test/SKILL.md +++ b/plugins/ndf/skills/playwright-scenario-test/SKILL.md @@ -1,7 +1,7 @@ --- name: playwright-scenario-test -description: "pytest-playwright 上の Web シナリオ E2E テスト実施フレームワーク。HTSM / ISTQB / FEW HICCUPPS に基づき page role 別の checklist + 必須技法マッピングを内蔵し、accessibility (axe-core) / Core Web Vitals 自動計測 + Playwright trace / HAR / 動画 / Markdown レポート + Google Drive 共有を pytest fixture / hook として提供する。v0.5.0 で利用者プロジェクトに all-in-one ディレクトリを埋め込む Skill 非依存構成へ移行。" -when_to_use: "E2E テスト計画立案 / 不具合エビデンス収集 / 動画レポート / Google Drive 共有が必要なとき。LP / 一覧 / 詳細 / 編集 / 申込フォーム / 検索 / ダッシュボード / 認証 / カート / チェックアウト / モーダル / ウィザード / 設定 / エラーページ など page role 別の理論ベースチェックを行う。Triggers: 'E2E テスト', 'シナリオテスト', '動画エビデンス', 'Playwright', 'pytest-playwright', 'リリース前確認', '回帰テスト', 'a11y テスト', 'accessibility テスト', 'Core Web Vitals', 'Web Vitals', 'page role', 'pwk_role', 'pwk_evidence'" +description: "pytest-playwright ベースのフル E2E テストフレームワーク統括。テスト計画・スクリプト作成・エビデンス付きテスト実行・レポート生成の 4 フェーズを組み合わせた包括的なテストワークフローを提供する。個別機能のみ必要な場合は各専門 skill を直接参照。" +when_to_use: "フル E2E テストワークフロー (計画→スクリプト→実行→レポート) を一貫して行うとき / pytest-playwright 拡張 fixture (pwk_*) の全体像を把握したいとき / init_project.sh でプロジェクトをセットアップするとき。Triggers: 'pytest-playwright', 'pwk_role', 'pwk_evidence', 'init_project', 'シナリオテスト一式', 'フル E2E'" allowed-tools: - Read - Bash(uv *) @@ -10,306 +10,57 @@ allowed-tools: - Bash(python *) --- -# Playwright シナリオテスト Skill (v0.5.0) +# Playwright シナリオテスト Skill (v0.6.0) -Web アプリの E2E シナリオを **理論ベース** で計画し、**pytest-playwright** 上で実行、**動画 + Markdown レポート + accessibility / web vitals** を自動収集する一式の Skill。 +Web アプリの E2E シナリオを **理論ベース** で計画し、**再現可能なテストスクリプトを実装してから**、**pytest-playwright** 上でエビデンス動画付きで実行、Markdown レポートを自動生成する一式の Skill。 -**v0.5.0 の方針**: 本 Skill は「テストを書き始めるためのスキャフォルダ」であり、`scripts/init_project.sh` で利用者プロジェクトに **all-in-one ディレクトリ** を埋め込んだ後は、Skill ディレクトリの存在に依存せず単独で動作する (CI / 別マシン / Skill 非導入のメンバー環境でも完結)。 +## 大原則 -## 用語集 +1. **再現可能なテストスクリプトを実装してからテストを実施する** +2. **テストスクリプトは ndf plugin 非依存でプロジェクトフォルダに設置する** +3. **テスト実行はエビデンス動画を常に取得する** (オプションで明示的にスキップ可能) -ドメイン略語と正式名・意味の対応表。 +## フェーズ別 Skill -| 略語 / 用語 | 正式名 / 意味 | -|---|---| -| accessibility (旧 a11y) | Web アクセシビリティ。WCAG 準拠を axe-core で機械検査 | -| web vitals (旧 CWV) | Google が定義する「ユーザ体感パフォーマンス指標」群 | -| LCP | Largest Contentful Paint — 最大コンテンツ描画時間 (体感ロード速度) | -| CLS | Cumulative Layout Shift — 累積レイアウトずれ量 (視覚的安定性) | -| TTFB | Time To First Byte — 初バイト到達時間 (サーバ応答速さ) | -| longest_task | Long Tasks API で観測した最長タスクのミリ秒値 (応答性代理指標) | -| HAR | HTTP Archive — ネットワーク通信ログのファイル形式 | -| trace | Playwright Trace — DOM スナップショット + 操作ログ + 動画の zip | -| overlay (旧 HUD) | テスト中に画面に重ねる赤丸カーソル + 字幕表示 | -| body_check | サーバが HTML 本文に出力した PHP/SSR エラー文字列の検出 | -| page role | LP / 一覧 / 詳細 / フォーム 等のページ種別。a11y / web vitals 自動実行の判定材料 | -| pwk | playwright_kit の略。fixture (`pwk_*`) / CLI option (`--pwk-*`) / env (`PWK_*`) の prefix | - -## 提供物 - -``` -playwright-scenario-test/ ← Skill 自体 (この Skill ディレクトリ) -├── SKILL.md ← このファイル -├── pyproject.toml ← Skill 開発用 (pytest entry-point 含む) -├── playwright_kit/ ← Python パッケージ本体 (旧 scenario_test) -│ ├── pytest_plugin.py ← pytest11 entry-point (addoption / markers / hooks) -│ ├── pytest_report.py ← report.md 生成 -│ ├── fixtures/ ← pytest fixtures -│ │ ├── auth.py — pwk_config / pwk_role_ -│ │ ├── evidence.py — pwk_evidence (HAR / trace / console / pageerror) -│ │ ├── accessibility.py — page_role marker autouse で axe-core -│ │ ├── web_vitals.py — page_role marker autouse で Core Web Vitals -│ │ └── body_check.py — page.on("response") で本文エラー文字列を検出 -│ ├── accessibility.py / web_vitals.py — axe-core / Web Vitals ランナー (純関数) -│ ├── overlay.py ← 赤丸カーソル + 字幕 (旧 HUD) JS -│ ├── video.py ← webm → mp4 変換 -│ └── config.py ← scenario.config.yaml ローダ -├── docs/ ← テスト方法論 (HTSM / ISTQB / FEW HICCUPPS) -├── scripts/ -│ ├── init_project.sh ← all-in-one 初期化 (rsync ベース) -│ ├── init_project.bat ← 同 Windows 版 (xcopy ベース) -│ ├── classify_page_role.py / run_a11y_scan.py / check_cwv.py / record_scenario.py -│ └── upload_evidence.py / gdrive_upload_dir.py / build_gdoc_with_drive_links.py -└── templates/ ← 利用者プロジェクト用雛形 - ├── pyproject.toml.runtime — runtime 用 pyproject (dev 用 deps を排除) - ├── runtime-gitignore — .venv / __pycache__ / reports/ - ├── runtime-README.md — Skill 無し環境向けの最低限の使い方 - ├── run.sh / run.bat — ワンコマンドランチャ - ├── scenario.config.yaml — base_url / roles / accessibility / web_vitals 設定 - ├── conftest.py.template — 利用者の conftest.py 雛形 - └── test_*.py.template — auth / list / form / dashboard 雛形 -``` - -init 後の利用者プロジェクト側 (Skill 非依存): - -``` -your-app/ -└── scenario-test/ ← all-in-one ランタイム (--runtime-dir で名前変更可) - ├── playwright_kit/ ← Python パッケージ本体 - ├── scripts/ ← 補助 CLI - ├── tests/ ← 利用者の pytest テスト - │ ├── conftest.py - │ └── test_*.py - ├── reports/ ← 実行結果 (.gitignore 推奨) - ├── scenario.config.yaml ← 利用者の設定 - ├── run.sh / run.bat ← ワンコマンドランチャ - ├── pyproject.toml ← runtime 用 (testpaths=["tests"]) - ├── uv.lock ← 再現性のため commit 推奨 - └── README.md ← runtime-README.md コピー -``` - -## クイックスタート - -```bash -# 1) このディレクトリ (Skill) で利用者プロジェクトを初期化 -cd .claude/plugins/ndf/skills/playwright-scenario-test # Skill のパスは環境による -./scripts/init_project.sh /path/to/your-app -# → /path/to/your-app/scenario-test/ 一式が作成され、uv sync + chromium install -# まで完了する - -# オプション: 配置先ディレクトリ名をカスタマイズ -./scripts/init_project.sh /path/to/your-app --runtime-dir e2e -# → /path/to/your-app/e2e/ - -# Windows -scripts\init_project.bat C:\path\to\your-app - -# 2) base_url / roles を編集 -$EDITOR /path/to/your-app/scenario-test/scenario.config.yaml - -# 3) tests/ にテストを追加 (init 時に test_auth/list/form/dashboard 雛形は配置済) -$EDITOR /path/to/your-app/scenario-test/tests/test_admin.py - -# 4) 実行 -cd /path/to/your-app -./scenario-test/run.sh # 全テスト -./scenario-test/run.sh -k test_admin # nodeid フィルタ -./scenario-test/run.sh --pwk-overlay # 動画に赤丸カーソル + 字幕 -./scenario-test/run.sh --pwk-drive-folder= # Drive 自動アップロード -``` - -→ 以降このディレクトリ (Skill) は不要。`your-app/scenario-test/` 単体で完結する。 - -### 複数ランタイム共存 - -```bash -./scripts/init_project.sh your-app --runtime-dir e2e-prod -./scripts/init_project.sh your-app --runtime-dir e2e-staging -# → your-app/e2e-prod/run.sh と your-app/e2e-staging/run.sh が独立に動く -``` - -## 利用者は通常の pytest テストを書く - -```python -# tests/test_admin_dashboard.py -import pytest -from playwright.sync_api import Page, expect - -@pytest.mark.page_role("dashboard") -@pytest.mark.role("admin") -def test_admin_kpi_view(page: Page, pwk_role_admin): - page.goto("/admin/dashboard") - expect(page.get_by_role("heading", name="売上サマリ")).to_be_visible() - page.get_by_role("link", name="ユーザ管理").click() - expect(page).to_have_url(lambda u: "/admin/users" in u) -``` - -提供 fixture / marker: - -| 提供 | 種別 | 役割 | +| Phase | Skill | 機能 | |---|---|---| -| `pwk_config` | session fixture | `scenario.config.yaml` をロード (Config dataclass) | -| `pwk_role_` | function fixture (動的) | 該当 role で login 済の storage_state を context に注入 | -| `pwk_evidence` | function fixture | HAR / trace / console.error / pageerror / body_check の集中管理 | -| `pwk_accessibility_scan()` | helper | 任意のタイミングで axe-core を 1 回実行 | -| `pwk_web_vitals_measure()` | helper | 任意のタイミングで Web Vitals を 1 回計測 | -| `pwk_body_check_scan()` | helper | 任意のタイミングで現在の page 本文を 1 回 body_check | -| `@pytest.mark.page_role("form")` | marker | accessibility / web_vitals autouse の判定 (auto_roles 設定に従う) | -| `@pytest.mark.role("admin")` | marker | report.md 集計用 (login 自体は `pwk_role_` fixture) | -| `@pytest.mark.phase(1)` | marker | report.md フェーズ集計 | -| `@pytest.mark.priority("high")` | marker | report.md ソート | -| `@pytest.mark.no_body_check` | marker | body_check autouse をこの test では skip | - -### body_check (PHP / SSR エラー検出, v0.4.0+) +| 1 | `/ndf:playwright-test-planning` | テスト計画 (HTSM / page role / チェックリスト) | +| 2 | `/ndf:playwright-script-creation` | テストスクリプト作成 (テンプレート→実装→レビュー) | +| 3 | `/ndf:playwright-execution` | テスト実行 + エビデンス収集 (video/trace/overlay/quality) | +| 4 | `/ndf:playwright-report` | レポート生成 (Markdown) | +| -- | `/ndf:playwright-kit-ops` | ツール群 (init_project / スキャン / アップロード) | -PHP / SSR が HTML 本文に直接出力した `Fatal error` / `Warning:` / `STRICT:` 等の -エラー文字列は console.error / pageerror では拾えない。`body_check` は -`page.on("response")` で全 HTML レスポンスを監視し、文字列パターンとの substring -一致で violation を記録する。**default で enabled + PHP 系パターン内蔵** なので、 -config を書かなくても PHP プロジェクトでまず動く。 - -パターンを上書きしたい場合のみ `scenario.config.yaml` で明示する: - -```yaml -# scenario.config.yaml (省略可) -body_check: - enabled: true - fatal_patterns: ["Fatal error", "Uncaught", "Parse error"] - warning_patterns: ["STRICT:", "Warning:", "Notice:", "Deprecated:"] - warning_head_chars: 300 # warning_patterns は本文先頭 N 文字のみ走査 (旧名 warning_head_bytes も alias) - not_found_patterns: ["File not found"] - fail_on_match: true # false で情報収集モード (PASS のまま report に記録) -``` - -- 違反は `case_dir/body_check.jsonl` に 1 violation = 1 行で出力 (`jq`/`grep` - で集計しやすいよう flat structure にしている) -- `report.md` のサマリ表に `body_check` カラムが、件数 > 0 の場合は詳細セクション - (URL / pattern / snippet) が出力される -- 機能ごと無効化したい場合は `body_check.enabled: false` を明示 -- 個別カテゴリのみ無効化したい場合は `fatal_patterns: []` のように明示空指定 -- 個別 test で skip したい場合は `@pytest.mark.no_body_check` を付与 -- 非 PHP プロジェクトでは default の `Notice:` / `Warning:` 等が誤検出になる - 場合あり。その場合は `warning_patterns: []` で warning カテゴリだけ無効化するか - `enabled: false` で機能ごと off にする - -## CLI options - -ランチャ経由 (`./run.sh` / `run.bat`) でも、`uv run pytest` を直接呼んでも、同じ option がそのまま効く。 - -| option | 役割 | -|---|---| -| `--pwk-config ` | `scenario.config.yaml` のパス。env `PWK_CONFIG` / CWD の同名ファイルでも可 | -| `--pwk-out-dir ` | 成果物出力先 (default: `reports//`) | -| `--pwk-no-evidence` | HAR / trace / video の収集を OFF | -| `--pwk-har-mode {minimal,full,none}` | HAR 録画モード (default: minimal、Issue #62) | -| `--pwk-overlay` | overlay (赤丸カーソル + 字幕、旧名 HUD) を全 page に inject | -| `--pwk-drive-folder ` | session 終了時に report.md と evidence を Drive アップロード | - -pytest 標準と組み合わせて使える: - -```bash -# page_role marker が付いたテストだけ実行 -./scenario-test/run.sh -m "page_role" - -# 4 worker で並列実行 -./scenario-test/run.sh -n 4 - -# 動画レポートを Drive へ自動アップロード -./scenario-test/run.sh --pwk-drive-folder= - -# pytest-html を組み合わせて HTML report も -./scenario-test/run.sh --html=reports/index.html --self-contained-html -``` - -## 標準ワークフロー (理論ベース計画) +## 標準ワークフロー ``` -[A] 対象 URL を渡される - │ -[B] page role を判定 scripts/classify_page_role.py --url - ▼ -[C] 該当 checklist を開く docs/checklists/checklist-{role}.md - │ 全項目を「適用」or「不適用 (理由付き)」で判定 - ▼ -[D] 必須技法を確定 docs/03-test-techniques.md § 11 - ▼ -[E] pytest テストを書く templates/test_.py.template を起点に - │ `playwright codegen` で操作 → そのまま test 関数に貼る or 整形 - ▼ -[F] 実行 ./scenario-test/run.sh - │ trace.zip / video / HAR / console / accessibility / web_vitals を自動収集 - ▼ -[G] レポート確認 scenario-test/reports//report.md - │ --pwk-drive-folder 指定で Drive にアップロード + viewer URL 化 - ▼ -[H] 不具合発見 → bug report docs/05-bug-report.md - FEW HICCUPPS の oracle 軸を必ず付与 +[Phase 1] テスト計画 (/ndf:playwright-test-planning) + │ 対象 URL → page role 判定 → チェックリスト → テスト技法確定 + ▼ +[Phase 2] スクリプト作成 (/ndf:playwright-script-creation) + │ テンプレート選択 → テストコード実装 → 再現可能性レビュー + │ ※ スクリプトが完成するまでテスト実行に進まない + ▼ +[Phase 3] テスト実行 + エビデンス収集 (/ndf:playwright-execution) + │ 動画デフォルト ON → trace/HAR/overlay/a11y/CWV/body_check + │ ※ --pwk-no-video で動画のみスキップ可 + ▼ +[Phase 4] レポート生成 (/ndf:playwright-report) + │ reports//report.md 自動生成 + ▼ +[任意] ツール群 (/ndf:playwright-kit-ops) + init_project / スキャン / アップロード (任意タイミング) ``` -## 単発 CLI ツール (補助) - -| Script | 用途 | -|---|---| -| `scripts/classify_page_role.py --url ` | a11y tree + URL pattern + role 集計から page role 推定 | -| `scripts/record_scenario.py ` | Playwright codegen を起動し操作を Python コードで取得 | -| `scripts/run_a11y_scan.py --url ` | axe-core 単発スキャン | -| `scripts/check_cwv.py --url ` | Web Vitals (LCP/CLS/TTFB) 単発計測 | -| `scripts/upload_evidence.py --kind trace --public` | Drive アップロード + Playwright Trace Viewer URL 生成 | - -## docs/ 配下 (理論ベース知識) - -| ファイル | 内容 | -|---|---| -| `docs/01-methodology.md` | 総論: HTSM / FEW HICCUPPS / ISO 29119-3 の位置付け | -| `docs/02-page-roles.md` | page role 分類 (lp/list/item/edit/form/search/...) | -| `docs/03-test-techniques.md` | テスト技法 (EP / BVA / Decision Table / Pairwise) と role 必須マッピング | -| `docs/04-playwright-mapping.md` | Playwright API → role / 観点 マッピング | -| `docs/05-bug-report.md` | bug report 仕様 (ISO 29119-3 + FEW HICCUPPS) | -| `docs/06-pytest-playwright.md` | pytest-playwright fixture / CLI option / playwright_kit 拡張との対応関係 | -| `docs/checklists/checklist-.md` | role 別チェックリスト (lp/list/item/edit/form/search/dashboard/auth/cart-checkout/modal-wizard/common) | - -## テスト雛形 (templates/) - -利用者は role に応じて `test_.py.template` をコピーして編集する (init 時に -4 ファイルが配置済)。各テンプレートには: - -- 該当 `page_role` marker -- 該当 `pwk_role_` fixture -- `expect()` ベースの web-first assertion -- 正常系 + 1 件以上の異常系 - -が含まれる。 - -## 開発者向け: Skill 単体で動かす旧運用 - -Skill 自身の改修・テスト時のみ、Skill ディレクトリで直接 pytest を回す: - -```bash -cd .claude/plugins/ndf/skills/playwright-scenario-test -uv sync -uv run pytest -q # 159 件 pure 関数テスト -``` - -利用者環境向け (`init_project.sh` 経由) と Skill 開発用は **別の uv プロジェクト** -として分離される (利用者側は `templates/pyproject.toml.runtime` を用い、開発側は -リポジトリルートの `pyproject.toml` を用いる)。 +## クイックスタート -## 制約 / 注意 +1. プロジェクト初期化: `/ndf:playwright-kit-ops` で `./scripts/init_project.sh /path/to/your-app` を実行 +2. 設定編集: `scenario-test/scenario.config.yaml` +3. テストスクリプト作成: `scenario-test/tests/test_*.py` (→ `/ndf:playwright-script-creation`) +4. テスト実行 (動画デフォルト ON): `./scenario-test/run.sh` +5. 動画スキップ: `./scenario-test/run.sh --pwk-no-video` -- **依存**: `pytest>=8.0`, `pytest-playwright>=0.5`, `pytest-xdist>=3.0`, `playwright>=1.50` -- **認証情報は YAML に直書きしない**: `scenario.config.yaml` の `fields.Password` 等は `${ENV_VAR}` で参照し、実値は環境変数 (`.env` / `direnv` / shell export) で管理してください。リポジトリに認証情報をコミットしないこと -- **トレース / HAR / 動画は機微情報を含む**: - - HAR には URL のクエリ文字列・Cookie・Authorization ヘッダ等が記録されます - - trace.zip には localStorage / 操作履歴 / DOM スナップショットが含まれます - - `--pwk-drive-folder=` は **private folder** を指定し、共有相手を限定してください - - `upload_evidence.py --public` を付けない限り Drive にも非公開でアップ (既定) -- **CI**: GitHub Actions では `cd scenario-test && uv run pytest -n auto` でそのまま回せる -- **Skill 更新時の追従**: 開発中につきコピー済ランタイムは再 `init_project.sh` で - 上書き運用 (`scenario.config.yaml` / `tests/conftest.py` / `tests/test_*.py` は - 既存があれば skip するため利用者編集物は保護される) +→ `your-app/scenario-test/` は ndf plugin 非依存。単体で完結する。 -## 関連ドキュメント +## 用語集・制約 -- `docs/README.md` — 知識マップ -- `templates/scenario.config.yaml` — 設定例 -- `templates/runtime-README.md` — init 後の `your-app/scenario-test/README.md` 元 +用語集 (accessibility, web vitals, LCP, CLS, TTFB, HAR, trace, overlay, body_check, page role, pwk) と制約/注意事項は `playwright_kit/` パッケージの README (`templates/runtime-README.md`) および `pyproject.toml` (`templates/pyproject.toml.runtime`) を参照。 diff --git a/plugins/ndf/skills/playwright-script-creation/SKILL.md b/plugins/ndf/skills/playwright-script-creation/SKILL.md new file mode 100644 index 00000000..9c259f96 --- /dev/null +++ b/plugins/ndf/skills/playwright-script-creation/SKILL.md @@ -0,0 +1,108 @@ +--- +name: playwright-script-creation +description: "再現可能な E2E テストスクリプトを作成するガイド。テンプレートを起点にテストコードを実装し、再現可能性レビューを経てからテスト実行フェーズに進む。ndf plugin 非依存で動作する。" +when_to_use: "E2E テストスクリプトの作成 / テストコードの実装 / テストテンプレートからのスクリプト生成が必要なとき。Triggers: 'テストスクリプト作成', 'テストコード作成', 'テスト実装', 'テストを書く', 'シナリオ作成', 'codegen', 'テンプレートからテスト', 'playwright codegen'" +allowed-tools: + - Read + - Edit + - Write + - Bash(uv *) + - Bash(playwright *) + - Bash(python *) +--- + +# Playwright Script Creation (テストスクリプト作成) + +再現可能なテストスクリプトを作成し、レビューを経てからテスト実行に進む。 + +## 大原則 + +**テストスクリプトを実装してからテストを実施する。** +スクリプトが完成・レビューを経るまで `/ndf:playwright-execution` に進まない。 + +## 前提条件 + +- テスト計画が完了していること (`/ndf:playwright-test-planning` で計画済み) +- `init_project.sh` でプロジェクトが初期化済みであること (`/ndf:playwright-kit-ops`) + +## ワークフロー + +``` +[A] テスト計画の確認 (チェックリスト / page role / テスト技法) + │ +[B] テンプレート選択 + │ tests/ 配下の test_*.py.template を起点にする + ▼ +[C] テストコード実装 + │ playwright codegen で操作を記録 → テスト関数に組み込む + │ または手動で expect() ベースの assertion を書く + ▼ +[D] 再現可能性レビュー (下記チェックリスト) + │ +[E] テスト実行へ → /ndf:playwright-execution +``` + +## テンプレート一覧 + +`init_project.sh` で以下のテンプレートが `tests/` に配置済み: + +| テンプレート | page role | 内容 | +|---|---|---| +| `test_auth.py` | auth | ログイン / ログアウトフロー | +| `test_list.py` | list | 一覧ページネーション / ソート | +| `test_form.py` | form | 入力 → 送信 → 結果検証 | +| `test_dashboard.py` | dashboard | KPI / リンク遷移 | + +## テストコードの書き方 + +### テンプレートを起点にする + +各 page role のテンプレートが `templates/test_*.py.template` に用意されている。 +`init_project.sh` 実行時に `tests/` へコピーされるので、プロジェクト固有の URL やセレクタを書き換えて使う。 + +→ コード例: `templates/test_form.py.template`, `templates/test_auth.py.template` 等を参照 + +### playwright codegen での操作記録 + +`uv run playwright codegen ` で操作を記録し、生成コードをテスト関数にコピーする。 +コピー後に `@pytest.mark.page_role()`, `@pytest.mark.role()`, `expect()` assertion, `pwk_config.base_url` を追加する。 + +### overlay 付きテスト + +overlay API (`set_caption`, `flash_click`) の使用例は `playwright_kit/overlay.py` を参照。 + +## fixture / marker 一覧 + +fixture / marker の完全な一覧は `playwright_kit/pytest_plugin.py` の `_PWK_MARKERS` 定義と `playwright_kit/fixtures/` 配下の各モジュールを参照。 + +主な fixture: `pwk_config`, `pwk_role_`, `pwk_evidence`, `pwk_accessibility_scan()`, `pwk_web_vitals_measure()` +主な marker: `@pytest.mark.page_role()`, `@pytest.mark.role()`, `@pytest.mark.phase()`, `@pytest.mark.priority()`, `@pytest.mark.no_body_check` + +## 再現可能性レビューチェックリスト + +スクリプト完成後、以下を全項目確認してからテスト実行に進む: + +- [ ] **再現可能性**: 同じ環境で同じ結果が得られるか (ランダム値・タイムスタンプに依存していないか) +- [ ] **テストデータ独立性**: 外部の状態に依存せず、テスト単体で成立するか +- [ ] **marker 付与**: `@pytest.mark.page_role()` が全テスト関数に付与されているか +- [ ] **role marker**: 認証が必要なテストに `@pytest.mark.role()` + `pwk_role_` fixture があるか +- [ ] **assertion 網羅性**: 正常系 + 少なくとも 1 つの異常系 (バリデーション等) が含まれるか +- [ ] **URL 構築**: ハードコードされた URL ではなく `pwk_config.base_url` を使用しているか +- [ ] **wait 戦略**: `wait_until="domcontentloaded"` 等の明示的な待機指定があるか +- [ ] **ndf plugin 非依存**: `scenario-test/` ディレクトリ単体で実行可能か + +## ndf plugin 非依存 + +`init_project.sh` で埋め込まれた `scenario-test/` は: +- `playwright_kit/` パッケージ本体を含む +- `pyproject.toml` で pytest11 entry-point を定義 +- `run.sh` でワンコマンド実行可能 + +→ ndf plugin 未インストール環境でも `./scenario-test/run.sh` で動作する。 + +## 関連 Skill + +- `/ndf:playwright-test-planning` — テスト計画 (前段) +- `/ndf:playwright-execution` — テスト実行 + エビデンス収集 (後段) +- `/ndf:playwright-kit-ops` — init_project / codegen 等のツール群 +- `/ndf:playwright-scenario-test` — 全機能統括 diff --git a/plugins/ndf/skills/playwright-test-planning/SKILL.md b/plugins/ndf/skills/playwright-test-planning/SKILL.md new file mode 100644 index 00000000..2bb6a587 --- /dev/null +++ b/plugins/ndf/skills/playwright-test-planning/SKILL.md @@ -0,0 +1,97 @@ +--- +name: playwright-test-planning +description: "HTSM / ISTQB / FEW HICCUPPS に基づく E2E テスト計画立案。page role 分類 + role 別チェックリストでテスト項目を網羅的に洗い出す。" +when_to_use: "E2E テストの計画立案 / page role 分類 / テスト技法の選定 / チェックリスト活用が必要なとき。Triggers: 'テスト計画', 'テスト計画立案', 'page role', 'HTSM', 'ISTQB', 'FEW HICCUPPS', 'チェックリスト', 'テスト技法', 'テスト設計'" +allowed-tools: + - Read + - Bash(python *) +--- + +# E2E テスト計画 (理論ベース) + +HTSM / ISTQB / FEW HICCUPPS に基づいて E2E テストシナリオを計画する。 + +## 計画ワークフロー + +``` +[A] 対象 URL を渡される + │ +[B] page role を判定 → scripts/classify_page_role.py --url + ▼ +[C] 該当チェックリストを開く → docs/checklists/checklist-{role}.md + │ 全項目を「適用」or「不適用 (理由付き)」で判定 + ▼ +[D] 必須テスト技法を確定 → docs/03-test-techniques.md § 11 + ▼ +[E] pytest テストを書く → templates/test_.py.template を起点に + ▼ +[F] スクリプト作成へ → /ndf:playwright-script-creation + テスト計画が確定したら、テストスクリプトの作成に進む。 + テスト計画が完了するまでスクリプト作成には進まない。 +``` + +## page role 一覧 + +| role | 説明 | 例 | +|---|---|---| +| lp | ランディングページ | トップ、LP | +| list | 一覧ページ | 商品一覧、記事一覧 | +| item | 詳細ページ | 商品詳細、記事詳細 | +| edit | 編集ページ | プロフィール編集 | +| form | 申込・入力フォーム | 会員登録、問い合わせ | +| search | 検索ページ | サイト内検索 | +| dashboard | ダッシュボード | 管理画面トップ | +| auth | 認証ページ | ログイン、パスワードリセット | +| cart-checkout | カート・決済 | ショッピングカート | +| modal-wizard | モーダル・ウィザード | ステップ型入力 | + +## チェックリスト + +`playwright-test-planning/docs/checklists/` 配下に role 別チェックリストがある: + +``` +docs/checklists/ +├── checklist-common.md # 全 role 共通項目 +├── checklist-lp.md +├── checklist-list.md +├── checklist-item.md +├── checklist-edit.md +├── checklist-form.md +├── checklist-search.md +├── checklist-dashboard.md +├── checklist-auth.md +├── checklist-cart-checkout.md +└── checklist-modal-wizard.md +``` + +## 方法論ドキュメント + +`playwright-test-planning/docs/` 配下: + +| ファイル | 内容 | +|---|---| +| `01-methodology.md` | HTSM / FEW HICCUPPS / ISO 29119-3 の概要 | +| `02-page-roles.md` | page role 分類の詳細定義 | +| `03-test-techniques.md` | テスト技法 (EP/BVA/Decision Table/Pairwise) + role 必須マッピング | +| `04-playwright-mapping.md` | Playwright API → role / 観点 マッピング | +| `05-bug-report.md` | 不具合報告書の仕様 (ISO 29119-3 + FEW HICCUPPS oracle) | + +## 補助スクリプト + +スクリプトの実行は `/ndf:playwright-kit-ops` skill を参照。主なコマンド: + +```bash +# page role を自動推定 (playwright-kit-ops/scripts/ 配下) +python scripts/classify_page_role.py --url + +# Playwright codegen で操作を記録 → テストコードに変換 +python scripts/record_scenario.py +``` + +> 上記は `playwright-kit-ops/` ディレクトリ内での実行を想定。詳細は `/ndf:playwright-kit-ops` を参照。 + +## 関連 Skill + +- `/ndf:playwright-script-creation` — テストスクリプト作成 (次のフェーズ) +- `/ndf:playwright-execution` — テスト実行 + エビデンス収集 +- `/ndf:playwright-scenario-test` — 全機能を統括したフルワークフロー diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/01-methodology.md b/plugins/ndf/skills/playwright-test-planning/docs/01-methodology.md similarity index 98% rename from plugins/ndf/skills/playwright-scenario-test/docs/01-methodology.md rename to plugins/ndf/skills/playwright-test-planning/docs/01-methodology.md index 2879b9d4..9c6e0df9 100644 --- a/plugins/ndf/skills/playwright-scenario-test/docs/01-methodology.md +++ b/plugins/ndf/skills/playwright-test-planning/docs/01-methodology.md @@ -105,7 +105,7 @@ James Bach の **Heuristic Test Strategy Model** (v6.3) は、テスト戦略を │ Playwright: page.accessibility.snapshot() or page.evaluate(getRoleSummary) ▼ [2] page role を判定 → docs/02-page-roles.md の識別ヒューリスティック - │ scripts/classify_page_role.py が補助 (DOM の role 集計) + │ playwright-kit-ops/scripts/classify_page_role.py が補助 (DOM の role 集計) ▼ [3] 該当 checklist を開く → docs/checklists/checklist-{role}.md │ 全項目を「適用」または「不適用 (理由付き)」と判定 diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/02-page-roles.md b/plugins/ndf/skills/playwright-test-planning/docs/02-page-roles.md similarity index 98% rename from plugins/ndf/skills/playwright-scenario-test/docs/02-page-roles.md rename to plugins/ndf/skills/playwright-test-planning/docs/02-page-roles.md index 6f6a8039..f3ccc627 100644 --- a/plugins/ndf/skills/playwright-scenario-test/docs/02-page-roles.md +++ b/plugins/ndf/skills/playwright-test-planning/docs/02-page-roles.md @@ -166,7 +166,7 @@ ## 識別の自動化 -`scripts/classify_page_role.py` は次のヒューリスティックで role を推定する: +`playwright-kit-ops/scripts/classify_page_role.py` は次のヒューリスティックで role を推定する: ``` 入力: target_url, [既ログイン storage_state] diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/03-test-techniques.md b/plugins/ndf/skills/playwright-test-planning/docs/03-test-techniques.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/docs/03-test-techniques.md rename to plugins/ndf/skills/playwright-test-planning/docs/03-test-techniques.md diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/04-playwright-mapping.md b/plugins/ndf/skills/playwright-test-planning/docs/04-playwright-mapping.md similarity index 97% rename from plugins/ndf/skills/playwright-scenario-test/docs/04-playwright-mapping.md rename to plugins/ndf/skills/playwright-test-planning/docs/04-playwright-mapping.md index 02b2a2bc..24abddcb 100644 --- a/plugins/ndf/skills/playwright-scenario-test/docs/04-playwright-mapping.md +++ b/plugins/ndf/skills/playwright-test-planning/docs/04-playwright-mapping.md @@ -121,7 +121,7 @@ playwright codegen --save-storage=auth.json example.com playwright codegen --load-storage=auth.json example.com ``` -本 Skill では `scripts/record_scenario.py` がラッパーを提供し、codegen の Python 出力をそのまま pytest テスト関数として利用する。 +本 Skill では `playwright-kit-ops/scripts/record_scenario.py` がラッパーを提供し、codegen の Python 出力をそのまま pytest テスト関数として利用する。 **「経験で書く」を「録画→生成→pytest テスト」に置換** する。 ### Trace Viewer @@ -137,7 +137,7 @@ playwright show-trace test-results//trace.zip https://trace.playwright.dev/?trace= ``` -bug report に **trace.zip の playwright.dev リンク** を必ず付与する (`scripts/upload_evidence.py --kind trace --public`)。 +bug report に **trace.zip の playwright.dev リンク** を必ず付与する (`playwright-kit-ops/scripts/upload_evidence.py --kind trace --public`)。 ### page.pause() @@ -186,7 +186,7 @@ def measure_lcp(page): })""") ``` -`scripts/check_cwv.py` が LCP/INP/CLS を一括計測. +`playwright-kit-ops/scripts/check_cwv.py` が LCP/INP/CLS を一括計測. ### モバイル / メディア diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/05-bug-report.md b/plugins/ndf/skills/playwright-test-planning/docs/05-bug-report.md similarity index 98% rename from plugins/ndf/skills/playwright-scenario-test/docs/05-bug-report.md rename to plugins/ndf/skills/playwright-test-planning/docs/05-bug-report.md index 8567ea48..074f2b1b 100644 --- a/plugins/ndf/skills/playwright-scenario-test/docs/05-bug-report.md +++ b/plugins/ndf/skills/playwright-test-planning/docs/05-bug-report.md @@ -94,7 +94,7 @@ addopts = "--tracing retain-on-failure --video retain-on-failure --screenshot on ### trace.zip の閲覧 URL 化 -`scripts/upload_evidence.py --kind trace --public` が trace.zip を Google Drive に +`playwright-kit-ops/scripts/upload_evidence.py --kind trace --public` が trace.zip を Google Drive に アップロードし、`https://trace.playwright.dev/?trace=` 形式の閲覧 URL を 生成する (HAR / video の Drive アップロードも同スクリプトで可能、`--kind har/video`)。 bug report に必ずこの URL を貼る (zip 単体だと開発者の手元で展開が必要)。 diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/06-pytest-playwright.md b/plugins/ndf/skills/playwright-test-planning/docs/06-pytest-playwright.md similarity index 99% rename from plugins/ndf/skills/playwright-scenario-test/docs/06-pytest-playwright.md rename to plugins/ndf/skills/playwright-test-planning/docs/06-pytest-playwright.md index a76f0eeb..d9378183 100644 --- a/plugins/ndf/skills/playwright-scenario-test/docs/06-pytest-playwright.md +++ b/plugins/ndf/skills/playwright-test-planning/docs/06-pytest-playwright.md @@ -157,7 +157,7 @@ v0.5.0 から、利用者プロジェクトに `init_project.sh` で埋め込ん ```bash # 1) 初期化 (Skill ディレクトリ内で 1 度だけ) -cd .claude/plugins/ndf/skills/playwright-scenario-test +cd .claude/plugins/ndf/skills/playwright-kit-ops ./scripts/init_project.sh /path/to/your-app # → /path/to/your-app/scenario-test/ 一式が作成される # (--runtime-dir e2e で配置先名カスタマイズ可) diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/README.md b/plugins/ndf/skills/playwright-test-planning/docs/README.md similarity index 98% rename from plugins/ndf/skills/playwright-scenario-test/docs/README.md rename to plugins/ndf/skills/playwright-test-planning/docs/README.md index 1ab18dea..31b7f712 100644 --- a/plugins/ndf/skills/playwright-scenario-test/docs/README.md +++ b/plugins/ndf/skills/playwright-test-planning/docs/README.md @@ -33,7 +33,7 @@ AI/人間どちらが計画書を書く場合も、まず該当 page role のチ ``` 1. 対象 URL を見て page_role を判定 → docs/02-page-roles.md の識別ヒューリスティックを使用 - → スクリプト: scripts/classify_page_role.py + → スクリプト: playwright-kit-ops/scripts/classify_page_role.py 2. 該当 role の checklist を開く → docs/checklists/checklist-{role}.md を全項目走査 diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-auth.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-auth.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-auth.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-auth.md diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-cart-checkout.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-cart-checkout.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-cart-checkout.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-cart-checkout.md diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-common.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-common.md similarity index 96% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-common.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-common.md index c6315dac..6466da43 100644 --- a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-common.md +++ b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-common.md @@ -9,7 +9,7 @@ | # | 観点 | 技法 | oracle | 検査方法 | |---|------|------|--------|---------| -| C1.1 | axe-core 違反 0 件 | Automatic Checking | Statutes (WCAG) | `scripts/run_a11y_scan.py {url}` (axe-playwright-python). タグ `wcag2a`, `wcag2aa`, `wcag21aa`, `wcag22aa` | +| C1.1 | axe-core 違反 0 件 | Automatic Checking | Statutes (WCAG) | `playwright-kit-ops/scripts/run_a11y_scan.py {url}` (axe-playwright-python). タグ `wcag2a`, `wcag2aa`, `wcag21aa`, `wcag22aa` | | C1.2 | キーボードのみで全主要操作可能 | User Testing | Statutes (WCAG 2.1.1) | Tab で操作要素を順に踏破。手順 YAML で記録 | | C1.3 | フォーカス可視性 | User Testing | Statutes (WCAG 2.4.7, 2.4.11 New 2.2) | フォーカス時の outline / 背景色変化を確認 | | C1.4 | 見出し階層 (h1 単一 / h2 → h3 順) | Automatic | Statutes (WCAG 1.3.1) | `page.locator("h1").count() == 1` + axe `heading-order` | @@ -26,8 +26,8 @@ LCP / INP / CLS は **field metric** だが、本 Skill では Lab 計測で代 | # | 観点 | 技法 | oracle | 検査方法 / 閾値 | |---|------|------|--------|----------------| -| C2.1 | LCP ≤ 2.5s | Claims | Claims (web.dev) | `scripts/check_cwv.py --metric lcp` | -| C2.2 | CLS ≤ 0.1 | Automatic | Claims | `scripts/check_cwv.py --metric cls` | +| C2.1 | LCP ≤ 2.5s | Claims | Claims (web.dev) | `playwright-kit-ops/scripts/check_cwv.py --metric lcp` | +| C2.2 | CLS ≤ 0.1 | Automatic | Claims | `playwright-kit-ops/scripts/check_cwv.py --metric cls` | | C2.3 | INP ≤ 200ms | User Testing | Claims | INP は field 主体。Lab で `pointer-down → next paint` を計測 | | C2.4 | TTFB (server response) ≤ 800ms | Automatic | Performance | `page.expect_response` の経過時間 | diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-dashboard.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-dashboard.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-dashboard.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-dashboard.md diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-edit.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-edit.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-edit.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-edit.md diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-form.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-form.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-form.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-form.md diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-item.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-item.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-item.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-item.md diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-list.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-list.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-list.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-list.md diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-lp.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-lp.md similarity index 96% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-lp.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-lp.md index 44f7d046..030507e7 100644 --- a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-lp.md +++ b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-lp.md @@ -8,7 +8,7 @@ ## 必須テスト観点 ### LP1: ヒーロー領域レンダリング `[Claims / Claims]` -- LCP < 2.5s (`scripts/check_cwv.py --metric lcp`) +- LCP < 2.5s (`playwright-kit-ops/scripts/check_cwv.py --metric lcp`) - ヒーロー画像/動画の poster が空白でない - WebP / AVIF fallback が動作 @@ -59,7 +59,7 @@ ### LP10: スクロール時の CLS `[Claims / Image]` - 画像 / iframe / web font の遅延差し替えで layout shift しない (`width/height` 属性 + aspect-ratio CSS) -- CLS < 0.1 (`scripts/check_cwv.py --metric cls`) +- CLS < 0.1 (`playwright-kit-ops/scripts/check_cwv.py --metric cls`) ### LP11: 内部 anchor link `[Functional / Product]` - `#section1` の click で smooth scroll diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-modal-wizard.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-modal-wizard.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-modal-wizard.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-modal-wizard.md diff --git a/plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-search.md b/plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-search.md similarity index 100% rename from plugins/ndf/skills/playwright-scenario-test/docs/checklists/checklist-search.md rename to plugins/ndf/skills/playwright-test-planning/docs/checklists/checklist-search.md