Skip to content

Add unit tests for various components and functionalities - #4

Merged
Meanski merged 3 commits into
mainfrom
feat/add-tests
Jul 11, 2026
Merged

Add unit tests for various components and functionalities#4
Meanski merged 3 commits into
mainfrom
feat/add-tests

Conversation

@Meanski

@Meanski Meanski commented Jul 11, 2026

Copy link
Copy Markdown
Owner
  • Implement tests for LocalTerminalView to cover terminal spawning, data routing, and resizing.
  • Create tests for TopBar to validate UI interactions and state changes.
  • Add tests for K8sIcon to ensure correct rendering and props handling.
  • Develop tests for ServerContextMenu to verify menu interactions and session management.
  • Enhance UnlockScreen tests to improve PIN entry handling and error display.
  • Introduce tests for SFTP connection logic to validate authentication methods and error handling.

Summary by CodeRabbit

  • Accessibility & Usability

    • Improved keyboard selection behavior in the database results grid.
    • Enhanced handling of complex database values, including large integers and structured data.
    • Improved PIN entry support for digit keys.
  • Tests

    • Added extensive coverage for menus, updates, authentication, sessions, terminals, Kubernetes, Redis, SSH, filesystem access, and renderer interactions.
    • Expanded testing for command palette, sidebar, logging, notifications, and connection workflows.

- Implement tests for LocalTerminalView to cover terminal spawning, data routing, and resizing.
- Create tests for TopBar to validate UI interactions and state changes.
- Add tests for K8sIcon to ensure correct rendering and props handling.
- Develop tests for ServerContextMenu to verify menu interactions and session management.
- Enhance UnlockScreen tests to improve PIN entry handling and error display.
- Introduce tests for SFTP connection logic to validate authentication methods and error handling.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 11, 2026

Copy link
Copy Markdown

Deploying noxed with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1499e49
Status: ✅  Deploy successful!
Preview URL: https://07ead990.noxed.pages.dev
Branch Preview URL: https://feat-add-tests.noxed.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

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

Next review available in: 31 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: fcd97a91-40ab-43b9-9841-f403c4e0d1de

📥 Commits

Reviewing files that changed from the base of the PR and between b3e2795 and 1499e49.

📒 Files selected for processing (7)
  • src/main/ipc/__tests__/k8s.handlers.more.test.ts
  • src/main/ipc/__tests__/keychain.handlers.test.ts
  • src/preload/__tests__/index.test.ts
  • src/renderer/src/components/CommandPalette/__tests__/CommandPalette.test.tsx
  • src/renderer/src/components/Database/DatabaseExplorer.tsx
  • src/renderer/src/components/Database/__tests__/DatabaseExplorer.test.tsx
  • src/renderer/src/components/Sidebar/__tests__/Sidebar.more.test.tsx
📝 Walkthrough

Walkthrough

Adds extensive automated coverage for Electron main-process handlers, preload IPC forwarding, renderer components, terminal and streaming lifecycles, authentication, sessions, networking, menus, updater behavior, and related UI interactions.

Changes

Application and IPC test coverage

Layer / File(s) Summary
Main-process menus and updater
src/main/__tests__/*
Tests platform-specific menus, command routing, updater IPC behavior, status broadcasts, and startup checks.
Kubernetes, terminal, and filesystem handlers
src/main/ipc/__tests__/{k8s,localTerminal,localfs}.handlers*.test.ts
Covers validation, resource mapping, streaming, PTY ownership, cleanup, filesystem access, and port forwarding.
Authentication, sessions, settings, and SSH
src/main/ipc/__tests__/{keychain,sessions,settings,sshClients}.handlers.test.ts
Tests credentials, lockout and auto-lock, session migration and import/export, settings persistence, SSH authentication, and jump hosts.
Redis and runner handlers
src/main/ipc/__tests__/{redis,runner}.handlers.test.ts
Covers Redis commands, scanning, TTLs, ownership, cleanup, command execution, cancellation, timeouts, and output routing.
Preload API forwarding
src/preload/__tests__/index.test.ts
Verifies IPC invocation, sending, subscriptions, and unsubscription across exposed API namespaces.

Renderer coverage

Layer / File(s) Summary
Navigation and workspace interactions
src/renderer/src/components/{CommandPalette,Sidebar,TopBar}/**/*test*
Tests palette search and activation, sidebar organization and context menus, top-bar actions, theme changes, and updater controls.
Streaming and terminal lifecycles
src/renderer/src/components/{Database,Docker,K8s,Terminal}/**/*test*, src/renderer/src/components/Database/DatabaseExplorer.tsx
Tests row keyboard behavior, log and exec streaming, reconnect and cleanup flows, terminal input/output, resizing, and value conversion.
Supporting components and SFTP
src/renderer/src/components/{Notifications,Settings,__tests__}/**/*test*, src/renderer/src/lib/__tests__/sftpConnect.test.ts
Tests notifications, icons, menus, unlock timing, PIN input, and SFTP credential and key authentication paths.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • Meanski/noxed#1: Adds the RDP preload API and corresponding IPC behavior covered by the new preload tests.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is very generic and does not identify the main areas covered by the new tests. Use a concise title naming the key components or subsystems being tested, such as terminal, UI, K8s, and SFTP behavior.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-tests

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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/preload/__tests__/index.test.ts (1)

31-68: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Avoid any in helper function signatures.

As per coding guidelines: "No any in function signatures. Use unknown and narrow, or define a proper type." The three helper functions (expectInvoke, expectSend, expectSubscription) use any[] and (...args: any[]) => any throughout their signatures. Consider using unknown[] with appropriate narrowing, or defining a minimal type for the API surface being tested.

🤖 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 `@src/preload/__tests__/index.test.ts` around lines 31 - 68, Replace the
any-based signatures in expectInvoke, expectSend, and expectSubscription with
type-safe alternatives using unknown and appropriate function types or a minimal
shared callback type; update argument forwarding and callback invocation as
needed so TypeScript remains valid without any while preserving the existing
test behavior.

Source: Coding guidelines

src/renderer/src/components/Terminal/__tests__/LocalTerminalView.test.tsx (1)

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

Replace any return type in term() with a proper type.

As per coding guidelines, src/**/*.{ts,tsx} files must have no any in function signatures. Define an interface for the mock terminal and use it as the return type.

♻️ Proposed fix
+interface MockTerminal {
+  options: Record<string, unknown>
+  cols: number
+  rows: number
+  dataCb: ((data: string) => void) | null
+  resizeCb: ((size: { cols: number; rows: number }) => void) | null
+  selectionCb: (() => void) | null
+  bellCb: (() => void) | null
+  open: ReturnType<typeof vi.fn>
+  write: ReturnType<typeof vi.fn>
+  dispose: ReturnType<typeof vi.fn>
+  focus: ReturnType<typeof vi.fn>
+  loadAddon: ReturnType<typeof vi.fn>
+  hasSelection: ReturnType<typeof vi.fn>
+  getSelection: ReturnType<typeof vi.fn>
+  onSelectionChange: ReturnType<typeof vi.fn>
+  onBell: ReturnType<typeof vi.fn>
+  onData: ReturnType<typeof vi.fn>
+  onResize: ReturnType<typeof vi.fn>
+}
+
 const held = vi.hoisted(() => ({
-  terminals: [] as any[],
-  fits: [] as any[],
-  observers: [] as any[],
+  terminals: [] as MockTerminal[],
+  fits: [] as Array<{ fit: ReturnType<typeof vi.fn> }>,
+  observers: [] as Array<{ cb: () => void; observe: () => void; unobserve: () => void; disconnect: () => void }>,
 }))

-function term(): any {
+function term(): MockTerminal {
   return held.terminals[held.terminals.length - 1]
 }
🤖 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 `@src/renderer/src/components/Terminal/__tests__/LocalTerminalView.test.tsx`
around lines 84 - 86, Replace the any return type of the term() helper with a
dedicated mock-terminal interface describing the properties and methods used by
the test, then annotate term() with that interface and update held.terminals
accordingly.

Source: Coding guidelines

🤖 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 `@src/main/ipc/__tests__/k8s.handlers.more.test.ts`:
- Around line 139-149: Restore the console.error spy after each test to prevent
cross-file test pollution. Update the afterEach hook alongside the
h.loadFromFileError reset to call vi.restoreAllMocks(), matching the cleanup
pattern used in localTerminal.handlers.test.ts.

In `@src/main/ipc/__tests__/keychain.handlers.test.ts`:
- Around line 114-138: Stub process.platform to "darwin" in the keychain
handlers test beforeEach so canUseTouchID() exercises the biometric paths, and
restore the original platform value in afterEach alongside the fake timers. Keep
the existing systemPreferences mocks unchanged and ensure restoration occurs
even after each test.

---

Nitpick comments:
In `@src/preload/__tests__/index.test.ts`:
- Around line 31-68: Replace the any-based signatures in expectInvoke,
expectSend, and expectSubscription with type-safe alternatives using unknown and
appropriate function types or a minimal shared callback type; update argument
forwarding and callback invocation as needed so TypeScript remains valid without
any while preserving the existing test behavior.

In `@src/renderer/src/components/Terminal/__tests__/LocalTerminalView.test.tsx`:
- Around line 84-86: Replace the any return type of the term() helper with a
dedicated mock-terminal interface describing the properties and methods used by
the test, then annotate term() with that interface and update held.terminals
accordingly.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 144c3a59-dfc2-49b9-a6a6-71db698c566c

📥 Commits

Reviewing files that changed from the base of the PR and between 75c5e3e and b3e2795.

📒 Files selected for processing (27)
  • src/main/__tests__/menu.test.ts
  • src/main/__tests__/updater.test.ts
  • src/main/ipc/__tests__/k8s.handlers.more.test.ts
  • src/main/ipc/__tests__/keychain.handlers.test.ts
  • src/main/ipc/__tests__/localTerminal.handlers.test.ts
  • src/main/ipc/__tests__/localfs.handlers.test.ts
  • src/main/ipc/__tests__/redis.handlers.test.ts
  • src/main/ipc/__tests__/runner.handlers.test.ts
  • src/main/ipc/__tests__/sessions.handlers.test.ts
  • src/main/ipc/__tests__/settings.handlers.test.ts
  • src/main/ipc/__tests__/sshClients.handlers.test.ts
  • src/preload/__tests__/index.test.ts
  • src/renderer/src/components/CommandPalette/__tests__/CommandPalette.test.tsx
  • src/renderer/src/components/Database/DatabaseExplorer.tsx
  • src/renderer/src/components/Docker/__tests__/DockerLogsModal.test.tsx
  • src/renderer/src/components/K8s/__tests__/PodExecModal.test.tsx
  • src/renderer/src/components/K8s/__tests__/PodLogsModal.test.tsx
  • src/renderer/src/components/Notifications/__tests__/NotificationHost.test.tsx
  • src/renderer/src/components/Settings/Settings.tsx
  • src/renderer/src/components/Settings/__tests__/Settings.test.tsx
  • src/renderer/src/components/Sidebar/__tests__/Sidebar.more.test.tsx
  • src/renderer/src/components/Terminal/__tests__/LocalTerminalView.test.tsx
  • src/renderer/src/components/TopBar/__tests__/TopBar.test.tsx
  • src/renderer/src/components/__tests__/K8sIcon.test.tsx
  • src/renderer/src/components/__tests__/ServerContextMenu.test.tsx
  • src/renderer/src/components/__tests__/UnlockScreen.test.tsx
  • src/renderer/src/lib/__tests__/sftpConnect.test.ts

Comment thread src/main/ipc/__tests__/k8s.handlers.more.test.ts
Comment thread src/main/ipc/__tests__/keychain.handlers.test.ts
@Meanski
Meanski merged commit e12e994 into main Jul 11, 2026
3 checks passed
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.

1 participant