-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Chore: Add cookies test #10352
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
Chore: Add cookies test #10352
Conversation
📝 WalkthroughWalkthrough
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 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 unit 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
There was a problem hiding this 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/resources/sites/astro/src/pages/cookies.js (1)
2-3
: Set an explicit content-type for predictable client behaviorReturning a Response without a content-type relies on client heuristics. Make it explicit to avoid future surprises and to aid debugging.
- return new Response(sessionId); + return new Response(sessionId, { + headers: { + 'content-type': 'text/plain; charset=utf-8', + }, + });tests/e2e/Services/Sites/SitesCustomServerTest.php (3)
2701-2701
: Reduce potential flakiness with Retry attributeSimilar E2E tests use Retry, which helps when infra (proxy/runtimes) is momentarily slow. Recommend adding it here as well.
- public function testCookieHeader() + #[Retry(count: 3)] + public function testCookieHeader()
2726-2736
: Broaden assertions: multi-cookie parsing and missing-cookie fallbackTwo quick follow-ups make this test more robust:
- Ensure the target cookie is correctly extracted when multiple cookies are present.
- Verify the fallback message when the cookie is absent (matches the handler).
$response = $proxyClient->call(Client::METHOD_GET, '/cookies', [ 'cookie' => 'custom-session-id=abcd123' ]); $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals("abcd123", $response['body']); + // Multiple cookies: ensure correct extraction + $response = $proxyClient->call(Client::METHOD_GET, '/cookies', [ + 'cookie' => 'foo=bar; custom-session-id=abcd123; baz=qux' + ]); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals("abcd123", $response['body']); + + // Missing cookie: verify fallback behavior from the route handler + $response = $proxyClient->call(Client::METHOD_GET, '/cookies', [ + 'cookie' => 'foo=bar' + ]); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals("Custom session ID missing", $response['body']);
2717-2729
: Minor: reuse existing $domain instead of re-queryingYou already get $domain from setupSiteDomain($siteId). Unless you specifically need the value from getSiteDomain(), you can reuse the existing variable and avoid the extra call.
📜 Review details
Configuration used: .coderabbit.yaml
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.
📒 Files selected for processing (2)
tests/e2e/Services/Sites/SitesCustomServerTest.php
(1 hunks)tests/resources/sites/astro/src/pages/cookies.js
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/e2e/Services/Sites/SitesCustomServerTest.php (2)
tests/e2e/Services/Sites/SitesBase.php (6)
setupSite
(21-34)setupSiteDomain
(345-363)setupDeployment
(36-83)packageSite
(239-251)getSiteDomain
(365-386)cleanupSite
(85-94)tests/e2e/Client.php (2)
Client
(8-328)setEndpoint
(126-131)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: scan
🔇 Additional comments (2)
tests/resources/sites/astro/src/pages/cookies.js (1)
1-4
: LGTM: endpoint correctly echoes the cookie valueThe handler uses Astro’s cookies API and returns the expected plain-text body, matching the E2E test expectations.
tests/e2e/Services/Sites/SitesCustomServerTest.php (1)
2701-2738
: LGTM: solid E2E coverage that validates cookie forwardingThe test provisions an Astro SSR site, deploys it, sends a Cookie header, and asserts the echoed value. Flow and assertions look good, and cleanup is handled.
✨ Benchmark results
⚡ Benchmark Comparison
|
What does this PR do?
Ensures behaviour of cookies for sites
Test Plan
new test
Related PRs and Issues
Checklist