|
18 | 18 |
|
19 | 19 | namespace Tests\ImageProcessing\Photo; |
20 | 20 |
|
| 21 | +use App\Jobs\RecomputeAlbumSizeJob; |
| 22 | +use App\Jobs\RecomputeAlbumStatsJob; |
| 23 | +use Illuminate\Support\Facades\Queue; |
21 | 24 | use Tests\Constants\TestConstants; |
22 | 25 | use Tests\Feature_v2\Base\BaseApiWithDataTest; |
23 | 26 |
|
@@ -159,4 +162,32 @@ public function testGoogleMotionPicture(): void |
159 | 162 | $response = $this->deleteJson('Photo', ['photo_ids' => [$id], 'from_id' => 'unsorted']); |
160 | 163 | $this->assertNoContent($response); |
161 | 164 | } |
| 165 | + |
| 166 | + public function testPhotoUploadDispatchesJobs(): void |
| 167 | + { |
| 168 | + // Fake only the recompute jobs, not the ProcessImageJob |
| 169 | + // This allows the photo upload to complete while capturing the recompute job dispatches |
| 170 | + Queue::fake([ |
| 171 | + RecomputeAlbumStatsJob::class, |
| 172 | + RecomputeAlbumSizeJob::class, |
| 173 | + ]); |
| 174 | + |
| 175 | + $this->catchFailureSilence = []; |
| 176 | + |
| 177 | + // Upload a photo to an album |
| 178 | + $response = $this->actingAs($this->admin)->upload('Photo', filename: TestConstants::SAMPLE_FILE_NIGHT_IMAGE, album_id: $this->album1->id); |
| 179 | + $this->assertCreated($response); |
| 180 | + |
| 181 | + // Assert that RecomputeAlbumStatsJob was dispatched for the album |
| 182 | + Queue::assertPushed(RecomputeAlbumStatsJob::class, function (RecomputeAlbumStatsJob $job) { |
| 183 | + return $job->album_id === $this->album1->id; |
| 184 | + }); |
| 185 | + |
| 186 | + // Assert that RecomputeAlbumSizeJob was dispatched for the album |
| 187 | + Queue::assertPushed(RecomputeAlbumSizeJob::class, function (RecomputeAlbumSizeJob $job) { |
| 188 | + return $job->album_id === $this->album1->id; |
| 189 | + }); |
| 190 | + |
| 191 | + $this->catchFailureSilence = ["App\Exceptions\MediaFileOperationException"]; |
| 192 | + } |
162 | 193 | } |
0 commit comments