Implement creator studio and upload updates
This commit is contained in:
@@ -13,6 +13,7 @@ use App\Models\NovaCardCategory;
|
||||
use App\Models\NovaCardBackground;
|
||||
use App\Models\NovaCardTemplate;
|
||||
use App\Models\User;
|
||||
use App\Services\NovaCards\NovaCardBackgroundService;
|
||||
use App\Services\NovaCards\NovaCardRenderService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Arr;
|
||||
@@ -413,6 +414,40 @@ it('rejects malformed background uploads without throwing', function (): void {
|
||||
@unlink($tempPath);
|
||||
});
|
||||
|
||||
it('stores uploaded backgrounds when real path falls back to pathname', function (): void {
|
||||
Storage::fake('local');
|
||||
Storage::fake('public');
|
||||
|
||||
config()->set('nova_cards.storage.private_disk', 'local');
|
||||
config()->set('nova_cards.storage.public_disk', 'public');
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
$tempFile = UploadedFile::fake()->image('background.png', 1400, 1000);
|
||||
$pathname = $tempFile->getPathname();
|
||||
|
||||
$upload = new class($pathname) extends UploadedFile {
|
||||
public function __construct(string $path)
|
||||
{
|
||||
parent::__construct($path, 'background.png', 'image/png', \UPLOAD_ERR_OK, true);
|
||||
}
|
||||
|
||||
public function getRealPath(): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$background = app(NovaCardBackgroundService::class)->storeUploadedBackground($user, $upload);
|
||||
|
||||
expect($background->width)->toBe(1400)
|
||||
->and($background->height)->toBe(1000)
|
||||
->and($background->sha256)->not->toBeNull();
|
||||
|
||||
Storage::disk('local')->assertExists($background->original_path);
|
||||
Storage::disk('public')->assertExists($background->processed_path);
|
||||
});
|
||||
|
||||
it('renders a draft preview through the render endpoint', function (): void {
|
||||
$user = User::factory()->create();
|
||||
$card = draftCard($user);
|
||||
|
||||
Reference in New Issue
Block a user