Skip to content

refactor: 2 モード e2e の重複 spec を整理 + 振り分け基準を ADR-0009 に集約 (#207)#231

Merged
ymnao merged 1 commit into
mainfrom
refactor/dedupe-e2e-specs
Jun 25, 2026
Merged

refactor: 2 モード e2e の重複 spec を整理 + 振り分け基準を ADR-0009 に集約 (#207)#231
ymnao merged 1 commit into
mainfrom
refactor/dedupe-e2e-specs

Conversation

@ymnao

@ymnao ymnao commented Jun 25, 2026

Copy link
Copy Markdown
Owner

概要

#207 の解消。

scripta の e2e は 2 モード並行運用 (renderer-only + 実 Electron) で運用しているが、e2e/settings-persistence.spec.ts の test 1, 2 (sidebarVisible 復元) が in-memory mock では実証性なし → renderer-only から削除し、実 Electron 側 (e2e/electron/settings-persistence.electron.spec.ts) に safety net を集約。同時に「どちらに spec を書くか」の振り分け基準を canonical 化する。

ADR-0009 は既に「各モードの役割分担(テスト分類方針)」§ で領域別の spec 対応表 + 「mock で踏めるか」の判断原則を持つので、CLAUDE.md からはこれへの 1 行 pointer + 同 ADR の spec table 拡張 (pdf-pagebreak / structured-error 追加) で対応。parity-checklist の領域列挙も同 ADR pointer に集約 (3-place sync を解消)。

関連 Issue

closes #207

移行 Stage

  • Stage 6: 仕上げ・配布・切り替え (post-Tauri-purge の v0.6.0 refactor 系)

変更内容

  • e2e/settings-persistence.spec.tse2e/workspace-restoration.spec.ts (git mv):
    • sidebarVisible round-trip test 2 件削除 (in-memory mock 実証性なし。実 Electron 側 e2e/electron/settings-persistence.electron.spec.ts:20-23, 36 で完全 mirror 済)
    • 残った 2 件は negative cases (?newWindow=true の workspace 復元 skip + 無効パス fallback)
    • describe を "workspace restoration: skip / fallback branches (mocked settings)" に変更し、scope を name で明示
  • CLAUDE.md L209: 「テスト」セクションに ADR-0009 §「各モードの役割分担(テスト分類方針)」への 1 行 pointer を追加 (振り分け基準は ADR が canonical)
  • docs/adr/0009-renderer-only-e2e-strategy.md §「各モードの役割分担」 table: Phase 4 で追加された pdf-pagebreak.electron.spec.ts / structured-error.electron.spec.ts を追加 (9→11 spec)
  • docs/parity-checklist.md:
    • L261: settings-persistence → workspace-restoration の rename を注記
    • L266: 11 項目の領域 inline list を ADR-0009 への canonical pointer に圧縮 (3-place sync を解消)

設計判断: issue 提案からの逸脱

issue #207 は以下を提案していた:

  1. CLAUDE.md に振り分け基準を直接追記
  2. electron/preload/api.ts 冒頭に「IPC contract 変更時は mock も同期」audit comment を追加
  3. smoke.spec.ts の scope 絞り込み (renderer-only 側を最小に)

本 PR は以下の通り逸脱:

1. CLAUDE.md には振り分け基準を直接書かず、ADR-0009 への 1 行 pointer に集約

ADR-0009 §「各モードの役割分担(テスト分類方針)」が既に領域別 spec 対応表 + 「mock で踏めるか」の判断原則を持っているため。直接書くと CLAUDE.md / ADR / parity-checklist の 3-place sync を生む (本 PR の parity-checklist L266 pointer 化 も同じ問題への対応)。

2. audit comment は追加しない (TypeScript 型 conform で代替)

e2e/helpers/electron-api-mock.ts:458 が既に const api: Api = { ... } で型 conform を強制し、pnpm typecheck:e2e が CI 必須 gate として動作している (mock.ts L455-457 にも既存 inline comment Api 型に固定することで preload 契約と乖離した瞬間に typecheck が落ちる あり)。

コメントを追加すると mechanism の triple-write (CLAUDE.md + api.ts + mock.ts) になり drift hazard を生む。TypeScript 型に任せる方が deep fix。

3. smoke.spec.ts は変更なし (削除も scope 絞り込みもしない)

renderer-only smoke と 実 Electron smoke は layer が異なる:

  • renderer-only smoke: mock IPC 越しの UI ロジック (Open Folder ボタンが描画される / openDirectoryPicker が呼ばれる)
  • 実 Electron smoke: build 成果物 + 実 preload + contextBridge pipeline の健全性 (8 領域 safety net の土台)

layer が異なる以上、片方を絞り込むのではなく両方を独立 spec として維持。

動作確認

UI / runtime 動作は変更なし (docs + comment 修正 + test 2 件削除 + describe rename のみ)。

  • node_modules/.bin/biome check --write: pass (4 ts files)
  • node_modules/.bin/tsc --noEmit -p tsconfig.web.json / tsconfig.node.json / tsconfig.e2e.json: pass (typecheck:e2e の pass が mock の Api 型 conform 維持を実証)
  • node_modules/.bin/vitest --run: 2212 passed (96 files) / 2 skipped
  • node_modules/.bin/electron-vite build: pass (449ms)
  • pnpm test:e2e (renderer-only): sandbox EPERM のためローカル不可、CI 待ち
  • pnpm test:e2e:electron (実 Electron): ローカル不可、CI 待ち

/simplify + /code-review の経緯

Phase 内容 diff size
初版 audit comment + 振り分け基準 sub-section + scope comment を追加 5 files / 39 ins / 39 del
/simplify 4 軸 review → 「TypeScript で既に enforce」を発見、IPC comment 大幅圧縮 + CLAUDE.md → ADR pointer 化 15 ins / 39 del (insertion -61%)
/code-review 1 周 (max effort) 10 angles + verify + sweep → 15 findings: parity-checklist:261 stale 修正、コメント追加の factual error (「下記 const api」が 445 行下) + self-redundancy 発見 → 4 ファイル comment 完全削除 + ADR-0009 spec table 拡張 + describe 名変更 6 ins / 41 del (net -35 行)
/code-review 2 周 10 findings、2 agent 収束は parity-checklist L266 の 11 項目 inline list が ADR-0009 table と duplicate → L266 を canonical pointer に圧縮 6 ins / 41 del (内容のみ改善)

skip した別 issue 候補 (本 PR scope 外、別 issue 起票検討)

  • mock return-shape divergence (e2e/helpers/electron-api-mock.ts:458): const api: Api = { ... } は signature conform を gate するが return-value shape (例: gitStatus.branch === '' vs undefined) は enforce しない。shared default payload (real IPC handler と mock で同じ default constant を import) 化が deep fix。Altitude。
  • ADR link existence の CI gate (markdown-link-check / lychee 等): ADR rename / supersede 時に silent 404 防止。
  • ADR-0009 「1 spec = 1 領域」原則違反: 本 PR で追加した PDF 改ページ (pdf-pagebreak.electron.spec.ts) は PDF エクスポート (pdf-export.electron.spec.ts) と同じ pdf:export IPC main 境界に対する 2 spec。ADR 自体の改訂検討。
  • ADR-0009 CI worker 数の再評価: 「worker を CI で 2 に絞り」 (L56) が元々 8 spec 想定だったが、現在 11 spec。
  • docs/parity-checklist.md:261 「23 spec」base が stale: 実際は 29 spec。renderer-only spec 追加の都度 cell 注記が伸びる構造的問題。本 PR でも 1 件 append したので、別途 cell rewrite 検討。

- e2e/settings-persistence.spec.ts → workspace-restoration.spec.ts (git mv):
  sidebarVisible round-trip test 2 件削除 (in-memory mock 実証性なし、
  実 Electron 側で完全 mirror 済)、残り 2 件は negative cases、
  describe を scope 明示型 ("workspace restoration: skip / fallback
  branches (mocked settings)") に変更
- CLAUDE.md: 振り分け基準を直接書かず、ADR-0009 §「各モードの役割分担
  (テスト分類方針)」への 1 行 pointer を追加
- ADR-0009 spec table: Phase 4 で追加された pdf-pagebreak /
  structured-error を追加 (9→11 spec)
- docs/parity-checklist.md: rename note を L261 に注記、L266 の領域
  inline list (11 項目) を ADR-0009 への canonical pointer に圧縮

audit comment (issue 提案) は TypeScript 型 conform
(`const api: Api = { ... }` + `pnpm typecheck:e2e`) で既に enforce
されているため追加しない。詳細は PR 本文「設計判断」セクション参照。

closes #207

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ymnao ymnao merged commit 6d39441 into main Jun 25, 2026
10 checks passed
@ymnao ymnao deleted the refactor/dedupe-e2e-specs branch June 25, 2026 02:02
@ymnao ymnao mentioned this pull request Jun 26, 2026
4 tasks
ymnao added a commit that referenced this pull request Jun 26, 2026
- `CHANGELOG.md` に v0.6.0 セクションを追加
  - Internal: #206#229 (AppLayout useShallow), #208#230 (settings
    _schemaVersion + MIGRATIONS), #207#231 (2 モード e2e 振り分け +
    ADR-0009 集約), #225#232 (onNavigate wikilink target),
    #226#233 (useCollapseToggle hook), #228#234 (createScanAction
    factory), #227#235 (producer-side lineContent trim)
- `package.json` の `version` を `0.5.0` → `0.6.0`
- HANDOFF の規約通り、本 commit では `pnpm <script>` を呼ばない
  (lockfile / node_modules には触れない)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: 2 モード e2e の重複 spec を整理 + 振り分け基準を明文化

1 participant