Merge pull request #12251 from appwrite/fix/graphql-preview-test-assertions

This commit is contained in:
Chirag Aggarwal
2026-05-08 18:13:14 +05:30
committed by GitHub
3 changed files with 20 additions and 4 deletions
+18 -2
View File
@@ -4,6 +4,7 @@ namespace Tests\E2E\Services\GraphQL;
use CURLFile;
use Utopia\Console;
use Utopia\Image\Image;
trait Base
{
@@ -516,6 +517,21 @@ trait Base
}
';
protected function assertFilePreviewResponse(array $file): void
{
$this->assertEquals(200, $file['headers']['status-code']);
$this->assertEquals('image/png', $file['headers']['content-type']);
$this->assertNotEmpty($file['body']);
$image = new Image($file['body']);
$dimensions = \getimagesizefromstring($file['body']);
$this->assertNotEmpty($image->output('png'));
$this->assertIsArray($dimensions);
$this->assertEquals(100, $dimensions[0]);
$this->assertEquals(100, $dimensions[1]);
}
public function getQuery(string $name): string
{
switch ($name) {
@@ -2388,8 +2404,8 @@ trait Base
}
}';
case self::GET_FILE_PREVIEW:
return 'query getFilePreview($bucketId: String!, $fileId: String!) {
storageGetFilePreview(bucketId: $bucketId, fileId: $fileId) {
return 'query getFilePreview($bucketId: String!, $fileId: String!, $width: Int, $height: Int) {
storageGetFilePreview(bucketId: $bucketId, fileId: $fileId, width: $width, height: $height) {
status
}
}';
@@ -200,7 +200,7 @@ class StorageClientTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
$this->assertEquals(46719, \strlen($file['body']));
$this->assertFilePreviewResponse($file);
return $file;
}
@@ -262,7 +262,7 @@ class StorageServerTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
$this->assertEquals(46719, \strlen($file['body']));
$this->assertFilePreviewResponse($file);
return $file;
}