Skip to content

test: align file-preview tests with #524 and #526#527

Merged
wonderwhy-er merged 2 commits into
mainfrom
test/align-file-preview-tests-524-526
Jun 26, 2026
Merged

test: align file-preview tests with #524 and #526#527
wonderwhy-er merged 2 commits into
mainfrom
test/align-file-preview-tests-524-526

Conversation

@wonderwhy-er

@wonderwhy-er wonderwhy-er commented Jun 26, 2026

Copy link
Copy Markdown
Owner

What

Fixes the two failing tests in the suite (test-file-handlers.js, test-markdown-preview.js). Both were stale tests trailing the two most recent merges — not MCP regressions.

Why they failed

test-file-handlers.js (Test 9)#526 (refactor(read_file): carry image base64 once) deliberately removed structuredContent.imageData and now carries the image base64 only in structuredContent.content. The test still asserted imageData was a string, so it got undefined.

test-markdown-preview.js (Test 9)#524 (feat(telemetry): call_origin ui vs llm) appends origin: 'ui' to the controller's read_file call. The mock asserted exact args via deepStrictEqual({ path, offset, length }); the extra key made it throw, loadFullDocument's catch swallowed it, and the full-document reload silently aborted — leaving the baseline at the truncated # Intro. The same staleness was hiding behind it in Test 11 (testFailedSaveResyncsEditBaseline, the runner stops at the first failure).

Changes

  • Image/SVG assertions now read structuredContent.content instead of the removed imageData.
  • Added origin: 'ui' to the expected read_file args in Test 9 and Test 11.

No source changes.

Verification

Full suite green locally: 42/42 passed.

Summary by CodeRabbit

  • Tests
    • Updated preview-related tests to match the latest file-handling and markdown preview behavior.
    • Updated structured preview assertions for images and SVGs, ensuring the returned content payload includes a non-empty base64 string.
    • Adjusted file-reading call expectations in markdown preview tests to include the new request parameter format.
  • Release / Versioning
    • Bumped version to 0.2.43 across the app configuration and source version.

Two tests trailed the latest contract changes:

- test-file-handlers.js: #526 dropped structuredContent.imageData and
  carries the image base64 only in structuredContent.content. Update the
  image/SVG assertions to read content instead of the removed field.
- test-markdown-preview.js: #524 tags read_file calls with origin:'ui'.
  The Test 9 and Test 11 mocks asserted exact read_file args via
  deepStrictEqual; add origin:'ui' so the full-document reload and the
  failed-save resync paths match again.

No source changes; both were stale tests, not regressions.
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3475d0f9-f69c-462b-bc5b-9d6220306dc4

📥 Commits

Reviewing files that changed from the base of the PR and between 592d1d6 and 1da29c7.

📒 Files selected for processing (3)
  • package.json
  • server.json
  • src/version.ts

📝 Walkthrough

Walkthrough

Tests and version metadata were updated for the new release. Preview assertions now expect structuredContent.content and origin: 'ui', and version fields were bumped to 0.2.43.

Changes

read_file contract updates and release version bump

Layer / File(s) Summary
Structured preview and tool-call assertions
test/test-file-handlers.js, test/test-markdown-preview.js
Image and SVG preview tests assert structuredContent.content as non-empty base64, and markdown preview mocks require origin: 'ui' in read_file arguments.
Version metadata
package.json, server.json, src/version.ts
Package, server, and exported version values were bumped from 0.2.42 to 0.2.43.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested labels

size:L

Suggested reviewers

  • dmitry-ottic-ai
  • edgarsskore

Poem

A bunny hopped through tests at dawn,
With base64 soft as clover drawn.
ui rode in on a leafy breeze,
And SVGs sang with quiet ease.
🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 accurately reflects that file-preview tests were updated to match prior contract changes.
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/align-file-preview-tests-524-526

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.

🧹 Nitpick comments (1)
test/test-file-handlers.js (1)

336-337: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the structured preview bytes match the image content bytes.

These checks now only prove structuredContent.content is present. Since the handler builds both fields from the same base64 payload, asserting equality with imageContentItem.data / svgContentItem.data would catch contract drift instead of only emptiness.

Diff to tighten the contract assertion
   assert.strictEqual(typeof imageResult.structuredContent.content, 'string', 'Image structured payload should carry base64 in content');
   assert.ok(imageResult.structuredContent.content.length > 0, 'Image structured payload should include non-empty content');
+  assert.strictEqual(imageResult.structuredContent.content, imageContentItem.data, 'Image structured payload should mirror the image content bytes');
@@
   assert.strictEqual(typeof svgResult.structuredContent.content, 'string', 'SVG structured payload should carry base64 in content');
   assert.ok(svgResult.structuredContent.content.length > 0, 'SVG structured payload should include non-empty content');
+  assert.strictEqual(svgResult.structuredContent.content, svgContentItem.data, 'SVG structured payload should mirror the image content bytes');

Also applies to: 351-352

🤖 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 `@test/test-file-handlers.js` around lines 336 - 337, The current assertions in
the image/SVG handler tests only verify that structuredContent.content exists
and is non-empty, but they do not confirm it matches the source payload. Update
the relevant checks in the image and SVG test cases to compare
structuredContent.content against the corresponding content item data
(imageContentItem.data and svgContentItem.data) so the test enforces the
intended base64 contract in the handler output.
🤖 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.

Nitpick comments:
In `@test/test-file-handlers.js`:
- Around line 336-337: The current assertions in the image/SVG handler tests
only verify that structuredContent.content exists and is non-empty, but they do
not confirm it matches the source payload. Update the relevant checks in the
image and SVG test cases to compare structuredContent.content against the
corresponding content item data (imageContentItem.data and svgContentItem.data)
so the test enforces the intended base64 contract in the handler output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 27e42643-d653-44f7-a77a-53e1a451008f

📥 Commits

Reviewing files that changed from the base of the PR and between 9efa40b and 592d1d6.

📒 Files selected for processing (2)
  • test/test-file-handlers.js
  • test/test-markdown-preview.js

Automated release commit with version bump from 0.2.42 to 0.2.43
@wonderwhy-er wonderwhy-er merged commit 9cd9cb4 into main Jun 26, 2026
1 check passed
@wonderwhy-er wonderwhy-er deleted the test/align-file-preview-tests-524-526 branch June 26, 2026 14:15
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