Protect recordings per user, seed a demo login on container start, and bind-mount the app with Vite HMR for local Compose development.
60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\User;
|
|
use App\Services\DiskSpaceService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Tests\TestCase;
|
|
|
|
class DiskSpaceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected User $user;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->user = User::factory()->create();
|
|
$this->actingAs($this->user);
|
|
}
|
|
|
|
public function test_disk_space_service_returns_snapshot_for_storage_path(): void
|
|
{
|
|
Cache::flush();
|
|
|
|
$snapshot = app(DiskSpaceService::class)->snapshot();
|
|
|
|
$this->assertNotNull($snapshot);
|
|
$this->assertGreaterThan(0, $snapshot['total_bytes']);
|
|
$this->assertGreaterThanOrEqual(0, $snapshot['free_bytes']);
|
|
$this->assertGreaterThanOrEqual(0, $snapshot['used_percent']);
|
|
$this->assertLessThanOrEqual(100, $snapshot['used_percent']);
|
|
$this->assertNotEmpty($snapshot['free_human']);
|
|
$this->assertNotEmpty($snapshot['total_human']);
|
|
}
|
|
|
|
public function test_disk_space_service_returns_null_for_missing_path(): void
|
|
{
|
|
Cache::flush();
|
|
|
|
$snapshot = app(DiskSpaceService::class)->snapshot('/path/that/does/not/exist-'.uniqid());
|
|
|
|
$this->assertNull($snapshot);
|
|
}
|
|
|
|
public function test_layout_shows_disk_space_bar(): void
|
|
{
|
|
Cache::flush();
|
|
|
|
$this->get(route('recordings.index'))
|
|
->assertOk()
|
|
->assertSee('Disk space')
|
|
->assertSee('free')
|
|
->assertSee('role="progressbar"', false);
|
|
}
|
|
}
|