test: lib の純粋アルゴに vitest characterization テストを導入 + CI (#38)#41
Merged
Conversation
Deploying machigai-salad with
|
| Latest commit: |
8cb7571
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://49f88db7.machigai-salad.pages.dev |
| Branch Preview URL: | https://38-lib-tests.machigai-salad.pages.dev |
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
closes #38
概要
lib/の OpenCV 非依存の純ロジック関数 に対し、現状挙動を golden master として固定する characterization テストを導入。テスト基盤 (vitest) と最小 CI を追加した。本番コード (lib の実装) は一切変更していない。対象関数とテスト観点
detectLineInApplib/detectLineInApp.tsLine/<digit>境界、lookalike 除外、Android が iOS より先に評価される quirk、未対応プラットフォーム=nullorderPointslib/opencv/paper-detection.tscornersToMatlib/opencv/paper-detection.tscv.matFromArray(4,1,CV_32FC2,[x0,y0,...])の配列レイアウトを stub cv で検証formatSaveDatelib/storage.tsYYYY/MM/DD HH:mm整形、ゼロ詰め、年は非パディングの quirk、秒/ミリ秒切り捨て (TZ=UTC pin)計 24 テスト・全緑 (
npm test=vitest run)。対象外 (OpenCV / canvas / DOM 依存で純ロジックでない)
drawMeshWarp/drawTexturedTriangle(mesh-warp.ts) — Canvas 2D context 依存image-utils.ts全般 — canvas / Image / WebCodecs / DOM 依存applyPerspectiveTransform/splitImage(image-transform.ts) — 実cv.*計算依存findBoundingQuad/detectPaperContour(paper-detection.ts) — 実cv.*(Canny/findContours 等) 依存getImageSize/resizeImage/isWebCodecsSupported— DOM/ブラウザ API 依存基盤・CI
vitest(devDependency) 導入、package.jsonに"test": "vitest run"を追加vitest.config.ts:@/*パスエイリアス解決、node 環境、TZ=UTCで日付テストを決定的に.github/workflows/ci.yml: push main / PR で Node 22・npm ci→npm test、HUSKY: 0、permissions: contents: read現状挙動 pin (quirk)
detectLineInApp: Android ブランチが iOS より先 → 両方含む UA は'android'orderPoints: y 同値時はArray.sortの安定性に依存して先頭2点=top / 末尾2点=bottom に分割formatSaveDate: 月日時分はゼロ詰めするが年はパディングしない