diff --git a/tests/e2e/Services/GraphQL/Base.php b/tests/e2e/Services/GraphQL/Base.php index c42679018e..9010490cc9 100644 --- a/tests/e2e/Services/GraphQL/Base.php +++ b/tests/e2e/Services/GraphQL/Base.php @@ -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 } }'; diff --git a/tests/e2e/Services/GraphQL/StorageClientTest.php b/tests/e2e/Services/GraphQL/StorageClientTest.php index dd89819c34..9cdf523a0a 100644 --- a/tests/e2e/Services/GraphQL/StorageClientTest.php +++ b/tests/e2e/Services/GraphQL/StorageClientTest.php @@ -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; } diff --git a/tests/e2e/Services/GraphQL/StorageServerTest.php b/tests/e2e/Services/GraphQL/StorageServerTest.php index 1377ef9207..7808c50be6 100644 --- a/tests/e2e/Services/GraphQL/StorageServerTest.php +++ b/tests/e2e/Services/GraphQL/StorageServerTest.php @@ -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; }