Skip to content

Conversation

@Milly
Copy link
Contributor

@Milly Milly commented Aug 12, 2025

Add missing tests.

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for import_map.jsonc scenarios, validating plugin load behavior, event emissions, command output, and mapped import resolution.
  • Chores
    • Updated configuration to exclude new test data directory to keep tooling and builds clean.

@coderabbitai
Copy link

coderabbitai bot commented Aug 12, 2025

Walkthrough

Adds JSONC import map test coverage: updates deno.jsonc excludes, introduces test data (helper and plugin using import_map.jsonc), and extends the plugin test to load and verify the JSONC-mapped imports and dispatcher behavior.

Changes

Cohort / File(s) Summary
Config exclude update
deno.jsonc
Added exclude entry for tests/denops/testdata/with_import_map_jsonc/ and adjusted trailing comma.
Plugin tests
denops/@denops-private/plugin_test.ts
Added test constants and a new test step to load a plugin using import_map.jsonc, assert events, echo outputs, and mapped import return value.
Test data: import_map.jsonc
tests/denops/testdata/with_import_map_jsonc/helper.ts, tests/denops/testdata/with_import_map_jsonc/plugin_with_import_map_jsonc.ts
New helper exports greeting and getMessage; new plugin entrypoint registers dispatcher “test”, echoes init, and returns greeting via mapped imports.

Sequence Diagram(s)

sequenceDiagram
  participant Test as Plugin Test
  participant Loader as Plugin Loader
  participant Denops as Denops (mock)
  participant Plugin as Plugin (import_map.jsonc)

  Test->>Loader: load(scriptWithImportMapJsonc)
  Loader->>Denops: emit PluginPre
  Loader->>Plugin: main(denops)
  Plugin->>Denops: dispatcher.test = (…)
  Plugin->>Denops: cmd("Import map jsonc plugin initialized")
  Loader->>Denops: emit PluginPost

  Test->>Denops: call plugin.call("test")
  Denops->>Plugin: dispatcher.test()
  Plugin->>Denops: cmd(getMessage("test-plugin"))
  Plugin-->>Test: return greeting
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • Shougo
  • lambdalisue

Poem

I hop through maps with comments galore,
Importing delights from JSONC’s door.
A whisper of “Hello!” in buffered light,
Dispatcher replies, all tests take flight.
Thump-thump—logs echo, green checks soar,
This bunny approves—let’s merge some more! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b0ee649 and b7eccd6.

📒 Files selected for processing (4)
  • deno.jsonc (1 hunks)
  • denops/@denops-private/plugin_test.ts (2 hunks)
  • tests/denops/testdata/with_import_map_jsonc/helper.ts (1 hunks)
  • tests/denops/testdata/with_import_map_jsonc/plugin_with_import_map_jsonc.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Milly
PR: vim-denops/denops.vim#418
File: tests/denops/runtime/functions/plugin/check_type_test.ts:6-6
Timestamp: 2024-09-14T17:09:30.174Z
Learning: In this project, import paths prefixed with `/denops-testdata/` are defined in `deno.jsonc` via an import map, and these import paths are valid.
📚 Learning: 2024-09-14T17:09:30.174Z
Learnt from: Milly
PR: vim-denops/denops.vim#418
File: tests/denops/runtime/functions/plugin/check_type_test.ts:6-6
Timestamp: 2024-09-14T17:09:30.174Z
Learning: In this project, import paths prefixed with `/denops-testdata/` are defined in `deno.jsonc` via an import map, and these import paths are valid.

Applied to files:

  • tests/denops/testdata/with_import_map_jsonc/helper.ts
  • tests/denops/testdata/with_import_map_jsonc/plugin_with_import_map_jsonc.ts
  • deno.jsonc
  • denops/@denops-private/plugin_test.ts
🧬 Code Graph Analysis (2)
tests/denops/testdata/with_import_map_jsonc/plugin_with_import_map_jsonc.ts (1)
tests/denops/testdata/with_import_map_jsonc/helper.ts (2)
  • getMessage (3-5)
  • greeting (1-1)
denops/@denops-private/plugin_test.ts (2)
tests/denops/testdata/resolve.ts (1)
  • resolveTestDataURL (9-11)
denops/@denops-private/plugin.ts (1)
  • Plugin (19-105)
🔇 Additional comments (5)
deno.jsonc (1)

18-19: Exclude addition for JSONC testdata looks correct

Adding tests/denops/testdata/with_import_map_jsonc/ to exclude prevents deno check from analyzing the JSONC import-map test fixtures. This mirrors the existing with_import_map/ exclusion and keeps CI noise down. LGTM.

tests/denops/testdata/with_import_map_jsonc/helper.ts (1)

1-5: Helper module is clear and minimal

Exports are straightforward and align with the test expectations for message and greeting. No issues spotted.

denops/@denops-private/plugin_test.ts (2)

31-33: New JSONC script fixture reference is consistent

Defining scriptWithImportMapJsonc via resolveTestDataURL mirrors the existing JSON variant and establishes a clear path to the new testdata plugin. Looks good.


552-601: Importer already recognizes and applies import_map.jsonc

All verified—no changes needed:

  • tests/denops/testdata/with_import_map_jsonc/import_map.jsonc includes the @test/ mappings.
  • denops/@denops-private/plugin.ts explicitly checks for "import_map.jsonc" immediately after "import_map.json" (lines 160–161).
  • plugin.ts imports and uses parseJsonc from @std/jsonc.

[test coverage is stable across environments]

tests/denops/testdata/with_import_map_jsonc/plugin_with_import_map_jsonc.ts (1)

1-13: Plugin behavior matches test expectations

  • Registers dispatcher with test handler.
  • Echoes the JSONC-specific message and returns the greeting.
  • Initialization message matches the assertions.

Quoting is consistent with other fixtures and the message contains no single quotes, so it’s safe in this context.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test-importmap-jsonc

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.77%. Comparing base (b0ee649) to head (b7eccd6).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #455   +/-   ##
=======================================
  Coverage   96.77%   96.77%           
=======================================
  Files          11       11           
  Lines         962      962           
  Branches      143      143           
=======================================
  Hits          931      931           
  Misses         28       28           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lambdalisue
Copy link
Member

lambdalisue commented Aug 16, 2025

Well, Import map is JSON so we should not have test for JSONC.

Ah, I didn't realized that I've added import_map.jsonc.

@lambdalisue lambdalisue merged commit 1acc76c into main Aug 24, 2025
14 checks passed
@lambdalisue lambdalisue deleted the test-importmap-jsonc branch August 24, 2025 06:41
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