GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore: 旧 scripta からユニットテスト 60 ファイルを復元(PR B) by ymnao · Pull Request #5 · ymnao/scripta

Conversation

@ymnao

@ymnao ymnao commented May 1, 2026

Copy link
Copy Markdown
Owner

概要

Stage 0b の続きとして、旧 scripta(Tauri 版・参照専用)から 60 ファイルのユニットテスト を scripta-next に復元する。Stage 1(fs 本物実装)に着手する前にテスト基盤を整え、安全性クリティカルな fs 実装をテスト無しで進めない方針。

関連 Issue

なし(HANDOFF.md の PR B スコープ)

移行 Stage

  • Stage 0: 雛形 + フロント表示確認(PR B = テスト復元)
  • Stage 1: ファイル I/O
  • Stage 2: ワークスペース・ファイルツリー・ファイル監視
  • Stage 3: 全文検索(ripgrep sidecar)
  • Stage 4: Git Sync
  • Stage 5: OGP / PDF / アップデート
  • Stage 6: 仕上げ・配布・切り替え

変更内容

1. テスト基盤の構築

  • devDeps 追加: `jsdom`, `@testing-library/{react,jest-dom,user-event}`
  • `vitest.config.ts` を新設(jsdom 環境 + setupFiles + e2e/out 除外)
  • `src/test-setup.ts` を新設(CodeMirror Range polyfill + matchMedia stub + window.api デフォルトモック注入 + afterEach で fake timers リセット)
  • `src/test-utils/api-mock.ts` を新設(46 メソッド分の `createApiMock()` ヘルパー、`Api` 型で網羅性を強制)
  • `src/components/editor/live-preview/test-helper.ts` を旧 scripta から流用(`createTestState` で構文木を完全構築 + `state.update({})` で field.tree を context.tree と同期)
  • `scripts.test` から `--passWithNoTests` を削除、`test:watch` を追加

2. テスト復元(60 ファイル)

分類 件数 方式
Tauri 非依存 51 旧 scripta から drop-in コピー
Tauri 依存 9 `window.api` または `commands.ts` mock パターンに書き換え

3. 主要な書き換えポイント

  • `commands.test.ts` / `store.test.ts`: `vi.mock("@tauri-apps/api/core")` / `vi.mock("@tauri-apps/plugin-store")` を撤去し、test-setup.ts が注入する `window.api` を `(window.api. as Mock).mockResolvedValue(...)` で個別上書き
  • `export.test.ts`: `@tauri-apps/plugin-dialog` mock を撤去し、`showSaveDialog` を `vi.mock("./commands")` に統合
  • hooks 系: `vi.mock("@tauri-apps/api/event")` を撤去し、`commands.ts` 経由のイベント subscribe(`onFsChange` / `onConflictResolved`)を mock
  • `useUpdateCheck.test.ts`: `@tauri-apps/api/app` の `getVersion` を `commands.ts` の `getAppVersion` に切替
  • `ConflictWindow.test.tsx`: `@tauri-apps/api/event/window` を撤去し、`commands.ts` の `emitConflictResolved` / `closeWindow` に切替
  • `AppLayout.test.tsx`: 5 つの Tauri 直接モック(`api/app`, `plugin-dialog`, `webviewWindow`, `api/event`, `api/window`)をすべて撤去し、`commands.ts` mock に集約。`closeHandler` の挙動を旧「`mockDestroy` 呼ばれた」検証 → 新「`closeHandler()` が throw した/しない」検証に書き換え(preload で payload を剥がす実装に合わせて `emitFsChange` ヘルパーも調整)

4. シャッフル順テストの安定化

複数シードで実行した際にフレークするテスト群を順次解消:

  • AppLayout: `useToastStore` クリア漏れ + `mockedReadFile/WriteFile/FileExists` の `mockResolvedValueOnce` キュー残留 → beforeEach で `mockReset` 経由設定
  • StatusBar: `Object.assign(navigator, { clipboard })` が read-only な navigator では TypeError → `Object.defineProperty` に変更
  • useGitSync: `mockedGit*` mocks の Once キュー残留 → `mockReset` 経由設定 + queue.enqueue の async chain 完了を timer 経由で待つ
  • MermaidEditorDialog: mock に `isTauriProtocol` / `promoteMermaidStyles` / 戻り値が Promise になる `renderMermaid` を追加
  • live-preview decoration 系: `createTestState` で `ensureSyntaxTree(.., Infinity)` + `state.update({})` により field.tree を context.tree と同期(Lazy parse の部分木が syntaxTree(state) で返る問題を解消)
  • EmojiInputDialog: `userEvent.setup({ delay: null })` で internal setTimeout 無効化 + `requestAnimationFrame` を vi.spyOn で局所同期化(CodeMirror の measure を壊さないようグローバル上書きはしない)+ ファイル局所で `vi.setConfig({ testTimeout: 15_000 })`
  • MarkdownEditor: `useSettingsStore` mock を関数形式 + `getState`/`setState`/`subscribe` で完全化

5. 既知の skip 対応

  • `math.test.ts`: CodeMirror 6.41.1 + math.ts hybrid 化で viewport 制限が撤去 されたため、viewport 制限を前提とした 2 ケースを `it.skip` 化(コメントで TODO 明示、新仕様カバレッジは後続 PR)

動作確認

ローカルで以下すべて pass:

  • `pnpm format`
  • `pnpm lint`
  • `pnpm typecheck`
  • `pnpm test` → 60 files / 1179 passed + 2 skipped
  • `pnpm vitest run --sequence.shuffle` を seed 1/2/3/4/5/7/17/42/99/200/500/999/1234/9999 で全 pass(フレークなし)
  • `pnpm build`

スクリーンショット

なし(テスト追加のみ)

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ymnao and others added 16 commits April 30, 2026 23:14
@ymnao @claude
chore: vitest 周辺の devDeps 追加と設定ファイル新設
0e46edf
- jsdom / @testing-library/{react,jest-dom,user-event} を devDeps に追加
- vitest.config.ts を新設(jsdom 環境 + setupFiles + e2e/out 除外)
- src/test-setup.ts を新設(CodeMirror Range polyfill + matchMedia stub + window.api デフォルトモック注入)
- src/__test-utils__/api-mock.ts を新設(46 メソッド分の window.api モック生成ヘルパー)
- src/components/editor/live-preview/test-helper.ts を旧 scripta から流用
- package.json の scripts に test:watch を追加

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
test: Tauri 非依存テストを旧 scripta から流用(51 ファイル)
6a34822
- decoration 18 / common 4 / editor 4 / filetree 1 / layout 1 / slide 2 /
  hooks 2 / lib 12 / stores 7 = 51 ファイルを旧 scripta から drop-in コピー
- math.test.ts のみ scripta-next 側の hybrid 化(StateField + ViewPlugin)に
  追従して `buildDecorations(view)` → `buildMathDecorations(view.state, view.hasFocus)`
  に書き換え。viewport 制限を前提とした 2 ケースは新仕様で意図が成立しないため
  it.skip + コメントで TODO 化(新仕様カバレッジは後続 PR で追加予定)
- package.json scripts.test から --passWithNoTests を削除(テスト 0 件で fail させる)

`pnpm test` 結果: 51 files / 957 passed + 2 skipped

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
test: lib のコマンド/ストア/エクスポートテストを window.api パターンに書き換え
91d9500
- commands.test.ts: vi.mock("@tauri-apps/api/core") を撤去し、test-setup.ts が注入する
  window.api 経由で各関数の retry 挙動をテスト。新 commands.ts では
  scanUnresolvedWikilinks も withRetry 配下なので 2 ケース追加(旧 7 関数 → 新 8 関数)
- store.test.ts: vi.mock("@tauri-apps/plugin-store") + mockStore を撤去し、
  window.api.settingsGet/Set/Delete/Save に張り替え。migration テスト
  (legacy theme → themePreference)も新 API で同等の assertion を維持
- export.test.ts: vi.mock("@tauri-apps/plugin-dialog") を撤去し、
  showSaveDialog を vi.mock("./commands") の mock object に統合。本文 30+ ケースは
  mockedSave 変数名そのままで無変更

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
test: hook / conflict / images テストを commands.ts mock パターンに書き換え
4df05ef
- useFileWatcher.test.ts: vi.mock("@tauri-apps/api/event") 撤去、commands.ts の
  onFsChange を mock し callback を保持。emit ヘルパーは payload を剥がした直接渡しへ
- useGitSync.test.ts: vi.mock("@tauri-apps/api/event") 撤去、commands mock に
  onConflictResolved を追加(useGitSync 本体が commands.ts 経由になっているため)
- useUpdateCheck.test.ts: vi.mock("@tauri-apps/api/app") 撤去、commands mock に
  getAppVersion を追加。本文の mockedGetVersion 変数名は流用
- ConflictWindow.test.tsx: vi.mock("@tauri-apps/api/event"/"window") 撤去、commands mock に
  emitConflictResolved/closeWindow を追加。emit の引数文字列確認は無引数 API のため
  toHaveBeenCalled() に簡素化
- images.test.ts: convertFileSrc を @tauri-apps/api/core から ../../../lib/commands に切替

`pnpm test` 結果: 59 files / 1139 passed + 2 skipped

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
test: AppLayout のテストを書き換え(Tauri モック → commands.ts mock に集約)
d8cd893
新 AppLayout は Tauri 直接依存をすべて捨てているため、書き換え後のモックは
5 モジュールに縮減(commands / store / useGitSync / Sidebar / MarkdownEditor)。

- 削除: vi.mock("@tauri-apps/api/app"/"plugin-dialog"/"webviewWindow"/"event"/"window")
- 追加: commands mock に getAppVersion/openDirectoryPicker/openConflictWindow/closeWindow/
  onFsChange/onMenuEvent/onWindowCloseRequested を集約
- closeHandler の挙動検証を新セマンティクスに変更:
  旧: closeHandler({ preventDefault }) + expect(preventDefault).toHaveBeenCalled() +
      expect(mockDestroy).toHaveBeenCalled()/.not.toHaveBeenCalled()
  新: throw しなければ ack=true → main destroy / throw すれば ack=false → close 中断
      → try/catch で closeHandlerThrew を捕捉し、toBe(false)/toBe(true) で検証
- conflict resolver window のオープン検証は MockWebviewWindowConstructor から
  openConflictWindow as Mock に置換
- emitFsChange ヘルパーを `cb({ payload: events })` → `cb(events)` に変更

`pnpm test` 結果: 60 files / 1179 passed + 2 skipped

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: shuffle 順でフレークするテスト 3 件を修正
5476754
シャッフル実行(pnpm vitest run --sequence.shuffle --sequence.seed=2 など)で
再現する 3 件のフレークを解消。

- AppLayout: 前テストが残した toast / mock 履歴をリーク防止のため
  beforeEach 冒頭で useToastStore を空に + mockedReadFile/WriteFile/FileExists を
  mockReset 経由で設定(Once キューも含めて完全 clear)
- StatusBar: navigator.clipboard を Object.assign で代入していたが、
  read-only な navigator では TypeError になる環境がある。
  Object.defineProperty(..., { configurable: true, value: ... }) に変更
- useGitSync: mockedGit* mocks を mockReset 経由で設定し、前テストの
  mockResolvedValueOnce キュー残留を排除。doPull failure の async chain
  完了を確実に待つため advanceTimersByTimeAsync(0) → (100) に拡張
  (100ms ≪ autoCommit/Pull/Push のデフォルト 10 分なので interval は無発火)

検証: --sequence.seed=1/2/7/17/42/99/200 で全 60 files / 1179 passed + 2 skipped

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: live-preview テストの構文木未構築によるシャッフルフレークを解消
b7d9983
decoration テスト群は createTestState で得た state に対し syntaxTree(state) を
直接呼ぶ。CodeMirror は lazy parse で、shuffle 順では state 作成時点の構文木が
スタブ/部分木のまま残り mermaid/horizontal-rules/headings/strikethrough/
code-block-copy 等で件数不足になる事象が報告された。

createMockView 側ではすでに ensureSyntaxTree(state, state.doc.length, 5000) を
呼んでいたが、createTestState を直接使うテスト(mermaid.test.ts:34 等)には
保証がなかった。createTestState 内で同じ ensureSyntaxTree を呼ぶことで全
テストパスで構文木を確実に構築する(既に呼んでいる箇所は cache が効くので
追加コストは無視できる)。

検証: pnpm vitest run --sequence.shuffle --sequence.seed=1/2/3/7/17/42/99/200/500
で全 60 files / 1179 passed + 2 skipped(フレークなし)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: createTestState の構文木構築を完了するまで poll する
276b227
ensureSyntaxTree(state, length, 5000) は ms ベースの timeout で、shuffle
並列実行で CPU 競合が起きると 5 秒以内に parse が完了せず部分的なスタブを
返す事象が報告された(tables.test.ts:43 で Table ノード未検出、
lists.test.ts:155 で list widget 0 件など)。

`syntaxTreeAvailable` で完了確認しつつループする方式に変更。markdown の
小さな doc なら数ループで完了する。最大 50 回で打ち切り(無限ループ防止)。

検証: pnpm vitest run --sequence.shuffle --sequence.seed=1/2/3/7/17/42/99/200/500/999
で全 60 files / 1179 passed + 2 skipped(フレークなし)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: shuffle 順で残っていたフレーク 3 件を解消
d8ed98c
- test-setup.ts: afterEach で vi.useRealTimers() を必ず呼び、fake timers が
  次テストに漏れて userEvent などが hung する事象を防ぐ
  (EmojiInputDialog の検索クリアテストが 5000ms timeout する症状を解消)
- MermaidEditorDialog.test.tsx: mockRenderMermaid のデフォルトを Promise を
  返す形に揃える。setTimeout(..., 300) で発火する renderMermaid の戻り値が
  undefined だと .then で TypeError になる事象を防ぐ
- test-helper.ts (createTestState): syntaxTreeAvailable 完了確認の poll に
  60 秒 timeout × 100 回ループへ拡張。CPU 競合下でも構文木が確実に完成する
  (buildDecorations(view) が空を返す lists/headings flake を解消)

検証: pnpm vitest run --sequence.shuffle --sequence.seed=1/2/3/7/17/42/99/200/500/999
で全 60 files / 1179 passed + 2 skipped(フレークなし)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: MermaidEditorDialog の mock 漏れと構文木 timeout を解消
236761e
1. MermaidEditorDialog.test.tsx
   コンポーネントは ../../lib/mermaid から { isTauriProtocol, promoteMermaidStyles,
   renderMermaid } の 3 つを import するが、mock が renderMermaid のみで
   isTauriProtocol と promoteMermaidStyles が undefined になっていた。
   shuffle 順では未処理例外として顕在化し巻き添えで onCancel assertion も落ちていた。
   3 つすべて mock に追加。

2. test-helper.ts (createTestState)
   `ensureSyntaxTree(state, upto, timeout)` の timeout は ms ベースで CPU 競合下で
   parse work loop が time-budget を使い切って部分木のまま return null するケースが
   残っていた(lists / mermaid / headings の buildDecorations 空配列)。
   timeout = Number.POSITIVE_INFINITY で work loop が time-out で抜けないようにし、
   markdown parser の有限 work で必ず完了するようにした。loop 上限は 10 回(保険)。

注: test-setup.ts の afterEach(() => vi.useRealTimers()) はフレーク解消に必要だが、
fake timers を使う今後のテストとの相互作用に注意(今回直接の問題はなし)。

検証: pnpm vitest run --sequence.shuffle --sequence.seed=1/2/3/7/17/42/99/200/500/999
で全 60 files / 1179 passed + 2 skipped(フレークなし)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: createTestState で field.tree を context.tree と同期する
1b745e2
これまでの修正で `ensureSyntaxTree(state, length, Infinity)` で parse は完了
していたが、`syntaxTree(state)` が返す `field.tree` は LanguageState 構築時の
スナップショットで、parse context の tree とは別物だった。`parse.work()` で
context.tree が前進しても field.tree は古いまま → buildDecorations 内の
`syntaxTree(state)` が部分木を返し、各種装飾が空配列になっていた。

CodeMirror の `forceParsing(view, ...)` は `view.dispatch({})` で no-op
transaction を発火し、LanguageState.apply (`this.tree != this.context.tree`
のとき new LanguageState を作って context.tree を field.tree に取り直す)
経由で同期している。テスト側でも view が無いため state.update({}).state で
同等の同期を行う。

ついでに createMockView 内の冗長な ensureSyntaxTree 呼び出しを削除(state は
createTestState で完全 parse 済みなので不要)。

検証: pnpm vitest run --sequence.shuffle で seed
1/2/3/7/17/42/99/200/500/999/1000/1234/9999 の 13 シードすべて
60 files / 1179 passed + 2 skipped(フレークなし)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: EmojiInputDialog テストの userEvent を delay:null setup に切替
c95cf1d
userEvent v14 のデフォルト動作はキー入力ごとに internal な setTimeout で
delay を入れる。shuffle 並列実行で CPU 競合が起きると userEvent.type/clear が
5000ms timeout する事象が seed=1 で報告されていた(「検索をクリアすると
カテゴリ表示に戻る」テスト)。

userEvent.setup({ delay: null }) で internal setTimeout を無効化し、各キー
入力を同期処理にする。renderDialog から user instance を返し、各テストで
await user.type/click/clear を使う形へ書き換え。

検証: pnpm vitest run --sequence.shuffle で seed
1/2/3/7/17/42/99/200/500/999/1234/9999 の 12 シードすべて
60 files / 1179 passed + 2 skipped(フレークなし)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: requestAnimationFrame の同期化と useSettingsStore mock を完全化
f0d0fd2
1. test-setup.ts: requestAnimationFrame を同期実行に置換
   jsdom の rAF は setTimeout(cb, ~16ms) で polyfill されるが、CPU 競合下で
   callback が遅延し、rAF を介した state 更新を待つ waitFor が timeout する。
   EmojiInputDialog では useEffect 内で `requestAnimationFrame(() =>
   setAllCategoriesReady(true))` していて、rAF 遅延でグリッド表示テスト
   (L57「全カテゴリの絵文字が一覧に表示される」など)が単体実行でも
   timeout する事象が報告されていた。同期実行で確実に flush する。

2. MarkdownEditor.test.tsx: useSettingsStore mock に getState/subscribe を追加
   既存 mock は selector 関数形式のみで `useSettingsStore.getState()` /
   `subscribe()` が undefined だった。live-preview/mermaid.ts:281 が直接
   `useSettingsStore.getState()` を呼ぶため、shuffle 順で実行されると
   `useSettingsStore.getState is not a function` でクラッシュしていた。
   zustand store が公開する getState/setState/subscribe を Object.assign で
   付与し、両方の使い方をカバーする。

検証: pnpm vitest run --sequence.shuffle で seed
1/2/3/5/7/17/42/99/200/500/999/1234/9999 の 13 シードすべて
60 files / 1179 passed + 2 skipped(フレークなし)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: requestAnimationFrame の同期化を EmojiInputDialog に局所化
b45750e
前 commit (f0d0fd2) で test-setup.ts に追加した global rAF 同期化が
CodeMirror の EditorView.requestMeasure() の前提(非同期フレーム境界)を
壊し、delayedAndroidKey 周りで MarkdownEditor / SlideView がクラッシュ
していた。global 上書きを撤回し、EmojiInputDialog テスト内で vi.spyOn を
使って局所化する(CodeMirror を使わないテストでのみ rAF が同期になる)。

検証: pnpm vitest run --sequence.shuffle で seed
1/2/3/4/5/7/17/42/99/200/500/999/1234/9999 の 14 シードすべて
60 files / 1179 passed + 2 skipped(フレークなし)
個別: EmojiInputDialog / MarkdownEditor / SlideView 各単体実行も pass

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
chore: testTimeout を 15s に拡大(emoji 全件 render の環境差吸収)
ed5be57
EmojiInputDialog は emoji-data.ts (2914 行) の全絵文字を jsdom で render
するため、CPU 競合や環境差で default 5000ms timeout に間に合わないテストが
ある(カテゴリ表示・検索・ハイライト等で waitFor がタイムアウトする事象が
ユーザー環境で報告されていた)。

userEvent delay や rAF 同期化などの構造的修正は前 commit までに入れ済みで、
残るのは「ユーザー環境では計算リソース不足で 5s に収まらないだけ」のため、
testTimeout を 15s に拡大して余裕を確保する。通常は 1〜3s で完了するため
正常系のテスト時間には影響しない(hang する bug があれば 15s で fail する)。

検証: pnpm vitest run(単体) + pnpm vitest run --sequence.shuffle で seed
1/2/3 の 60 files / 1179 passed + 2 skipped、format/lint/typecheck 全 pass

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
chore: testTimeout 拡大を EmojiInputDialog テストファイルに局所化
4e7c195
前 commit (ed5be57) で vitest.config.ts に入れた global testTimeout: 15_000 は
全テストの猶予を一律で広げる副作用があり、別の場所のハング検出感度を下げる。
原因が emoji-data の全件 render のみに限定されているため、
src/components/common/EmojiInputDialog.test.tsx 内で `vi.setConfig({
testTimeout: 15_000 })` で局所化する。これにより他のテストは default 5s の
hang 検出を維持する。

検証: EmojiInputDialog 単体 / MarkdownEditor 単体 / 全体 shuffle seed=1 で
全 60 files / 1179 passed + 2 skipped、format/lint/typecheck 全 pass

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 1, 2026 17:24
Copilot started reviewing on behalf of ymnao May 1, 2026 17:24
View session
Copilot AI reviewed May 1, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

旧 scripta(Tauri 版)由来のユニットテスト群を scripta-next に復元し、Stage 1(fs 本物実装)に入る前に Vitest + jsdom 前提のテスト基盤(window.api モック注入など)を整備する PR です。

Changes:

  • Vitest 実行環境(jsdom / setupFiles / 除外設定)と共通テストセットアップ(window.api デフォルトモック、polyfill/stub、timer リセット)を追加
  • window.api を型で網羅する createApiMock() を追加し、Tauri 直接モック依存を低減
  • stores / lib / hooks / components のユニットテストを多数復元(旧実装からの drop-in + 必要箇所の mock 移植)

Reviewed changes

Copilot reviewed 65 out of 66 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vitest.config.ts Vitest の jsdom 設定・setupFiles・対象/除外パターンを追加
src/test-setup.ts Testing Library 初期化、window.api デフォルト注入、Range/matchMedia スタブ、timer 漏れ防止
src/test-utils/api-mock.ts Api 型で網羅された window.api のデフォルトモック生成/注入
package.json テスト関連 devDeps 追加、test スクリプト更新、test:watch 追加
src/stores/wikilink.test.ts wikilink store の scan / draft / reset / in-flight 破棄のテスト
src/stores/toast.test.ts toast store の add/remove のテスト
src/stores/theme.test.ts theme store の preference / cycle のテスト
src/stores/settings.test.ts settings store の setter / hydrate(永続化抑止)のテスト
src/stores/scratchpad.test.ts scratchpad store の open/toggle のテスト
src/stores/git-sync.test.ts git sync store の setter 永続化と runtime state のテスト
src/lib/store.test.ts settings load/save・migration・バリデーションのテスト
src/lib/slide-parser.test.ts slide 区切りパースとカーソル位置判定のテスト
src/lib/scripta-config.test.ts .scripta 配下の各種パス/テンプレ/入出力のテスト
src/lib/path.test.ts パス操作ユーティリティ(Windows/Unix)のテスト
src/lib/mermaid.test.ts Mermaid レンダリングとキャッシュのテスト
src/lib/mermaid-sanitize.test.ts Mermaid SVG サニタイズ(foreignObject/style/属性除去)のテスト
src/lib/mermaid-promote.test.ts Mermaid CSS の promote/保持挙動のテスト
src/lib/ime.test.ts IME composing 判定ユーティリティのテスト
src/lib/file-icon.test.ts 拡張子→アイコン選択のテスト
src/lib/errors.test.ts エラーメッセージ翻訳・transient/network 判定のテスト
src/lib/east-asian-width.test.ts 文字幅計算のテスト
src/lib/commands.test.ts window.api 経由コマンドの retry ロジックのテスト
src/lib/code-fence.test.ts コードフェンス追跡ユーティリティのテスト
src/hooks/useUpdateCheck.test.ts 更新チェック hook(スキップ条件/キャンセル/ダイアログ制御)のテスト
src/hooks/useScratchpadVolatile.test.ts scratchpad アーカイブ/クリア条件のテスト
src/hooks/useFileWatcher.test.ts fs change バッチング/重複排除/unmount 安全性のテスト
src/components/slide/SlideView.test.tsx SlideView のレンダリングと callback 発火のテスト
src/components/slide/SlidePreview.test.tsx SlidePreview の表示・区切り行扱いのテスト
src/components/layout/StatusBar.test.tsx StatusBar の表示・clipboard・git 操作のテスト
src/components/editor/live-preview/wikilink-completion.test.ts wikilink 補完(キャッシュ/フィルタ/パス処理)のテスト
src/components/editor/live-preview/test-helper.ts CodeMirror 状態生成・decoration 収集ヘルパー
src/components/editor/live-preview/tables.test.ts テーブル keymap/構文木検出/テンプレ生成のテスト
src/components/editor/live-preview/table-utils.test.ts テーブル解析・移動・整形のテスト
src/components/editor/live-preview/table-decoration.test.ts テーブル装飾ウィジェットの生成/eq/ignoreEvent のテスト
src/components/editor/live-preview/strikethrough.test.ts 取り消し線装飾のテスト
src/components/editor/live-preview/mermaid.test.ts Mermaid ブロック検出と装飾ウィジェットのテスト
src/components/editor/live-preview/links.test.ts URL 安全性/リンク生成/Widget ignoreEvent のテスト
src/components/editor/live-preview/link-cards.test.ts LinkCard 判定/Widget 表示/eq のテスト
src/components/editor/live-preview/images.test.ts 画像 src 解決(相対/絶対/Windows)のテスト
src/components/editor/live-preview/horizontal-rules.test.ts HR 装飾ウィジェットのテスト
src/components/editor/live-preview/headings.test.ts 見出し解析/装飾のテスト
src/components/editor/live-preview/cursor-utils.test.ts カーソル行収集と差分判定のテスト
src/components/editor/live-preview/code-blocks.test.ts コードブロック装飾のテスト
src/components/editor/live-preview/code-block-copy.test.ts コードコピーウィジェットのテスト
src/components/editor/live-preview/blockquotes.test.ts 引用装飾のテスト
src/components/editor/formatting-commands.test.ts Markdown フォーマット操作コマンドのテスト
src/components/editor/MermaidEditorDialog.test.tsx MermaidEditorDialog(プレビュー遅延/IME/再オープン)のテスト
src/components/conflict/ConflictWindow.test.tsx ConflictWindow(hook order/自動 close/例外)のテスト
src/components/common/SetupWizardDialog.test.tsx セットアップウィザード(作成/既存/エラー/無効化)のテスト
src/components/common/SettingsDialog.test.tsx SettingsDialog(テンプレ作成/既存/エラー/外部リンク)のテスト
src/components/common/ExportDialog.test.tsx ExportDialog(HTML/PDF/プロンプト・テンプレ作成)のテスト
src/components/common/EmojiInputDialog.test.tsx EmojiInputDialog(大量描画/検索/rAF/IME)安定化込みのテスト
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/components/slide/SlidePreview.test.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/components/slide/SlidePreview.test.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
test: SlidePreview のアサーションを null 安全 + hr 検証に強化
8426810
PR #5 の copilot レビュー指摘 2 件に対応:
- `expect(content).toBeDefined()` は querySelector が null を返しても通って
  しまうため、`not.toBeNull()` に変更。DOM 不在を検知できるようにする
- 「区切り行だけのスライドは hr として表示する」テストが content の存在
  確認しかしていなかったため、`querySelector(\"hr\")` で実際に <hr> が
  描画されることを検証する形に強化

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 1, 2026 23:29
Copilot AI reviewed May 1, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 65 out of 66 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/test-setup.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/components/common/ExportDialog.test.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
test: matchMedia stub に configurable + ExportDialog コメント修正
ea38e2e
PR #5 の copilot レビュー指摘 2 件に対応:
- src/test-setup.ts: window.matchMedia stub の Object.defineProperty に
  configurable: true を追加。別のテストやライブラリが matchMedia を再定義
  しても TypeError にならないようにする
- src/components/common/ExportDialog.test.tsx: コメントの「navigator.platform」を
  「navigator.userAgent」に修正(実装と整合)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 2, 2026 01:25
Copilot started reviewing on behalf of ymnao May 2, 2026 01:25
View session
Copilot AI reviewed May 2, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 65 out of 66 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/components/layout/StatusBar.test.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/components/common/ExportDialog.test.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
test: clipboard / userAgent の上書きを退避・復元する形に修正
edaab34
PR #5 の copilot レビュー指摘 2 件に対応:

- StatusBar.test.tsx: navigator.clipboard を上書きする 2 テストを
  describe(\"clipboard interactions\") にまとめ、beforeEach で original を
  退避、afterEach で必ず復元する形に変更。同一 worker 内の他テストへ
  clipboard が漏れて shuffle 実行でフレーク要因になるのを防ぐ
- ExportDialog.test.tsx: vi.hoisted で navigator.userAgent を書き換える際、
  元の値を vi.hoisted の戻り値で保存して afterAll で復元する形に変更。
  module load 時に userAgent を参照する他テストへの影響を排除

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 2, 2026 01:52
Copilot started reviewing on behalf of ymnao May 2, 2026 01:53
View session
Copilot AI reviewed May 2, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 65 out of 66 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ymnao
ymnao merged commit 379ec1a into main May 2, 2026
8 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@ymnao
ymnao deleted the chore/stage-0b-tests branch May 2, 2026 01:59
@ymnao ymnao mentioned this pull request May 8, 2026
test: Playwright _electron API ベースの最小 e2e を追加 #33
Closed
15 tasks
ymnao added a commit that referenced this pull request May 31, 2026
@ymnao @claude
chore: PR #103 code-review 7 件反映 (CI ガード設計欠陥修正)
9a1ff5e
/code-review で検出した 7 件全てに対応。最重要は self-counting 解消
(scripts/check-tauri-residue.sh → scripts/check-legacy-residue.sh)。

Fix #1: self-counting で Phase 5 green 化が原理的に不可能だった問題:
- scripts/check-tauri-residue.sh → check-legacy-residue.sh にリネーム
- ci.yml job tauri-residue → legacy-residue にリネーム
- package.json check:tauri-residue → check:legacy-residue にリネーム
- ci.yml コメントから "Tauri" / "WKWebView" verbatim を排除
- 結果: 88 行 (うち 4 行 self-reference) → 84 行 baseline と一致

Fix #2: pnpm verify が CI と divergence していた問題:
- verify chain に typecheck:e2e + build を追加
- check:legacy-residue は意図 fail のため verify には含めない (CLAUDE.md
  で「補助」として別行案内)

Fix #3: PATHS の coverage gap:
- pnpm-workspace.yaml (CLAUDE.md 上 canonical config) 追加
- vite.config.e2e.ts 追加
- tsconfig.json (root) 追加
- docs/tauri-purge-inventory.md §2.1 にも追従

Fix #4: WebKit 扱いの inventory との非整合:
- script ヘッダで WebKit 除外の意図を明記 (-webkit- prefix FP 回避)
- inventory §2.1 / §2.5 / §2.6 で CI ガードとの差分を明記
  (ime.ts:4 等 WebKit 系コメントは CI 非対象 → Phase 3 で手動チェック)

Fix #5: git grep exit ≥2 (pathspec error / 非 git repo 等) を silently
success として扱っていた問題:
- if RESULT=$(...) を捨て、明示的に EXIT=$? を捕捉
- case 0 / 1 / *) で 3 分岐 (match / no-match / error)
- error 時は stderr 出力 + exit 2

Fix #6: continue-on-error は workflow 成否にのみ作用し job の check-run
は failure のまま残るため、branch protection の required status checks
に追加すると merge blocking される:
- workflow コメントに caveat を追記
- 「Phase 5 完了まで required 化しない」運用を明示

Fix #7: :(exclude)scripts/check-tauri-residue.sh の dead code 化:
- 新ファイル名 :(exclude)scripts/check-legacy-residue.sh に更新
- 「PATHS に scripts/ を含めないため現状 no-op、defensive 配置」コメント
  追記

検証:
- bash scripts/check-legacy-residue.sh → 84 行検出 (PR 直前と一致)
- pnpm verify (format / lint / typecheck / typecheck:e2e / test /
  test:e2e / build) 全 pass

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ymnao added a commit that referenced this pull request May 31, 2026
@ymnao @claude
chore: Tauri 残骸検出 CI ガードを追加 (#82 Phase 1 PR-2) (#103)
d0f3a7b
* chore: Tauri 残骸検出 CI ガードを追加 (#82 Phase 1 PR-2)

Issue #82 サブタスク D。Phase 2-5 の削除・置換進捗を質的に追跡する
CI ガードを設置する。

変更:
- scripts/check-tauri-residue.sh: 13 種の FORBIDDEN keyword
  (tauri / wkwebview / __TAURI / webviewWindow / @tauri-apps /
  src-tauri / tauri:// / tauri-plugin / data-tauri- /
  convertFileSrc / WebviewWindow / appWindow / tauri.conf) を
  git grep で検出。1 hit でも exit 1。対象スコープは
  docs/tauri-purge-inventory.md §2.1 と同期。-webkit- prefix CSS
  の false positive は keyword に WebKit を含めないことで除外
- package.json: check:tauri-residue script + verify script を追加
  (verify = format && lint && typecheck && test && test:e2e の
  chain を codify。check:tauri-residue は Phase 5 完了時に verify
  へ合流予定)
- .github/workflows/ci.yml: tauri-residue job を追加。Phase 1 時点
  では既存残骸 84 行が検出され意図 fail するため continue-on-error:
  true で merge を blocking しない運用。Phase 5 完了 PR で除去
- CLAUDE.md: 「コミット前の検証」を pnpm verify に集約

ローカル実行: 84 行検出で exit 1 (期待動作)。inventory §2.2 の
集計 (B 14 行 + 残り A/C/D) と整合。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore: PR #103 code-review 7 件反映 (CI ガード設計欠陥修正)

/code-review で検出した 7 件全てに対応。最重要は self-counting 解消
(scripts/check-tauri-residue.sh → scripts/check-legacy-residue.sh)。

Fix #1: self-counting で Phase 5 green 化が原理的に不可能だった問題:
- scripts/check-tauri-residue.sh → check-legacy-residue.sh にリネーム
- ci.yml job tauri-residue → legacy-residue にリネーム
- package.json check:tauri-residue → check:legacy-residue にリネーム
- ci.yml コメントから "Tauri" / "WKWebView" verbatim を排除
- 結果: 88 行 (うち 4 行 self-reference) → 84 行 baseline と一致

Fix #2: pnpm verify が CI と divergence していた問題:
- verify chain に typecheck:e2e + build を追加
- check:legacy-residue は意図 fail のため verify には含めない (CLAUDE.md
  で「補助」として別行案内)

Fix #3: PATHS の coverage gap:
- pnpm-workspace.yaml (CLAUDE.md 上 canonical config) 追加
- vite.config.e2e.ts 追加
- tsconfig.json (root) 追加
- docs/tauri-purge-inventory.md §2.1 にも追従

Fix #4: WebKit 扱いの inventory との非整合:
- script ヘッダで WebKit 除外の意図を明記 (-webkit- prefix FP 回避)
- inventory §2.1 / §2.5 / §2.6 で CI ガードとの差分を明記
  (ime.ts:4 等 WebKit 系コメントは CI 非対象 → Phase 3 で手動チェック)

Fix #5: git grep exit ≥2 (pathspec error / 非 git repo 等) を silently
success として扱っていた問題:
- if RESULT=$(...) を捨て、明示的に EXIT=$? を捕捉
- case 0 / 1 / *) で 3 分岐 (match / no-match / error)
- error 時は stderr 出力 + exit 2

Fix #6: continue-on-error は workflow 成否にのみ作用し job の check-run
は failure のまま残るため、branch protection の required status checks
に追加すると merge blocking される:
- workflow コメントに caveat を追記
- 「Phase 5 完了まで required 化しない」運用を明示

Fix #7: :(exclude)scripts/check-tauri-residue.sh の dead code 化:
- 新ファイル名 :(exclude)scripts/check-legacy-residue.sh に更新
- 「PATHS に scripts/ を含めないため現状 no-op、defensive 配置」コメント
  追記

検証:
- bash scripts/check-legacy-residue.sh → 84 行検出 (PR 直前と一致)
- pnpm verify (format / lint / typecheck / typecheck:e2e / test /
  test:e2e / build) 全 pass

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Jun 19, 2026
chore: undici security advisory 9 件を parent>child override で対応 #201
Merged
chore: Electron security checklist 補完 (permission handler / fs:read size limit / pdf debug env) #204
Closed
chore: Electron security checklist の Tier 1 補完 (#204) #210
Merged
test: same-line [[target]] [[target]] の trim test を追加 (iterateWikilinkOccurrences の per-yield 新規 alloc を lock) #241
Closed
This was referenced Jul 12, 2026
feat: スライドプレビューを fit-to-frame スケール描画に変更 (Fable #3) #316
Merged
feat: スライド発表モード (F5) を追加 #330
Merged
ymnao added a commit that referenced this pull request Jul 14, 2026
@ymnao
docs: HelpDialog に macOS の Fn+F5 注記を追加 (#331)
3297ba9
- スライド発表モード (F5) の行に、macOS では Fn+F5 が必要な旨を小さな
  補助テキストで表示
- ShortcutGroup 型に optional な note フィールドを追加し、IS_MAC の
  場合のみ注記を出す
- Fable ロードマップ #5 (発表モード) の派生 UX 改善
@ymnao ymnao mentioned this pull request Jul 20, 2026
feat: FileTree に WAI-ARIA tree キーボード操作を追加 #389
Merged
3 of 4 tasks
ymnao added a commit that referenced this pull request Jul 20, 2026
@ymnao
feat: FileTree に WAI-ARIA tree キーボード操作を追加 (#389)
43f8ec3
* feat: FileTree に WAI-ARIA tree キーボード操作を追加

- root ul に role="tree"、button に role="treeitem" を付与
- roving tabindex で Tab 遷移を tree 全体で 1 stop に
- ↑↓ で visible item 移動、→ で folder 展開・展開済みなら第一子へ、
  ← で folder 畳み・else 親へ、Enter/Space で activate、Home/End で先頭/末尾
- 選択パスと focus を同期、rename/create InlineInput 中は key handler を早期 return
- FileTree.test.tsx にキーボード操作 8 ケース追加

Fable 広範レビュー (session 123, PR #388) High #5 対応。

* refactor: FileTree keydown handler の /simplify 指摘対応

- focusedPath の 2 段 useEffect を 1 段 + effectiveFocusedPath 導出に整理
- currentBtn を closest<HTMLButtonElement> で型付けし 4 箇所の cast 削除
- data-depth の "?? 0" fallback 3 箇所削除 (常に present)
- unhandled key を querySelectorAll 前に早期 return

* fix: FileTree roving tabindex の fallback 保証と aria-selected 冗長解消

- code-reviewer Critical: focusedPath が visible entry に一致しないと
  どの treeitem も tabIndex=0 にならず Tab で tree に入れなくなる問題を
  修正 (workspace 切替 / 外部削除 / nested selectedPath でトリガ)。
  render 後に tabbable の存在を DOM で検査し、無ければ先頭 entry に fallback
- code-reviewer Warning: aria-selected={isSelected || undefined} に変更し
  未選択 item への "not selected" 冗長読み上げを回避
- fallback 不変条件を検証する test 1 件追加

skip 判断:
- selectedPath 上書き warning: 意図的挙動 (外部選択に追随)
- Cmd+Enter modifier: 既存挙動非退化 (before PR も同じ)
- onFocus + focusIdx の重複 setState: React 18 同値 bailout で無害
- ArrowRight 展開後 auto-focus 子: 非同期待ち必要、scope 外
- typeahead search: scope 外

* fix: CI lint 失敗の解消 (ul/li → div、useExhaustiveDependencies)

- FileTree の tree 構造を ul/li から div ベースに変更
  - noNoninteractiveElementToInteractiveRole (role="tree" on ul) 対応
  - rootUlRef 型を HTMLDivElement へ、keydown handler 型も同期
  - test 側の querySelector("ul") を [role="tree"] に置き換え
- FileTreeItem の子コンテナ role="group" にも同ルールが当たるが
  fieldset は tree pattern の a11y と両立不能なため biome-ignore で許可
  (SlideView.tsx:271 の separator role と同じ扱い)
- 空 folder メッセージの <li> を <div> に変更
- useExhaustiveDependencies: fallback useEffect の deps を body で
  実際に参照するよう再構成 (focusedPath check + entries.length guard)
- refreshKey は root fallback に不要なため deps から除外

* style: FileTree.test.tsx の biome format 適用

sed 置換で "\"" escape 記法が残っていた箇所を biome 標準の single-quote
形式へ (biome format 差分のみ、挙動変更なし)
@ymnao ymnao mentioned this pull request Oct 26, 2026
fix: ウィンドウを閉じるとき、main が close 要求を送らないので未保存の編集が消える #727
Open
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ymnao
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.