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)) {