8000 [#402] Fixed path trait failing on `<front>`. by AlexSkrypnyk · Pull Request #403 · drevops/behat-steps · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[#402] Fixed path trait failing on <front>. #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025

Conversation

AlexSkrypnyk
Copy link
Member
@AlexSkrypnyk AlexSkrypnyk commented May 16, 2025

closes #402

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of the root path ("/") and "" so they are treated as equivalent in path assertions.
    • Updated error messages to display the original input path for clearer feedback.
  • Tests

    • Enhanced and expanded test coverage for path assertions, including new scenarios for both matching and non-matching cases with "/", "", and related edge cases.
  • Documentation

    • Updated examples to include the root path ("/") as a valid option for path assertion steps.

Copy link
coderabbitai bot commented May 16, 2025

"""

Walkthrough

The changes update path assertion logic in PathTrait to treat "/" and "" as equivalent in both pathAssertCurrent and pathAssertNotCurrent. Test coverage in the Behat feature file is expanded and refactored using scenario outlines, adding explicit checks for these equivalences and improving error message accuracy. Documentation examples now include "/" alongside "".

Changes

File(s) Change Summary
src/PathTrait.php Enhanced path normalization to treat "/" and "" as equivalent in assertion methods; updated comments and error messages.
tests/behat/features/path.feature Refactored tests to use scenario outlines; added comprehensive cases for "/", "", and error reporting.
STEPS.md Updated documentation examples to include "/" as a valid path for assertion steps alongside "".

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Correct handling of <front> in pathAssertCurrent (#402) Path normalization now treats "/" and "" equivalently in assertions.

Poem

A path is a path, whether "/" or "",
Now both are the same, no need to confront.
The tests are more thorough, the logic precise,
Assertion confusion? No longer a vice!
🐇✨ Paths united, all bugs in flight!
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 2fc386d and 638b0fd.

📒 Files selected for processing (3)
  • STEPS.md (2 hunks)
  • src/PathTrait.php (4 hunks)
  • tests/behat/features/path.feature (3 hunks)
🔇 Additional comments (8)
STEPS.md (2)

1043-1043: Documentation updated to include root path example

Good addition to include the root path "/" in the documentation examples, which matches the functionality changes in the implementation.


1059-1059: Documentation updated to include root path example for negative assertion

Good addition to include the root path "/" in the negative assertion examples as well, maintaining consistency with the positive assertion documentation.

src/PathTrait.php (3)

41-42: Improved path normalization with concise logic

The path normalization logic is now more concise and readable, clearly treating both '/' and '' as equivalent. This is a good improvement over the previous implementation.


75-76: Consistent normalization in path assertion methods

Good consistency in implementing the same normalization logic in both path assertion methods. This ensures uniform handling of paths across positive and negative assertions.


22-22: Updated documentation examples to match implementation

Documentation examples now properly reflect the implementation's handling of the root path, maintaining consistency between code and documentation.

Also applies to: 56-56

tests/behat/features/path.feature (3)

7-18: Improved test structure with scenario outlines

Excellent refactoring of the tests to use scenario outlines with examples. This approach is more maintainable and provides better coverage of different path combinations, including the equivalence between "/" and "".


49-78: Added comprehensive tests for failure cases with special paths

Great addition of specific failure test cases for "" and "/" paths. These tests ensure that appropriate error messages are generated when path assertions fail with these special paths.


94-123: Complete test coverage for negative assertion failures

Good addition of test cases for negative assertions with special paths. The comprehensive test suite now covers all edge cases for both positive and negative path assertions.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc5ed0d and 512633f.

📒 Files selected for processing (2)
  • src/PathTrait.php (4 hunks)
  • tests/behat/features/path.feature (3 hunks)
🔇 Additional comments (6)
src/PathTrait.php (2)

47-49: The error message is correct and helpful.

The error message preserves the original input path rather than the normalized one, which is user-friendly and provides clear context for debugging.


84-86: Good error handling preserves the original path.

The error message correctly uses the original $path parameter rather than the normalized path, which makes the error messages more user-friendly and consistent with how the path was specified.

tests/behat/features/path.feature (4)

7-18: Great refactoring to scenario outlines.

Converting individual test cases to a parameterized scenario outline with examples makes the tests more comprehensive and maintainable. The examples table thoroughly tests the equivalence between / and <front> with various combinations.


21-32: Comprehensive test coverage for negative assertions.

The negative path assertion tests cover all important combinations, ensuring that paths that shouldn't match don't match. This is essential for validating the equivalence logic between / and <front>.


49-78: Good addition of specific failure test cases.

These additional test cases for failure scenarios are important to verify that error messages correctly reflect the expected path in its original form, not the normalized form. This ensures that error messages are user-friendly and consistent with how paths were specified.


94-123: Complete test coverage with negative assertion failures.

Adding specific test cases for negative assertion failures with both / and <front> ensures comprehensive coverage of all edge cases. These tests validate that error messages display the original path as specified rather than its normalized form.

8000

@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/fix-pathtrait branch from 512633f to 2fc386d Compare May 16, 2025 23:22
@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/fix-pathtrait branch from 2fc386d to 638b0fd Compare May 16, 2025 23:38
Copy link
codecov bot commented May 16, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.25%. Comparing base (fc5ed0d) to head (638b0fd).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/PathTrait.php 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #403      +/-   ##
==========================================
+ Coverage   80.23%   80.25%   +0.02%     
==========================================
  Files          29       29              
  Lines        1963     1965       +2     
==========================================
+ Hits         1575     1577       +2     
  Misses        388      388              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AlexSkrypnyk AlexSkrypnyk merged commit beef0e3 into main May 16, 2025
5 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/fix-pathtrait branch May 16, 2025 23:45
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.

pathAssertCurrent does not correctly handle <front>
1 participant
0