Repository navigation
test(avatars): screenshot a local fixture instead of example.com - #13964
Conversation
example.com was redeployed with a new design, so the pixel comparison against its reference image broke. Screenshot tests now load a static page served inside the e2e stack: the API container resolves screenshot.webapp.com to a public address through the fixture resolver, so the SSRF checks still pass, while the browser reaches the nginx fixture through a network alias the API container cannot see.
🟢 Tier S · Ready to merge
This change replaces live websites with a locally served page for avatar screenshot tests. It adds split-DNS and Docker networking for the fixture, updates the REST and GraphQL test URLs, and changes the reference screenshot used for pixel comparison.
📂 Walkthrough · 6
Reviewed |
|
| 'x-appwrite-project' => $this->getProject()['$id'], | ||
| ], [ | ||
| 'url' => 'https://example.com', | ||
| 'url' => self::SCREENSHOT_URL, |
There was a problem hiding this comment.
CI browser endpoint remains invalid
The Avatars CI job starts Appwrite with _APP_BROWSER_HOST set to http://invalid-browser/v1 and runs this screenshot test. The API sends the request to that browser endpoint before it can load the new page URL, so changing the URL does not repair the job. The GraphQL screenshot tests in the same job are affected too.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Services/Avatars/AvatarsBase.php
Line: 1359
Comment:
**CI browser endpoint remains invalid**
The Avatars CI job starts Appwrite with `_APP_BROWSER_HOST` set to `http://invalid-browser/v1` and runs this screenshot test. The API sends the request to that browser endpoint before it can load the new page URL, so changing the URL does not repair the job. The GraphQL screenshot tests in the same job are affected too.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| */ | ||
| private const PHOTO_SURFACE_COLOR = ['r' => 79, 'g' => 79, 'b' => 79]; | ||
|
|
||
| private const string SCREENSHOT_URL = 'http://screenshot.webapp.com'; |
There was a problem hiding this comment.
HTTPS screenshot coverage disappears
Both the Avatars and GraphQL screenshot tests now use an HTTP-only fixture, although the endpoint also accepts HTTPS URLs. A regression in HTTPS page loading or certificate handling would no longer be caught by these tests. Keep an observable HTTPS screenshot case.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Services/Avatars/AvatarsBase.php
Line: 17
Comment:
**HTTPS screenshot coverage disappears**
Both the Avatars and GraphQL screenshot tests now use an HTTP-only fixture, although the endpoint also accepts HTTPS URLs. A regression in HTTPS page loading or certificate handling would no longer be caught by these tests. Keep an observable HTTPS screenshot case.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| $referenceScreenshot = $referencePath . '/screenshot-example-com.png'; | ||
| $this->assertFileExists($referenceScreenshot, 'Reference example.com screenshot not found'); | ||
| $this->assertSamePixels($referenceScreenshot, $response['body']); | ||
| $this->assertSamePixels(__DIR__ . '/../../../resources/avatars/screenshot.png', $response['body']); |
There was a problem hiding this comment.
Pixel assertion mirrors fixture
This compares the response pixel-for-pixel with an image rendered from the repository’s own HTML fixture. A change to the fixture or its rendering requires updating the reference image, rather than checking an independent screenshot contract. The repository requires tests to assert observable behavior instead of mirroring implementation or configuration; that requirement needs to be met before merging.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Services/Avatars/AvatarsBase.php
Line: 1367
Comment:
**Pixel assertion mirrors fixture**
This compares the response pixel-for-pixel with an image rendered from the repository’s own HTML fixture. A change to the fixture or its rendering requires updating the reference image, rather than checking an independent screenshot contract. The repository requires tests to assert observable behavior instead of mirroring implementation or configuration; that requirement needs to be met before merging.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Cause
testGetScreenshotComparisonscreenshots the livehttps://example.comand compares it pixel for pixel withtests/resources/avatars/screenshot-example-com.png. example.com was redeployed with a new design (last-modified: Mon, 28 Sep 2026 16:19:23 GMT). The new page itself says to avoid relying on it for testing. Since then the Avatars job has failed onmainand on every open PR. Updating the reference image would only fix it until the next time the site changes.Fix
Screenshot tests now load a static page that the e2e stack serves, so they no longer depend on the public internet.
PublicHostname), so a plain internal service name is rejected. The fixture uses split DNS so that check keeps running unchanged:screenshot.webapp.comresolves through the existing unbound fixture resolver to203.0.0.1, following the same pattern as the otherwebapp.comfixtures. That address is public, so validation passes.webpageservice (nginx:1.30-alpine, pinned by digest) servestests/resources/avatars/webpage/index.html. It sits on a separatefixturesnetwork with the aliasscreenshot.webapp.com. Onlyappwrite-browserjoins that network, so the browser reaches nginx and the API container never sees the private address./avatars/screenshotscall inAvatarsBase.php(53 of them) and in the GraphQLAvatarsTest.php(6 of them, which used liveappwrite.io) now targets the fixture.screenshot-example-com.pngforscreenshot.png, rendered from the fixture through the endpoint in the running stack. The test still checks exact pixel equality.Validation
test tests/e2e/Services/Avatarson a fresh stack (down -v), run 1test tests/e2e/Services/Avatars, run 2test tests/e2e/Services/GraphQL/AvatarsTest.phpappwrite/browser:0.3.4arm64 vs amd64composer linton touched PHP files-c phpstan.neon) on touched PHP filestests/tools/rector.php) on touched PHP files🤖 Generated with Claude Code