Skip to content

test(mobile): test PR review diff behavior instead of internals - #8029

Merged
iscekic merged 5 commits into
mainfrom
drain/pr-review-diff-behavior-tests
Oct 21, 2026
Merged

iscekic merged 5 commits into
mainfrom
drain/pr-review-diff-behavior-tests

Conversation

@iscekic

@iscekic iscekic commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Change

Test-only change under apps/mobile/src/lib. The PR review diff suites kept several tests that pin implementation internals or cannot fail, and missed behavior coverage on two hooks. This PR swaps each pinned contract for the observable one:

  • parse-patch-accessibility.test.ts: removed the self-comparing label test; the exact-label assertions already prove the parsed type drives the status word.
  • pr-diff-list-builder.test.ts: removed the parse-call-count test with its parse-patch mock; the trailing separator now asserts its unknown end as the expand row's unknown-end branch input, and the separator presence, gap index, and start line stay asserted.
  • highlight.test.ts: removed the cache test whose only assertion (identical output for identical input) holds by determinism.
  • pr-review-file-list-state: the pure builder test now asserts the literal documented 60-page ceiling; a new mounted suite (pr-review-file-list-state.mounted.test.tsx) drives usePrReviewFileListQuery and asserts the first-page versus later-page error classification (firstPageErrorState, laterPageError, loaded files kept).
  • use-pr-review-viewed-files.mounted.test.tsx: removed the three mock call-argument pass-through tests; extended the mounted behavior coverage with a two-provider independence case (a toggle through a GitLab MR never lights up a same-numbered GitHub PR).
  • viewed-files.test.ts: the LRU cap test seeds distinguishable paths, asserts the surviving entry keeps its own set, and asserts the stored map holds exactly 20 keys after the 21st toggle.
  • infinite-retention.test.ts: the refetch fan-out test now builds its observer options through withInfiniteRetention(..., 3), so the module's own helper is exercised end to end.
  • viewed-files-store.test.ts: replaced the fixed two-microtask settle() drains with a bounded waitFor on observable publishes (snapshot loaded, listener counts, path sets) plus a single macrotask flush where the test asserts nothing published; the held-read fence tests keep their gated promises.
  • New use-pr-diff-page-gate.mounted.test.tsx: covers the pagination gate's hold-until-drag contract (end-reach held until a drag, drag alone never fetches, post-drag end-reach fetches directly, no next page / in-flight page fetch blocked) and the identity reset (a held end-reach from the previous PR is discarded; the switched-in PR starts with a fresh gate). Rerenders keep the same root element type so the hook instance survives the identity change.
  • use-pr-diff-context-loader.mounted.test.tsx: added the partial, unavailable (no lines), unavailable (NOT_FOUND), and error expansion states, asserted on expandedContext.

pr-review-file-list-state.ts exports the named PrReviewFileListQueryResult type so the mounted test imports a contract name instead of reaching through ReturnType.

Verification

  • vitest run --project mobile-pure over src/lib/pr-review/diff/, src/lib/pr-review/viewed-files.test.ts, src/lib/query/infinite-retention.test.ts: 166 passed.
  • vitest run --project mobile-mounted over src/lib/pr-review/diff/: 20 passed.
  • Failability checks: with the page-gate's identity reset disabled, the reset test fails; with the provider-key suffix dropped, the provider-independence test fails; with maxPages dropped from withInfiniteRetention, three retention tests fail. All restored to production code afterwards.
  • oxlint (repo mobile config) on all changed files: 0 warnings, 0 errors. Mobile tsgo typecheck error count is unchanged from main (pre-existing tRPC build-artifact errors; none reference the changed files).

No runtime behavior changed. The only non-test edits are an exported type alias for the existing hook return type (PrReviewFileListQueryResult) and two type-only imports that use it.

Proxy answers

  1. Question: The infinite-retention refetch fan-out test exercises TanStack Query directly. The finding offers two options: delete it, or rewrite it to build the observer options through withInfiniteRetention(..., 3) and keep the fan-out assertion. Which?
    Answer: Rewrite through withInfiniteRetention
    Confidence: 0.60 · Precedent: Do the least work possible with no drop in quality; session 7f3470e0ba6f: "do the least amount of work possible, with no drop in quality". A rewrite keeps the maxPages fan-out invariant and ties it to the module's own code.
  2. Question: For the file-list hook behavior tests (first-page vs later-page error classification), the finding suggests mounting the hook. That needs a new *.mounted.test.tsx file since the pure project can't mount React. OK to add a new mounted test file for this?
    Answer: New mounted file (Recommended)
    Confidence: 0.70 · Precedent: Make executive decisions yourself and use "is this reasonable?" as the test; session 7f3470e0ba6f. Mounting the hook tests behavior with less mock surface.
  3. Question: For the new page-gate test, identity changes need a rerender with a different identity prop. Which mechanism?
    Answer: renderer.update with QueryClientProvider (Recommended)
    Confidence: 0.70 · Precedent: Keep similar elements consistent across surfaces; session a247f3c19b1e: the thought row should match the tool call row. This option matches the existing mounted-test harness and makes the identity change a real render.
  4. Question: viewed-files-store.test.ts: replace settle() microtask drains with which mechanism?
    Answer: Bounded waitFor + one-macrotask flush (Recommended)
    Confidence: 0.65 · Precedent: Speed and least work: "do the least amount of work possible, with no drop in quality" (session 7f3470e0ba6f). The brief allows a bounded waitFor, and it avoids per-test promise wiring.
  5. Question: The viewed-files mounted suite: after removing the three pass-through tests, how far should the extended cross-probe behavior test go?
    Answer: Two-provider independence test (Recommended)
    Confidence: 0.70 · Precedent: Speed and least work: "skip work that doesn't need to be done" (session 00eb2a1d3e4b). viewed-files.test.ts already covers instance keying.
  6. Question: Verification depth: mutate-and-see-fail spot check on one new suite?
    Answer: Spot-check one suite (Recommended)
    Confidence: 0.75 · Precedent: Proof and verification: "logs and/or screenshots are mandatory proof ... make sure they make sense" (session 55c9c80332a7). A cheap mutation check shows the new tests can fail.

…vior tests

Delete tests that cannot fail or only pin internals: the self-comparing
accessibility label test, the parse-call-count WeakMap cache test with its
parse-patch mock, the Infinity endLine sentinel assertion, the highlight
cache equality test, and the three viewed-files mock pass-through tests.

Replace pass-throughs with observable contracts: the file-list retention
bound is asserted at the literal documented ceiling and the hook's
first-page versus later-page error classification is covered by a new
mounted suite; the viewed-files LRU test seeds distinguishable paths and
asserts the stored key count; the refetch fan-out test routes its observer
options through withInfiniteRetention; the store tests await observable
publishes instead of fixed microtask drains; a new mounted suite covers
the pagination gate's hold-until-drag and identity reset; the context
loader suite asserts the partial, unavailable, and error expansion states.
@iscekic iscekic added drain Work item from the findings drain janitor:test-improver Janitor finding: evidence and test quality labels Oct 19, 2026
Comment thread apps/mobile/src/lib/pr-review/diff/use-pr-diff-page-gate.mounted.test.tsx Outdated
Comment thread apps/mobile/src/lib/pr-review/diff/pr-review-file-list-state.test.ts Outdated
Comment thread apps/mobile/src/lib/pr-review/diff/pr-diff-list-builder.test.ts
Comment thread apps/mobile/src/lib/query/infinite-retention.test.ts
@kilo-code-bot

kilo-code-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental commit adds the trailing separator's endLine === Infinity assertion, resolving the last open coverage gap; it matches the builder's output and the consumer's unknown-end branch, and no new issues were found.

Files Reviewed (1 file)
  • apps/mobile/src/lib/pr-review/diff/pr-diff-list-builder.test.ts - 0 issues

Review was static (read-only); the suites were not executed.

Previous Review Summaries (3 snapshots, latest commit 874e8bd)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 874e8bd)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The final lint-only commit (making the SecureStore stubs await) introduces no new issues; the sole remaining item is the previously raised, still-open coverage gap for the trailing separator's non-finite endLine.

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
apps/mobile/src/lib/pr-review/diff/pr-diff-list-builder.test.ts 139 The trailing separator's non-finite endLine contract is still uncovered; the author has declined to re-add it, so this remains open for maintainer judgment.
Files Reviewed (2 files)
  • apps/mobile/src/lib/pr-review/diff/use-pr-review-viewed-files.mounted.test.tsx - 0 issues
  • apps/mobile/src/lib/pr-review/diff/pr-diff-list-builder.test.ts - 1 issue (carried forward, unchanged by the incremental commit)

Review was static (read-only); the suites were not executed.

Fix these issues in Kilo Cloud

Previous review (commit 31f0851)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The follow-up commit resolves the five prior findings and adds the missing drag-before-switch, idempotent-hold, colliding-provider, and fourth-page retention coverage; the only remaining gap is the deleted assertion on the trailing separator's non-finite endLine.

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
apps/mobile/src/lib/pr-review/diff/pr-diff-list-builder.test.ts 139 The trailing separator's non-finite endLine contract is still uncovered.
Files Reviewed (13 files)
  • apps/mobile/src/lib/pr-review/diff/highlight.test.ts - 0 issues
  • apps/mobile/src/lib/pr-review/diff/parse-patch-accessibility.test.ts - 0 issues
  • apps/mobile/src/lib/pr-review/diff/pr-diff-list-builder.test.ts - 1 issue
  • apps/mobile/src/lib/pr-review/diff/pr-review-file-list-state.mounted.test.tsx - 0 issues
  • apps/mobile/src/lib/pr-review/diff/pr-review-file-list-state.test.ts - 0 issues
  • apps/mobile/src/lib/pr-review/diff/pr-review-file-list-state.ts - 0 issues
  • apps/mobile/src/lib/pr-review/diff/use-pr-diff-context-loader.mounted.test.tsx - 0 issues
  • apps/mobile/src/lib/pr-review/diff/use-pr-diff-page-gate.mounted.test.tsx - 0 issues
  • apps/mobile/src/lib/pr-review/diff/use-pr-diff-page-gate.ts - 0 issues
  • apps/mobile/src/lib/pr-review/diff/use-pr-review-viewed-files.mounted.test.tsx - 0 issues
  • apps/mobile/src/lib/pr-review/diff/viewed-files-store.test.ts - 0 issues
  • apps/mobile/src/lib/pr-review/viewed-files.test.ts - 0 issues
  • apps/mobile/src/lib/query/infinite-retention.test.ts - 0 issues

Review was static (read-only); the suites were not executed.

Fix these issues in Kilo Cloud

Previous review (commit 6919f61)

Status: 6 Issues Found | Recommendation: Address before merge

Executive Summary

The test-only refactor is structurally sound, but the new page-gate identity test leaves the drag-before-switch regression (stale userDragged) unverified, and two added tests claim to prove contracts they would not catch.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 5
Issue Details (click to expand)

WARNING

File Line Issue
apps/mobile/src/lib/pr-review/diff/use-pr-diff-page-gate.mounted.test.tsx 168 Identity-reset test never drags before switching, so the userDragged reset is unverified.

SUGGESTION

File Line Issue
apps/mobile/src/lib/pr-review/diff/use-pr-diff-page-gate.mounted.test.tsx 108 "once" is not asserted; a missed heldEndReach clear still passes.
apps/mobile/src/lib/pr-review/diff/pr-review-file-list-state.test.ts 30 Comment says 100/page = 6,000; the server pages 50, so the ceiling is 3,000.
apps/mobile/src/lib/pr-review/diff/pr-diff-list-builder.test.ts 139 Removed assertion was the only coverage of the trailing separator's non-finite endLine.
apps/mobile/src/lib/pr-review/diff/use-pr-review-viewed-files.mounted.test.tsx 90 Provider-independence test mocks viewedFilesKey; the fixtures do not collide under the legacy key.
apps/mobile/src/lib/query/infinite-retention.test.ts 171 Test loads only 3 pages with a cap of 3, so a missing maxPages still passes.
Files Reviewed (13 files)
  • apps/mobile/src/lib/pr-review/diff/highlight.test.ts - 0 issues
  • apps/mobile/src/lib/pr-review/diff/parse-patch-accessibility.test.ts - 0 issues
  • apps/mobile/src/lib/pr-review/diff/pr-diff-list-builder.test.ts - 1 issue
  • apps/mobile/src/lib/pr-review/diff/pr-review-file-list-state.mounted.test.tsx - 0 issues
  • apps/mobile/src/lib/pr-review/diff/pr-review-file-list-state.test.ts - 1 issue
  • apps/mobile/src/lib/pr-review/diff/pr-review-file-list-state.ts - 0 issues
  • apps/mobile/src/lib/pr-review/diff/use-pr-diff-context-loader.mounted.test.tsx - 0 issues
  • apps/mobile/src/lib/pr-review/diff/use-pr-diff-page-gate.mounted.test.tsx - 2 issues
  • apps/mobile/src/lib/pr-review/diff/use-pr-diff-page-gate.ts - 0 issues
  • apps/mobile/src/lib/pr-review/diff/use-pr-review-viewed-files.mounted.test.tsx - 1 issue
  • apps/mobile/src/lib/pr-review/diff/viewed-files-store.test.ts - 0 issues
  • apps/mobile/src/lib/pr-review/viewed-files.test.ts - 0 issues
  • apps/mobile/src/lib/query/infinite-retention.test.ts - 1 issue

Review was static (read-only); the suites were not executed.


Reviewed by deepseek-v4.1-flash-1017 · Input: 32.1K · Output: 2.1K · Cached: 280.6K

Review guidance: REVIEW.md from base branch main

…t hold, colliding provider fixtures, 4th-page retention cap

@iscekic iscekic left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

bot: Fixed in 31f0851. The reset coverage is now two cases: resets the gate when the PR identity changes drags pr-1, switches to pr-2, and asserts the mount-time end-reach does not fetch (catches a userDragged reset miss); discards a held end-reach from the previous PR on identity change keeps the original held-end-reach-then-switch case. Verified both fail against a gate that only resets heldEndReach and pass on the current code.

@iscekic iscekic added the merge:human Substantive functional risk requires human review. label Oct 19, 2026
@iscekic iscekic added merge:bot Bot-owned review; merge when ready once readiness passes and a review approves. and removed merge:human Substantive functional risk requires human review. labels Oct 20, 2026
@iscekic
iscekic added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit e70ef0a Oct 21, 2026
89 checks passed
@iscekic
iscekic deleted the drain/pr-review-diff-behavior-tests branch October 21, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

drain Work item from the findings drain janitor:test-improver Janitor finding: evidence and test quality merge:bot Bot-owned review; merge when ready once readiness passes and a review approves.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants