Settings pages: - Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections) - Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal - Add workspace logo upload/delete routes and controller methods - Translate all hardcoded strings in Workspace.vue modals Language system: - Drop languages table, replace language_id FK with locale string column on users - Create config/languages.php for available languages and default locale - Add Spanish (es) translations (13 files) - Simplify HandleInertiaRequests, ProfileController, RegisteredUserController Code quality: - Add declare(strict_types=1) to all PHP files - Fix MastodonPublisher using wrong attribute (filename -> original_filename) - Fix HasMediaTest for new has_photo/photo_url accessors - Fix PublishToSocialPlatformTest type error revealed by strict_types - Remove orphaned Language model from AppServiceProvider morph map - Update User TypeScript interface (has_photo, photo_url, locale) - Eager load media relation on workspaces to prevent N+1 - Add 8 new tests for workspace logo upload/delete - Update workspace settings test to assert members/invitations props All 710 tests passing.
81 lines
2.4 KiB
PHP
81 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Enums\Media\Type as MediaType;
|
|
use App\Models\Workspace;
|
|
use Illuminate\Http\UploadedFile;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
beforeEach(function () {
|
|
Storage::fake();
|
|
});
|
|
|
|
test('media belongs to mediable', function () {
|
|
$workspace = Workspace::factory()->create();
|
|
$file = UploadedFile::fake()->image('logo.jpg', 100, 100);
|
|
$media = $workspace->addMedia($file, 'logo');
|
|
|
|
expect($media->mediable->id)->toBe($workspace->id);
|
|
});
|
|
|
|
test('media has url attribute', function () {
|
|
$workspace = Workspace::factory()->create();
|
|
$file = UploadedFile::fake()->image('logo.jpg', 100, 100);
|
|
$media = $workspace->addMedia($file, 'logo');
|
|
|
|
expect($media->url)->not->toBeEmpty();
|
|
});
|
|
|
|
test('media casts type to enum', function () {
|
|
$workspace = Workspace::factory()->create();
|
|
$file = UploadedFile::fake()->image('logo.jpg', 100, 100);
|
|
$media = $workspace->addMedia($file, 'logo');
|
|
|
|
expect($media->type)->toBeInstanceOf(MediaType::class);
|
|
});
|
|
|
|
test('media casts size to integer', function () {
|
|
$workspace = Workspace::factory()->create();
|
|
$file = UploadedFile::fake()->image('logo.jpg', 100, 100);
|
|
$media = $workspace->addMedia($file, 'logo');
|
|
|
|
expect($media->size)->toBeInt();
|
|
});
|
|
|
|
test('media casts meta to array', function () {
|
|
$workspace = Workspace::factory()->create();
|
|
$file = UploadedFile::fake()->image('logo.jpg', 100, 100);
|
|
$media = $workspace->addMedia($file, 'logo', ['key' => 'value']);
|
|
|
|
expect($media->meta)->toBeArray();
|
|
expect($media->meta['key'])->toBe('value');
|
|
});
|
|
|
|
test('media deletes file from storage when deleted', function () {
|
|
$workspace = Workspace::factory()->create();
|
|
$file = UploadedFile::fake()->image('logo.jpg', 100, 100);
|
|
$media = $workspace->addMedia($file, 'logo');
|
|
$path = $media->path;
|
|
|
|
Storage::assertExists($path);
|
|
|
|
$media->delete();
|
|
|
|
Storage::assertMissing($path);
|
|
});
|
|
|
|
test('media can get temporary url', function () {
|
|
// Use a driver that supports temporary URLs
|
|
Storage::fake('s3');
|
|
config(['filesystems.default' => 's3']);
|
|
|
|
$workspace = Workspace::factory()->create();
|
|
$file = UploadedFile::fake()->image('logo.jpg', 100, 100);
|
|
$media = $workspace->addMedia($file, 'logo');
|
|
|
|
// The fake driver returns a basic URL format
|
|
$url = $media->getTemporaryUrl(30);
|
|
|
|
expect($url)->toBeString();
|
|
});
|