Skip to content

Conversation

@Meldiron
Copy link
Contributor

@Meldiron Meldiron commented Aug 19, 2025

Summary by CodeRabbit

  • Tests
    • Added end-to-end coverage for handling double slashes in URL paths across multiple patterns.
    • Verifies consistent 200 OK responses and expected bodies for leading and in-path double slashes.
    • Improves confidence in URL normalization and prevents regressions.
    • No changes to application functionality; test coverage only.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

Adds a new end-to-end test method testDoubleSlash() in tests/e2e/BaseTest.php to validate URL double-slash path normalization by issuing five GET requests and asserting status codes and response bodies.

Changes

Cohort / File(s) Summary
E2E Test Additions
tests/e2e/BaseTest.php
Added testDoubleSlash() issuing 5 GETs to paths with double slashes. Asserts 200 for all; expects "Hello World!" for // and //path-404; expects empty body for //value/123, /value//123, and //value//123.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Tester
  participant TestSuite as BaseTest::testDoubleSlash()
  participant Server as HTTP Server

  Tester->>TestSuite: Run testDoubleSlash()
  loop Double-slash paths
    Note over TestSuite: Paths: //, //path-404,<br/>//value/123, /value//123, //value//123
    TestSuite->>Server: GET {path}
    Server-->>TestSuite: 200 OK + Body
    TestSuite-->>Tester: Assert status/body per case
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A bunny bounds through slashes twain,
Hop-hop, it tests each winding lane.
“Hello World!” the roots reply,
While value paths stay hush and shy.
Green lights gleam across the run—
Double lines, and all is done. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore-add-double-slash-tests

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
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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
Contributor

@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: 0

🧹 Nitpick comments (4)
tests/e2e/BaseTest.php (4)

97-97: Make “empty body” assertions resilient to incidental whitespace

In a few environments/middlewares, bodies may include a trailing newline. Trimming before asserting emptiness will reduce flakiness without weakening the check.

Apply this diff:

-        $this->assertEmpty($response['body']);
+        $this->assertEmpty(trim($response['body']));

Repeat the same replacement for all three empty-body assertions in this method.

Also applies to: 101-101, 105-105


86-106: Reduce duplication with a table-driven loop

You can make this test more compact and maintainable by iterating over cases. It also lets you attach per-path failure messages easily.

Apply this diff to the method body:

-    {
-        $response = $this->client->call(Client::METHOD_GET, '//');
-        $this->assertEquals(200, $response['headers']['status-code']);
-        $this->assertEquals('Hello World!', $response['body']);
-
-        $response = $this->client->call(Client::METHOD_GET, '//path-404');
-        $this->assertEquals(200, $response['headers']['status-code']);
-        $this->assertEquals('Hello World!', $response['body']);
-
-        $response = $this->client->call(Client::METHOD_GET, '//value/123');
-        $this->assertEquals(200, $response['headers']['status-code']);
-        $this->assertEmpty($response['body']);
-
-        $response = $this->client->call(Client::METHOD_GET, '/value//123');
-        $this->assertEquals(200, $response['headers']['status-code']);
-        $this->assertEmpty($response['body']);
-
-        $response = $this->client->call(Client::METHOD_GET, '//value//123');
-        $this->assertEquals(200, $response['headers']['status-code']);
-        $this->assertEmpty($response['body']);
-    }
+    {
+        $cases = [
+            ['//', 200, 'Hello World!'],
+            ['//path-404', 200, 'Hello World!'],
+            ['//value/123', 200, ''],
+            ['/value//123', 200, ''],
+            ['//value//123', 200, ''],
+        ];
+
+        foreach ($cases as [$path, $expectedStatus, $expectedBody]) {
+            $response = $this->client->call(Client::METHOD_GET, $path);
+            $this->assertEquals($expectedStatus, $response['headers']['status-code'], "Unexpected status for path {$path}");
+            if ($expectedBody === '') {
+                $this->assertEmpty(trim($response['body']), "Expected empty body for path {$path}, got: {$response['body']}");
+            } else {
+                $this->assertSame($expectedBody, $response['body'], "Unexpected body for path {$path}");
+            }
+        }
+    }

91-94: Confirm expected 200 for path “//path-404”

This intentionally diverges from testNotFound(), which asserts 404 for unknown paths. Given Client::call() enables CURLOPT_FOLLOWLOCATION, a 200 here could be the result of a redirect to “/” rather than router-level normalization. If the goal is specifically to validate normalization vs. redirect behavior, we may want to capture/inspect redirect info in the client in a follow-up (e.g., an option to disable following redirects or returning redirect count/effective URL).

Please confirm that returning 200 with “Hello World!” for “//path-404” is the desired behavior across supported runtimes/web servers.

If you want, I can draft a follow-up change adding an optional “followRedirects” flag (default true) to Client::call() so tests can assert redirect semantics explicitly.


85-85: Name nit: clarify intent

Optional: rename to testDoubleSlashNormalization() to be more explicit about what’s being validated.

-    public function testDoubleSlash()
+    public function testDoubleSlashNormalization()
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8bbe56a and 9d18ad2.

📒 Files selected for processing (1)
  • tests/e2e/BaseTest.php (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/e2e/BaseTest.php (1)
tests/e2e/Client.php (2)
  • call (55-107)
  • Client (7-108)
🔇 Additional comments (1)
tests/e2e/BaseTest.php (1)

85-106: LGTM: Solid addition of double-slash E2E coverage

Nice, focused test expanding coverage for path normalization edge cases. Matches the PR objective and keeps assertions clear.

@Meldiron
Copy link
Contributor Author

Tests failing and master isnt used anyway right now, skipping for now

@Meldiron Meldiron closed this Aug 19, 2025
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