refactor(mock): tighten strict schema name recovery (#3574 follow-up) - #3578
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR replaces single-regex alias scraping with multiple targeted regexes plus an alias-to-base-type helper, updates the collector to aggregate matches from all patterns, adds a unit test ensuring both ChangesStrict-mock schema-type name extraction improvements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Match MockWithNullableOverrides alias and return-type patterns only. Document regex coupling; keep Widget and WidgetMock when both appear. Co-authored-by: Cursor <cursoragent@cursor.com>
50c00f6 to
6407ce2
Compare
|
Verified locally — LGTM (non-blocking notes below) ✅ What I checked:
Non-blocking — the Widget/WidgetMock co-exist case still doesn't compile end-to-end: The collection fix works (both names are now kept), but when schemas To be clear, this is not a regression — I ran the same spec against master and it also fails ( Order:
type: object
properties:
widgets:
type: array
items:
$ref: '#/components/schemas/Widget'
widgetMocks:
type: array
items:
$ref: '#/components/schemas/WidgetMock'Nit: the |
Follow-up to #3575 (closes #3574).
#3575 landed the tags-split strict mock type fix; this PR addresses two review nits from that work:
Changes
collectStrictMockSchemaTypeNamesFromImplementationnow notes it reverse-parses emitted factory syntax and that the robust long-term fix is threading schema names from array-item / faker getters at generation time.MockWithNullableOverridesfirst type param (unchanged)getStrictMockTypeName): TenantInfoDtoMock[]This fixes the residual edge case where both
WidgetandWidgetMockstrict mocks in the same file would dropWidget, while keepingissue-3525-widget-mock-strictsnapshot-stable.Test plan
vitest run packages/mock/src/mock-types.test.tsWidgetandWidgetMockcollected when presentissue-3525-widget-mock-strict/issue-3574fixtures unchangedRelates to #3574
Summary by CodeRabbit
Tests
Refactor
Documentation