Skip to content

test(explorer): cover file icon resolution chain - #1076

Open
mydd7 wants to merge 1 commit into
crynta:mainfrom
mydd7:test/coverage-21
Open

test(explorer): cover file icon resolution chain#1076
mydd7 wants to merge 1 commit into
crynta:mainfrom
mydd7:test/coverage-21

Conversation

@mydd7

@mydd7 mydd7 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What

Adds unit tests for the file/folder icon resolution chain in
explorer/lib/iconResolver.ts. Test-only.

Why

fileIconUrl resolves which icon a file gets through a by-name -> extension ->
compound-extension -> default fallback chain, and that resolution logic was
untested.

How

The assertions lock the resolution algorithm, not the icon SVGs: they compare
outputs relationally (known vs default, base vs compound extension, by-name vs
default), so they stay valid when the underlying icon set changes.

Locked behavior:

  • Returns an inline svg data url.
  • Deterministic per extension.
  • A known extension resolves to something other than the default.
  • A compound extension (.test.tsx) resolves differently from its base (.tsx).
  • A by-name match (Dockerfile) is non-default.
  • An unknown extension falls back to the default.

Testing

Ran the full suite plus type-check and lint locally on Windows.

  • pnpm lint clean (unchanged: 103 pre-existing warnings, none introduced)
  • pnpm check-types clean
  • pnpm test clean (the new suite passes; see reviewer note on one
    pre-existing suite)
  • Manual smoke-test of the affected feature - N/A, test-only, no runtime change
  • (If you touched src-tauri/) cargo clippy - N/A, no Rust changes
  • (If you touched src-tauri/) cargo nextest - N/A, no Rust changes
  • (If you changed a #[tauri::command] signature) - N/A
  • (If UI) tested in pnpm tauri dev - N/A, no UI change
  • Platforms tested: Windows
  • Shells tested (if relevant): N/A

Screenshots / GIFs

N/A - no UI change.

Notes for reviewer

  • Test-only. No public API, behavior, dependency, or config change.
  • Branched a couple of commits behind current main on purpose (my token lacks
    the workflow scope). Only adds a new file; should merge cleanly.
  • Same unrelated pre-existing failure noted before: src/app/eager-budget.test.ts
    fails locally under Windows with git core.autocrlf=true; the committed blob is
    LF and it passes on CI.

Summary by CodeRabbit

  • Tests
    • Added coverage for file and folder icon resolution.
    • Verified consistent icon generation, support for known and compound file extensions, filename-based matches, and fallback behavior for unknown types.
    • Confirmed that generated icons are available as inline SVG data URLs.

fileIconUrl and folderIconUrl resolve which icon a file or folder gets, but the resolution chain had no tests. Lock the algorithm (not the icon set): a known extension resolves to something other than the default, resolution is deterministic per extension, a compound extension (.test.tsx) resolves differently from its base (.tsx), a by-name match like Dockerfile is non-default, and an unknown extension falls back to the default. Assertions are relational so they survive icon-set changes.
@mydd7
mydd7 requested a review from crynta as a code owner July 29, 2026 06:03
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Vitest coverage for file and folder icon URL generation, including known, compound, filename-based, unknown, and default resolution cases.

Changes

Icon resolution tests

Layer / File(s) Summary
Resolver behavior coverage
src/modules/explorer/lib/iconResolver.test.ts
Adds assertions for inline SVG URLs, deterministic file icons, extension and filename matching, compound extensions, unknown-extension fallback, and folder icons.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses Conventional Commits and accurately describes the new explorer icon resolver tests.
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.

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

🤖 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/modules/explorer/lib/iconResolver.test.ts`:
- Around line 38-42: Strengthen the folderIconUrl tests by asserting both
collapsed and expanded results for the mapped “src” folder, and compare them
against the corresponding collapsed and expanded results for a confirmed unknown
folder name. Keep the assertions specific enough to detect a broken “src”
mapping rather than only checking for an SVG data URL.
🪄 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: e1478e3a-851c-49ed-a6f3-92267a1a4bf4

📥 Commits

Reviewing files that changed from the base of the PR and between 2141d16 and d9d0f80.

📒 Files selected for processing (1)
  • src/modules/explorer/lib/iconResolver.test.ts

Comment on lines +38 to +42
describe("folderIconUrl", () => {
it("returns an inline svg data url", () => {
expect(folderIconUrl("src", false)).toContain("data:image/svg");
});
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Strengthen the folder resolution assertions.

This only proves that the collapsed result is some SVG data URL. Both mapped and fallback paths produce data URLs, so the test can pass if the src mapping breaks, and it never exercises expanded=true. Add assertions for the expanded variant and compare against a confirmed unknown folder name.

🤖 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/modules/explorer/lib/iconResolver.test.ts` around lines 38 - 42,
Strengthen the folderIconUrl tests by asserting both collapsed and expanded
results for the mapped “src” folder, and compare them against the corresponding
collapsed and expanded results for a confirmed unknown folder name. Keep the
assertions specific enough to detect a broken “src” mapping rather than only
checking for an SVG data URL.

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