Support intra-segment wildcards in mock path matching#21
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds intra-segment wildcard support to mock path matching (using path.Match per segment), introduces a path-specificity tiebreaker so exact paths beat wildcard paths when match scores tie, and—beyond what the description states—adds a new "proxy" on_end mode for sequence mocks that lets requests fall through to the real backend after the sequence is exhausted, with matching frontend type, sequence-display, sidebar, and editor changes.
Changes:
- Per-segment wildcard matching via
path.Match, plus apathSpecificitytiebreaker infindBestLocked. - New
"proxy"sequence end-mode wired through backend resolution and frontend display/editor. - Updated mock-editor placeholder and added Go tests for path matching, exact-vs-wildcard preference, and proxy fall-through.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mock.go | Adds pathpkg.Match-based segment matching, pathSpecificity tiebreaker, and "proxy" OnEnd handling that returns nil after exhaustion. |
| mock_test.go | New tests for intra-segment wildcards, exact-over-wildcard preference, and proxy sequence fall-through. |
| frontend/src/types.ts | Extends Sequence.on_end union with 'proxy'. |
| frontend/src/sequence.ts | Treats 'proxy' like 'reset' for cursor advance and adds proxyNext label/tooltip. |
| frontend/src/components/Sidebar.tsx | Adds tooltip variant and updates comment for 'proxy' sequence mode. |
| frontend/src/components/MockEditorModal.tsx | Adds "Proxy after end" button, exhausted-state messaging, and updates path placeholder to /tickets-bff/tkt_*. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Previously, path matching only supported whole-segment wildcards (`*`), so a pattern like `/tickets-bff/tkt_*` would not match `/tickets-bff/tkt_8WNAsd8wsRnf0xC0m`. Switch each segment comparison to use `path.Match` so that patterns like `tkt_*` are resolved as glob expressions within a single segment. When multiple mocks match the same request with equal specificity, prefer the one whose path has fewer wildcard characters (via `pathSpecificity`), ensuring an exact-path mock always wins over a wildcard-path mock. Update the path placeholder in the mock editor to reflect the new syntax. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ebc717e to
a580396
Compare
Dustec
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
matchPathto usepath.Matchper segment, enabling patterns like/tickets-bff/tkt_*to match paths where the wildcard appears within a segment (not just as a whole-segment*).pathSpecificityas a tiebreaker infindBestLocked: when multiple mocks score equally, the one with fewer wildcard characters wins — so an exact-path mock always takes priority over a wildcard-path mock./tickets-bff/tkt_*to surface this new capability to users.Test plan
TestMatchPathSupportsWildcardWithinSegment— covers exact match, whole-segment*, prefix wildcard (tkt_*), non-matching prefix, and mismatched segment count.TestFindPrefersExactPathOverWildcardPath— verifies that when both/tickets-bff/tkt_*and/tickets-bff/tkt_8WNAsd8wsRnf0xC0mare registered, the exact mock wins for a matching request.go test ./...to confirm all tests pass./tickets-bff/tkt_*.🤖 Generated with Claude Code