mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #13771 from appwrite/fix-vcs-comment-processing-image
fix(vcs): use the mapped status when picking the comment image extension
This commit is contained in:
2 files changed
+34
-1
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in new issue
Block a user