Skip to content

test(avatars): screenshot a local fixture instead of example.com - #13964

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/avatars-screenshot-fixture
Sep 28, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/avatars-screenshot-fixture

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Cause

testGetScreenshotComparison screenshots the live https://example.com and compares it pixel for pixel with tests/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 on main and 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.

  • The screenshot endpoint only accepts hosts with a known public suffix that resolve to public addresses (PublicHostname), so a plain internal service name is rejected. The fixture uses split DNS so that check keeps running unchanged:
    • In the API container, screenshot.webapp.com resolves through the existing unbound fixture resolver to 203.0.0.1, following the same pattern as the other webapp.com fixtures. That address is public, so validation passes.
    • A new webpage service (nginx:1.30-alpine, pinned by digest) serves tests/resources/avatars/webpage/index.html. It sits on a separate fixtures network with the alias screenshot.webapp.com. Only appwrite-browser joins that network, so the browser reaches nginx and the API container never sees the private address.
  • Every /avatars/screenshots call in AvatarsBase.php (53 of them) and in the GraphQL AvatarsTest.php (6 of them, which used live appwrite.io) now targets the fixture.
  • Swapped screenshot-example-com.png for screenshot.png, rendered from the fixture through the endpoint in the running stack. The test still checks exact pixel equality.

Validation

Check Result
test tests/e2e/Services/Avatars on a fresh stack (down -v), run 1 OK (50 tests, 1023 assertions)
test tests/e2e/Services/Avatars, run 2 OK (50 tests, 1027 assertions)
test tests/e2e/Services/GraphQL/AvatarsTest.php OK (13 tests, 55 assertions)
Fixture render, appwrite/browser:0.3.4 arm64 vs amd64 Byte-identical PNG (same sha1)
Two consecutive renders through the endpoint Byte-identical
composer lint on touched PHP files Passed
PHPStan on host (-c phpstan.neon) on touched PHP files No errors
Rector dry run (tests/tools/rector.php) on touched PHP files No changes

🤖 Generated with Claude Code

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.
@ghost

ghost commented Sep 28, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The fixture wiring and updated test URLs are consistent with the existing validation and CI Compose setup; I found no concrete issues requiring changes.

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.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 6
File Change
docker-compose.override.yml Adds a fixture-only nginx service and connects the browser to its network.
tests/e2e/Services/Avatars/AvatarsBase.php Uses the local screenshot URL and compares against the new reference image.
tests/e2e/Services/GraphQL/AvatarsTest.php Points screenshot queries at the local fixture.
tests/resources/avatars/webpage/index.html Adds the static page rendered in screenshot tests.
tests/resources/dns/zones.conf Adds a public-address DNS answer for API-side URL validation.
tests/resources/avatars/screenshot-example-com.png → tests/resources/avatars/screenshot.png Replaces the live-site reference screenshot with the fixture reference.

Reviewed 4193dc8 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Low risk] Test fixtures for avatar screenshot tests.

The PR is not ready to merge because the intended CI repair remains blocked by the invalid browser endpoint, and the screenshot assertion conflicts with an explicit repository testing requirement.

Fix All in Claude CodeFindings

  1. P1 CI browser endpoint remains invalid ▶
  2. P2 HTTPS screenshot coverage disappears ▶
  3. P2 Pixel assertion mirrors fixture ▶
Fix with agent prompt
### Issue 1
tests/e2e/Services/Avatars/AvatarsBase.php:1359
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.

### Issue 2
tests/e2e/Services/Avatars/AvatarsBase.php:17
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.

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!

### Issue 3
tests/e2e/Services/Avatars/AvatarsBase.php:1367
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.

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!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR replaces external screenshot targets with a local nginx page, split-DNS fixture, and new reference image.

  • The local fixture removes dependence on changes to the public websites.
  • The Avatars CI job still points screenshot generation at an invalid browser endpoint.

Reviews (1) · Last reviewed commit: "test(avatars): screenshot a local fixtur..."

'x-appwrite-project' => $this->getProject()['$id'],
], [
'url' => 'https://example.com',
'url' => self::SCREENSHOT_URL,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 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.

Fix in Claude Code Fix in Codex

*/
private const PHOTO_SURFACE_COLOR = ['r' => 79, 'g' => 79, 'b' => 79];

private const string SCREENSHOT_URL = 'http://screenshot.webapp.com';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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!

Fix in Claude Code Fix in Codex

$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']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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!

Fix in Claude Code Fix in Codex

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/avatars-screenshot-fixture (after).

⚠️ Before benchmark did not complete — change column unavailable.

Metric Before After Change
🚀 Requests/sec n/a 195.83 n/a
⏱️ Latency P50 n/a 89.89 ms n/a
⏱️ Latency P95 n/a 204.08 ms n/a
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 89.89 204.08 12,483 195.83 n/a
Account 166.51 314.21 657 10.86 n/a
TablesDB 87.41 163.48 6,789 108.67 n/a
Storage 80.81 171.62 3,285 53.89 n/a
Functions 123.88 249.78 1,752 29.49 n/a

Top API waits (after)

API request Max wait (ms)
functions.variables.update 553.33
account.name.update 485.17
storage.buckets.create 432.36
functions.create 415.01
account.prefs.update 407.81

@ChiragAgg5k
ChiragAgg5k merged commit 6cfe024 into main Sep 28, 2026
55 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/avatars-screenshot-fixture branch September 28, 2026 19:53
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.

1 participant