Skip to content

test(desktop): restore coverage baseline without lowering thresholds - #1488

Merged
DeliciousBuding merged 2 commits into
masterfrom
test/restore-frontend-coverage-baseline
Aug 1, 2026
Merged

test(desktop): restore coverage baseline without lowering thresholds#1488
DeliciousBuding merged 2 commits into
masterfrom
test/restore-frontend-coverage-baseline

Conversation

@DeliciousBuding

@DeliciousBuding DeliciousBuding commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add desktop auth hook delegation coverage
  • cover desktop file/preview/settings adapters across fallback paths
  • cover keyboard shortcut normalization, global shortcut routing, and search store state

Evidence

  • pnpm --filter agenthub-desktop exec vitest run --config vitest.desktop-ci.config.ts --coverage --coverage.reportsDirectory=coverage-recovery-without-dup
  • 56 files, 569 tests, 0 skipped before the final keyboard/search additions; focused additions: 4 tests passed
  • coverage before final additions: lines 68.28%, statements 64.97%, functions 62.33%, branches 55.07%
  • static baseline: lines 67.13%, statements 63.72%, functions 61.80%, branches 55.35%
  • git diff --check passed

This PR keeps the historical baseline unchanged and restores the desktop floor with behavior tests. Web coverage recovery remains a separate lane.

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for authentication, search, keyboard shortcuts, desktop file handling, evidence selection, and settings synchronization.
    • Added validation for cross-platform shortcut behavior, editable-field handling, failed previews, fallback settings access, and resilient synchronization.

Copilot AI review requested due to automatic review settings August 1, 2026 14:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@DeliciousBuding, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c4a5fc11-36da-48f4-a4b1-5d28c952240b

📥 Commits

Reviewing files that changed from the base of the PR and between 6309188 and df17ecd.

📒 Files selected for processing (5)
  • app/desktop/src/hooks/useAuth.test.tsx
  • app/desktop/src/hooks/useGlobalKeyboardShortcuts.test.tsx
  • app/desktop/src/platform/desktopAdapters.test.ts
  • app/desktop/src/stores/searchStore.test.ts
  • app/desktop/src/utils/keyboardShortcuts.test.ts
📝 Walkthrough

Walkthrough

This PR adds Vitest coverage for desktop authentication, keyboard shortcuts, search state, file and evidence adapters, and settings synchronization fallbacks.

Changes

Desktop test coverage

Layer / File(s) Summary
Authentication hook coverage
app/desktop/src/hooks/useAuth.test.tsx
Tests cover reactive auth state, token retrieval, delegated session actions, auto-login results, and subscription setup.
Keyboard and search behavior coverage
app/desktop/src/utils/keyboardShortcuts.test.ts, app/desktop/src/stores/searchStore.test.ts, app/desktop/src/hooks/useGlobalKeyboardShortcuts.test.tsx
Tests cover modifier matching, search dialog state, editable-element filtering, settings navigation, and unrelated shortcuts.
Desktop adapter coverage
app/desktop/src/platform/desktopAdapters.test.ts
Tests cover file selection, content previews, evidence targets, settings-read fallbacks, caching, and settings-write synchronization.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: restoring desktop test coverage without lowering coverage thresholds.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/restore-frontend-coverage-baseline

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
app/desktop/src/utils/keyboardShortcuts.test.ts (1)

15-22: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Reject an unexpected modifier.

The test verifies a missing required modifier. It does not verify that Ctrl+Shift+K fails for ['Ctrl', 'K']. An implementation that accepts extra modifiers would pass this suite.

Proposed test
     expect(matchesBinding(event({ ctrlKey: true, key: 'k' }), ['Ctrl', 'K'])).toBe(true);
+    expect(matchesBinding(event({ ctrlKey: true, shiftKey: true, key: 'k' }), ['Ctrl', 'K'])).toBe(false);
     expect(matchesBinding(event({ ctrlKey: true, key: 'k' }), ['Ctrl', 'Shift', 'K'])).toBe(false);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/desktop/src/utils/keyboardShortcuts.test.ts` around lines 15 - 22, Extend
the matchesBinding test in the “matches exact modifiers and the cross-platform
Ctrl/Command token” case to assert that an event with both Ctrl and Shift does
not match ['Ctrl', 'K']. Keep the existing required-modifier, cross-platform
token, undefined binding, and key-name assertions unchanged.
app/desktop/src/hooks/useGlobalKeyboardShortcuts.test.tsx (1)

11-26: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover every editable target type.

The hook filters input, textarea, select, and contenteditable elements. This test only covers input. Add cases for the other target types so a regression in their filtering cannot pass.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/desktop/src/hooks/useGlobalKeyboardShortcuts.test.tsx` around lines 11 -
26, Add coverage to the useGlobalKeyboardShortcuts test for textarea, select,
and contenteditable targets, verifying Ctrl+K does not open search when
dispatched from each editable element. Preserve the existing input case and
outside-editable document case, and clean up every created target after each
scenario.
app/desktop/src/hooks/useAuth.test.tsx (1)

15-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise the subscription callback before claiming reactive coverage.

The test checks the initial snapshot and confirms that subscribe was called. It never invokes the listener with a new snapshot. A regression in useSyncExternalStore update propagation could still pass.

Capture the listener, return a real cleanup function, replace getState with a new state object, notify the listener inside act, and assert that result.current updates.

Also applies to: 28-44

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/desktop/src/hooks/useAuth.test.tsx` at line 15, Update the subscription
test around useAuth to capture the listener passed to subscribe and return a
functional cleanup callback. Replace getState with a new state object, invoke
the captured listener inside act, and assert that result.current reflects the
updated state in addition to the existing initial snapshot and subscription
assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/desktop/src/platform/desktopAdapters.test.ts`:
- Line 88: Update the tests around openDesktopEvidencePreview and the
localStorage assertions to verify public adapter behavior instead of
implementation details: remove the hard-coded error-message and storage-key
checks, mock the external remote reads to fail, and confirm readSettings()
returns the cached values after each write.

---

Nitpick comments:
In `@app/desktop/src/hooks/useAuth.test.tsx`:
- Line 15: Update the subscription test around useAuth to capture the listener
passed to subscribe and return a functional cleanup callback. Replace getState
with a new state object, invoke the captured listener inside act, and assert
that result.current reflects the updated state in addition to the existing
initial snapshot and subscription assertions.

In `@app/desktop/src/hooks/useGlobalKeyboardShortcuts.test.tsx`:
- Around line 11-26: Add coverage to the useGlobalKeyboardShortcuts test for
textarea, select, and contenteditable targets, verifying Ctrl+K does not open
search when dispatched from each editable element. Preserve the existing input
case and outside-editable document case, and clean up every created target after
each scenario.

In `@app/desktop/src/utils/keyboardShortcuts.test.ts`:
- Around line 15-22: Extend the matchesBinding test in the “matches exact
modifiers and the cross-platform Ctrl/Command token” case to assert that an
event with both Ctrl and Shift does not match ['Ctrl', 'K']. Keep the existing
required-modifier, cross-platform token, undefined binding, and key-name
assertions unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 02317de1-749d-4eff-856f-b7f35c7ecba0

📥 Commits

Reviewing files that changed from the base of the PR and between 1d2feff and 6309188.

📒 Files selected for processing (5)
  • app/desktop/src/hooks/useAuth.test.tsx
  • app/desktop/src/hooks/useGlobalKeyboardShortcuts.test.tsx
  • app/desktop/src/platform/desktopAdapters.test.ts
  • app/desktop/src/stores/searchStore.test.ts
  • app/desktop/src/utils/keyboardShortcuts.test.ts

expect(mockOpenShell).toHaveBeenNthCalledWith(1, 'file:///tmp/readme.md');
expect(mockOpenShell).toHaveBeenNthCalledWith(2, './README.md');
expect(mockOpenShell).toHaveBeenNthCalledWith(3, 'https://example.test/a');
await expect(openDesktopEvidencePreview(invalidEvidence)).rejects.toThrow('No preview target');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove assertions of implementation strings.

Line 88 hard-asserts an error message. Lines 95, 123, and 131 hard-assert localStorage key strings. Assert the public adapter behavior instead. For example, force remote reads to fail and verify that readSettings() returns the cached values after each write.

As per coding guidelines, **/*.{test,spec}.{ts,tsx,js,jsx}: “禁止无保护力测试:不要复制实现 switch、测试常量字符串、硬断错误文案,或 mock 被测函数本身;mock 应模拟外部系统。”

Also applies to: 95-95, 123-123, 131-131

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/desktop/src/platform/desktopAdapters.test.ts` at line 88, Update the
tests around openDesktopEvidencePreview and the localStorage assertions to
verify public adapter behavior instead of implementation details: remove the
hard-coded error-message and storage-key checks, mock the external remote reads
to fail, and confirm readSettings() returns the cached values after each write.

Source: Coding guidelines

@DeliciousBuding
DeliciousBuding force-pushed the test/restore-frontend-coverage-baseline branch from 6309188 to df17ecd Compare August 1, 2026 17:32
@DeliciousBuding
DeliciousBuding merged commit 1e1e61e into master Aug 1, 2026
21 checks passed
@DeliciousBuding
DeliciousBuding deleted the test/restore-frontend-coverage-baseline branch August 1, 2026 17:56
DeliciousBuding pushed a commit that referenced this pull request Aug 1, 2026
…wave)

- Hub integration fixtures: merged in #1489
- Edge tests on Linux: merged in #1491 (incl. ACP request-sequence race fix)
- TokenDance ID defaults: merged in #1480 (+ check-secrets.sh *_URL exemption)
- Frontend coverage gate: merged #1490 (web 63.14→66.72) / #1488 (desktop)
- Edge lint debt: merged in #1491 (102→0, zero exclusions, .gitattributes eol)

Remaining: CI policy parser (#1481), Doc SSOT compaction, Desktop typecheck,
shared frontend tests.
DeliciousBuding added a commit that referenced this pull request Aug 1, 2026
…wave) (#1492)

- Hub integration fixtures: merged in #1489
- Edge tests on Linux: merged in #1491 (incl. ACP request-sequence race fix)
- TokenDance ID defaults: merged in #1480 (+ check-secrets.sh *_URL exemption)
- Frontend coverage gate: merged #1490 (web 63.14→66.72) / #1488 (desktop)
- Edge lint debt: merged in #1491 (102→0, zero exclusions, .gitattributes eol)

Remaining: CI policy parser (#1481), Doc SSOT compaction, Desktop typecheck,
shared frontend tests.

Co-authored-by: Codex (Delicious233) <codex@vectorcontrol.tech>
DeliciousBuding added a commit that referenced this pull request Aug 11, 2026
…1488)

* test(desktop): restore coverage baseline

* test(desktop): cover keyboard and search state

---------

Co-authored-by: Codex <codex@vectorcontrol.tech>
DeliciousBuding added a commit that referenced this pull request Aug 11, 2026
…wave) (#1492)

- Hub integration fixtures: merged in #1489
- Edge tests on Linux: merged in #1491 (incl. ACP request-sequence race fix)
- TokenDance ID defaults: merged in #1480 (+ check-secrets.sh *_URL exemption)
- Frontend coverage gate: merged #1490 (web 63.14→66.72) / #1488 (desktop)
- Edge lint debt: merged in #1491 (102→0, zero exclusions, .gitattributes eol)

Remaining: CI policy parser (#1481), Doc SSOT compaction, Desktop typecheck,
shared frontend tests.

Co-authored-by: Codex <codex@vectorcontrol.tech>
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.

2 participants