Skip to content

Fix/url mocking#75

Merged
kevinccbsg merged 7 commits into
mainfrom
fix/url-mocking
Nov 1, 2025
Merged

Fix/url mocking#75
kevinccbsg merged 7 commits into
mainfrom
fix/url-mocking

Conversation

@kevinccbsg

Copy link
Copy Markdown
Member

This pull request introduces improvements to mock request rule handling and UI enhancements for the TWD testing tool. The main changes include more accurate URL matching for mock rules (especially for file extensions), a new sidebar button for viewing mock rule status, new icon components, and updates to tests and documentation.

Mock Rule Matching Enhancements:

  • Improved the logic in findRule to distinguish between URLs that are files (with extensions) and general endpoints, preventing accidental rule matches for file URLs unless the rule explicitly specifies a file extension. This logic is now shared between the CLI and mock service worker scripts. [1] [2] [3]
  • Added new tests to ensure correct rule matching behavior for files and endpoints.

UI Improvements:

  • Added a new MockRulesButton component to the sidebar, displaying the count of triggered and total mock rules, and allowing users to view rule details in the console. [1] [2] [3]
  • Updated the sidebar layout to group the "Run All" button and the new mock rules button in a sticky header for better usability. [1] [2] [3] [4]

Icon Components:

  • Added a new MockRequestIcon and corresponding test coverage. [1] [2] [3]

Test and Documentation Updates:

  • Added tests for the new MockRulesButton component.
  • Updated the documentation and example tests to reflect changes in mock rule clearing and sidebar usage. [1] [2] [3] [4] [5]

Summary of Most Important Changes:

Mock rule matching logic:

  • Improved URL matching in findRule and mock service workers to handle file extensions correctly, preventing endpoint rules from matching file URLs unless explicitly configured. [1] [2] [3]
  • Added comprehensive tests for new matching logic, ensuring robust and predictable behavior.

Sidebar and UI enhancements:

  • Introduced MockRulesButton to the sidebar for viewing mock rule usage and details, with a new icon and improved sticky header layout. [1] [2] [3] [4] [5]
  • Added MockRequestIcon and its test to visually represent mock rules in the UI. [1] [2] [3]

Test and documentation maintenance:

  • Updated and added tests for new UI components and improved mock rule clearing in example tests. [1] [2] [3] [4] [5]
  • Minor documentation updates to reflect tutorial and example changes.

This closes #72

@kevinccbsg kevinccbsg merged commit 268bd4b into main Nov 1, 2025
4 checks passed
@kevinccbsg kevinccbsg deleted the fix/url-mocking branch November 1, 2025 13:44
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.

[bug] url mocking files

1 participant