Use an inline-colored full-width progress bar so the fill renders without relying on purged Tailwind classes.
67 lines
1.9 KiB
PHP
67 lines
1.9 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();
|
|
|
|
$response = $this->get(route('recordings.index'))
|
|
->assertOk()
|
|
->assertSee('Disk space', false)
|
|
->assertSee('% used', false)
|
|
->assertSee('free')
|
|
->assertSee('role="progressbar"', false)
|
|
->assertSee('background-color:', false);
|
|
|
|
$this->assertMatchesRegularExpression(
|
|
'/width:\s*[\d.]+%;\s*background-color:\s*#(0d9488|f59e0b|dc2626)/',
|
|
$response->getContent(),
|
|
);
|
|
}
|
|
}
|