Skip to content

Refine home connector router tests - #102

Merged
kentcdodds merged 5 commits into
mainfrom
cursor/issue-71-test-signal
Mar 30, 2026
Merged

kentcdodds merged 5 commits into
mainfrom
cursor/issue-71-test-signal

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Mar 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • replace brittle UI copy/absence assertions with behavior-focused checks in session refresh, UI utils, saved UI hosting, OAuth guide, and skill embed tests
  • parse runtime bootstrap/import map content to validate structured behavior instead of raw HTML string fragments
  • verify denormalized skill embed content using stable line structure rather than incidental wording
  • update testing guidelines to discourage string-contains-only assertions on incidental copy
  • remove description-substring assertions in capability tests, replacing them with structured field checks

Testing

  • npm run test -- packages/worker/client/app-session-refresh.node.test.ts packages/worker/client/mcp-apps/kody-ui-utils.node.test.ts packages/worker/src/app/saved-ui-hosted-html.node.test.ts packages/worker/src/mcp/capabilities/coding/generated-ui-oauth-guide.node.test.ts packages/worker/src/mcp/skills/skill-embed-and-flags.node.test.ts
  • npm run test -- packages/worker/src/mcp/capabilities/meta/meta-list-capabilities.node.test.ts packages/worker/src/mcp/capabilities/capability-search.workers.test.ts
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Documentation

    • Updated testing guidelines to prioritize behavior-focused assertions and structured output validation over content matching in free-form text.
  • Tests

    • Refactored test assertions across multiple modules to use structured parsing (regex, JSON, line-based decomposition) instead of substring matching, improving test robustness and clarity.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented Mar 30, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 201af1fc-49ad-4d1d-8969-e772fd7b560b

📥 Commits

Reviewing files that changed from the base of the PR and between 9979081 and ccedf51.

📒 Files selected for processing (9)
  • docs/agents/testing-principles.md
  • packages/home-connector/app/router.node.test.ts
  • packages/worker/client/app-session-refresh.node.test.ts
  • packages/worker/client/mcp-apps/kody-ui-utils.node.test.ts
  • packages/worker/src/app/saved-ui-hosted-html.node.test.ts
  • packages/worker/src/mcp/capabilities/capability-search.workers.test.ts
  • packages/worker/src/mcp/capabilities/coding/generated-ui-oauth-guide.node.test.ts
  • packages/worker/src/mcp/capabilities/meta/meta-list-capabilities.node.test.ts
  • packages/worker/src/mcp/skills/skill-embed-and-flags.node.test.ts
💤 Files with no reviewable changes (1)
  • packages/worker/client/app-session-refresh.node.test.ts

📝 Walkthrough

Walkthrough

Documentation update establishes testing guidance against incidental string assertions, alongside test assertion refactoring across multiple packages that replace exact string matching with structured data validation, behavior-focused assertions, and parsed output verification.

Changes

Cohort / File(s) Summary
Documentation
docs/agents/testing-principles.md
Added guideline instructing to avoid assertions checking string blobs for incidental copy; emphasizes behavior-focused assertions on structured output and stable public contracts.
Home Connector Tests
packages/home-connector/app/router.node.test.ts
Renamed home route test to validate conditional rendering of snapshot link based on connectorId state; removed assertions for worker connection status/setup links and updated Roku diagnostics fixture (changed endpoints to roku.local, made deviceInfoLookups empty, removed IP/port/serial assertions).
Worker Client Tests
packages/worker/client/app-session-refresh.node.test.ts, packages/worker/client/mcp-apps/kody-ui-utils.node.test.ts
Removed negative assertions checking for absent login/signup elements; refactored HTML injection and URL absolutization assertions from substring matching to line-based decomposition and specific value equality; restructured codemode execution test using exact line assertions instead of toContain.
Worker App Tests
packages/worker/src/app/saved-ui-hosted-html.node.test.ts
Converted HTML rendering assertions from exact string containment to regex/JSON-structure-based validation; now extracts and parses stylesheet URL, runtime script URL, import map JSON, and window.__kodyGeneratedUiBootstrap payload to assert specific resolved values and mode === "hosted".
Worker MCP Tests
packages/worker/src/mcp/capabilities/...
Updated multiple capability tests to replace substring assertions with structured validation: keyword arrays instead of description text, exact outputFields equality, phrase presence checks, and removal of negative assertions (e.g., removing checks for absence of specific code patterns).
Worker Skill Tests
packages/worker/src/mcp/skills/skill-embed-and-flags.node.test.ts
Refactored embed text assertions from substring matching to line-structure decomposition; validates expected exact lines and locates capability metadata sections to assert specific structured entries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 We hop away from fuzzy strings,
With structured checks and parsing wings,
Line-by-line we now assert,
No incidental copy hurt,
True behavior shines—hooray! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Refine home connector router tests' accurately describes the primary change—improving home connector router tests—which aligns with the main objective shown in the file summaries and PR description.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 cursor/issue-71-test-signal

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 and usage tips.

cursoragent and others added 3 commits March 30, 2026 13:36
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kentcdodds
kentcdodds marked this pull request as ready for review March 30, 2026 13:49
@github-actions

github-actions Bot commented Mar 30, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-102.kentcdodds.workers.dev

Worker: kody-pr-102
D1: kody-pr-102-db
KV: kody-pr-102-oauth-kv

Mocks:

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Negative snapshot assertion is vacuously true
    • Updated the negative assertion to check for the snapshot link text so it fails if the link renders when the connector ID is empty.

Comment thread packages/home-connector/app/router.node.test.ts Outdated
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
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