Files
ladill-meet/tests/Feature/MeetRecordingUploadTest.php
T
isaaccladandCursor b765b5dd97
Deploy Ladill Meet / deploy (push) Successful in 53s
Store meet recordings on Ladill servers via browser upload.
Capture the meeting in the host browser, upload to Ladill storage on stop, and remove the LiveKit egress placeholder job.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 17:40:44 +00:00

116 lines
3.7 KiB
PHP

<?php
namespace Tests\Feature;
use App\Http\Middleware\EnsurePlatformSession;
use App\Models\Member;
use App\Models\Organization;
use App\Models\Participant;
use App\Models\Recording;
use App\Models\Room;
use App\Models\Session;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
class MeetRecordingUploadTest extends TestCase
{
use RefreshDatabase;
protected User $user;
protected Organization $organization;
protected function setUp(): void
{
parent::setUp();
$this->withoutMiddleware(EnsurePlatformSession::class);
Storage::fake('local');
$this->user = User::create([
'public_id' => 'test-user-recording',
'name' => 'Test User',
'email' => 'recording@example.com',
]);
$this->organization = Organization::create([
'owner_ref' => $this->user->public_id,
'name' => 'Test Org',
'slug' => 'test-org-recording',
'timezone' => 'UTC',
'settings' => ['onboarded' => true],
]);
Member::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'user_ref' => $this->user->public_id,
'role' => 'owner',
]);
$base = rtrim((string) config('billing.api_url'), '/');
Http::fake([
$base.'/can-afford*' => Http::response(['affordable' => true]),
$base.'/debit' => Http::response(['ok' => true]),
]);
}
public function test_host_can_upload_browser_recording_to_ladill_storage(): void
{
$room = Room::create([
'organization_id' => $this->organization->id,
'owner_ref' => $this->user->public_id,
'host_user_ref' => $this->user->public_id,
'title' => 'Recorded meeting',
'type' => 'instant',
'status' => 'live',
'timezone' => 'UTC',
]);
$session = Session::create([
'room_id' => $room->id,
'owner_ref' => $this->user->public_id,
'media_room_name' => 'room-'.$room->uuid,
'status' => 'live',
'started_at' => now()->subMinutes(5),
]);
$participant = Participant::create([
'owner_ref' => $this->user->public_id,
'session_id' => $session->id,
'user_ref' => $this->user->public_id,
'role' => 'host',
'display_name' => 'Test User',
'status' => 'joined',
'joined_at' => now(),
]);
$recording = Recording::create([
'owner_ref' => $this->user->public_id,
'session_id' => $session->id,
'status' => 'processing',
'layout' => 'gallery',
'started_by_ref' => $this->user->public_id,
'started_at' => now()->subMinute(),
'ended_at' => now(),
'duration_seconds' => 60,
]);
$this->withSession(["meet.participant.{$session->uuid}" => $participant->uuid])
->actingAs($this->user)
->post("/room/{$session->uuid}/recordings/{$recording->uuid}/upload", [
'recording' => UploadedFile::fake()->create('meet.webm', 128, 'video/webm'),
])
->assertOk()
->assertJson(['status' => 'ready']);
$recording->refresh();
$this->assertSame('ready', $recording->status);
$this->assertNotNull($recording->storage_path);
Storage::disk('local')->assertExists($recording->storage_path);
}
}