Skip to content

test(chore): convert mcp configure tests to unit#1398

Open
filmaj wants to merge 7 commits into
mainfrom
mcp-config-tests
Open

test(chore): convert mcp configure tests to unit#1398
filmaj wants to merge 7 commits into
mainfrom
mcp-config-tests

Conversation

@filmaj

@filmaj filmaj commented Jun 26, 2026

Copy link
Copy Markdown
Member

Description

Converting more integration tests to unit. This time for the mcp configure code path.

  • Added a unit test for the mcp configure Command
  • Many of the 'editor' test cases already existed as unit tests in src/actions/mcp/__tests__/editorConfigs.test.ts
  • Any integration tests missing from setupMCP unit tests were added.

Note

Low Risk
Production changes are limited to configure command control flow and error reporting; MCP setup behavior is unchanged aside from tests and a trivial fs import.

Overview
Replaces the large mcp configure integration suite with narrow unit tests that mock ensureAuthenticated and setupMCP, and extends setupMCP / detectAvailableEditors coverage for scenarios that used to live in integration tests (no editors, all configured, token creation failure, parse/skip behavior).

ConfigureMcpCommand now picks auto vs prompt via this.isUnattended() instead of isInteractive(), and reports auth/setup failures through this.output.error with return rather than this.error. mockSanityCommand gains a telemetry stub so configure tests can run run() without real tracing.

detectAvailableEditors only switches to a named readFile import (no behavior change intended).

Reviewed by Cursor Bugbot for commit e40dc40. Bugbot is set up for automated code reviews on this repo. Configure here.

@filmaj filmaj self-assigned this Jun 26, 2026
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (3778774d)

@sanity/cli

Metric Value vs main (3778774)
Internal (raw) 2.7 KB -
Internal (gzip) 1.0 KB -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 870ms +9ms, +1.1%

bin:sanity

Metric Value vs main (3778774)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 2.20s -23ms, -1.0%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-core

Compared against main (3778774d)

Metric Value vs main (3778774)
Internal (raw) 106.7 KB -
Internal (gzip) 26.7 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 766ms +3ms, +0.4%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — create-sanity

Compared against main (3778774d)

Metric Value vs main (3778774)
Internal (raw) 908 B -
Internal (gzip) 483 B -
Bundled (raw) 931 B -
Bundled (gzip) 491 B -
Import time ❌ ChildProcess denied: node -
Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli/src/actions/mcp/detectAvailableEditors.ts 90.7% (+ 7.0%)
packages/@sanity/cli/src/commands/mcp/configure.ts 95.0% (+ 5.0%)

Comparing 2 changed files against main @ 3778774db6facea7d166ba275e479e1de4e1aecc

Overall Coverage

Metric Coverage
Statements 74.1% (- 0.2%)
Branches 64.0% (- 0.1%)
Functions 68.5% (- 0.2%)
Lines 74.7% (- 0.2%)

@filmaj filmaj force-pushed the mcp-config-tests branch from c8e57a9 to c377e82 Compare June 26, 2026 20:37
@filmaj filmaj marked this pull request as ready for review June 27, 2026 01:14
@filmaj filmaj requested a review from a team as a code owner June 27, 2026 01:14
@filmaj filmaj requested a review from a team June 27, 2026 01:15
Comment on lines -45 to +47
mode: isInteractive() ? 'prompt' : 'auto',
mode: this.isUnattended() ? 'auto' : 'prompt',

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.

I think these are slightly different. Is interactive means there's a tty available and is unattended means the --yes flag was used

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