]> BookStack Code Mirror - bookstack/blobdiff - tests/Uploads/ImageTest.php
Tests: Updated comment test to account for new editor usage
[bookstack] / tests / Uploads / ImageTest.php
index e28880c95fdcf53128f790cdb933b8bb364830c6..a2f03df34d4f62d12d163ea23378811418f6e58d 100644 (file)
@@ -68,7 +68,20 @@ class ImageTest extends TestCase
         $this->files->deleteAtRelativePath($imgDetails['path']);
 
         $this->assertStringContainsString('thumbs-', $imgDetails['response']->thumbs->gallery);
-        $this->assertStringNotContainsString('thumbs-', $imgDetails['response']->thumbs->display);
+        $this->assertStringNotContainsString('scaled-', $imgDetails['response']->thumbs->display);
+    }
+
+    public function test_image_display_thumbnail_generation_for_animated_avif_images_uses_original_file()
+    {
+        $page = $this->entities->page();
+        $admin = $this->users->admin();
+        $this->actingAs($admin);
+
+        $imgDetails = $this->files->uploadGalleryImageToPage($this, $page, 'animated.avif');
+        $this->files->deleteAtRelativePath($imgDetails['path']);
+
+        $this->assertStringContainsString('thumbs-', $imgDetails['response']->thumbs->gallery);
+        $this->assertStringNotContainsString('scaled-', $imgDetails['response']->thumbs->display);
     }
 
     public function test_image_edit()
@@ -119,6 +132,32 @@ class ImageTest extends TestCase
         $this->files->deleteAtRelativePath($relPath);
     }
 
+    public function test_image_file_update_allows_case_differences()
+    {
+        $page = $this->entities->page();
+        $this->asEditor();
+
+        $imgDetails = $this->files->uploadGalleryImageToPage($this, $page);
+        $relPath = $imgDetails['path'];
+
+        $newUpload = $this->files->uploadedImage('updated-image.PNG', 'compressed.png');
+        $this->assertFileEquals($this->files->testFilePath('test-image.png'), public_path($relPath));
+
+        $imageId = $imgDetails['response']->id;
+        $image = Image::findOrFail($imageId);
+        $image->updated_at = now()->subMonth();
+        $image->save();
+
+        $this->call('PUT', "/images/{$imageId}/file", [], [], ['file' => $newUpload])
+            ->assertOk();
+
+        $this->assertFileEquals($this->files->testFilePath('compressed.png'), public_path($relPath));
+
+        $image->refresh();
+        $this->assertTrue($image->updated_at->gt(now()->subMinute()));
+
+        $this->files->deleteAtRelativePath($relPath);
+    }
 
     public function test_image_file_update_does_not_allow_change_in_image_extension()
     {