From 980c4f94a8020e7f50f6b03f65c04fa2951f79a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sat, 19 Sep 2026 11:48:44 +0200 Subject: [PATCH] fix(vcs): use the mapped status when picking the comment image extension Sites map the `processing` status onto the `building` image, but the extension was still derived from the raw status, so a processing deployment asked for `status-building-light.png`, which does not exist. Only the `.gif` variants are shipped for `building`. Co-Authored-By: Claude Opus 5 (1M context) --- src/Appwrite/Vcs/Comment.php | 2 +- tests/unit/Vcs/CommentTest.php | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Vcs/Comment.php b/src/Appwrite/Vcs/Comment.php index 700f37b5e1..f5e6e140c9 100644 --- a/src/Appwrite/Vcs/Comment.php +++ b/src/Appwrite/Vcs/Comment.php @@ -147,7 +147,7 @@ class Comment foreach ($project['site'] as $siteId => $site) { $imageStatus = in_array($site['status'], ['processing', 'building']) ? 'building' : $site['status']; - $extension = $site['status'] === 'building' ? 'gif' : 'png'; + $extension = $imageStatus === 'building' ? 'gif' : 'png'; $pathLight = '/images/vcs/status-' . $imageStatus . '-light.' . $extension; $pathDark = '/images/vcs/status-' . $imageStatus . '-dark.' . $extension; diff --git a/tests/unit/Vcs/CommentTest.php b/tests/unit/Vcs/CommentTest.php index 5c43a68d09..72c4603ecd 100644 --- a/tests/unit/Vcs/CommentTest.php +++ b/tests/unit/Vcs/CommentTest.php @@ -135,6 +135,39 @@ final class CommentTest extends TestCase $this->assertSame($firstTip, $secondTip); } + public function testSiteStatusImagesMatchExistingFiles(): void + { + $extensions = [ + 'waiting' => 'status-waiting-%s.png', + 'processing' => 'status-building-%s.gif', + 'building' => 'status-building-%s.gif', + 'ready' => 'status-ready-%s.png', + 'failed' => 'status-failed-%s.png', + ]; + + foreach ($extensions as $status => $file) { + $comment = new Comment(['consoleHostname' => 'localhost']); + $comment->addBuild( + new Document(['$id' => 'project1', 'name' => 'Test Project', 'region' => 'default']), + new Document(['$id' => 'site1', 'name' => 'Test Site']), + 'site', + $status, + 'dep1', + ['type' => 'logs'], + 'https://example.appwrite.network' + ); + + $generated = $comment->generateComment(); + + foreach (['light', 'dark'] as $scheme) { + $path = \sprintf($file, $scheme); + + $this->assertStringContainsString('/images/vcs/' . $path, $generated); + $this->assertFileExists(__DIR__ . '/../../../public/images/vcs/' . $path); + } + } + } + private function extractTip(string $comment): ?string { if (\preg_match('/> \[!TIP\]\n> (.+)/', $comment, $matches)) {