Move recordings UI to Livewire pages with Flux components.
Replace controller-driven Blade views with full-page Livewire index/show/create flows so Flux tables, toasts, and uploads work natively.
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Recordings;
|
||||
|
||||
use App\Jobs\TranscribeRecording;
|
||||
use App\Livewire\Recordings\Index;
|
||||
use App\Models\Recording;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IndexTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_index_page_renders_as_livewire(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
Recording::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'title' => 'Pocket note',
|
||||
'original_filename' => 'note.mp3',
|
||||
'file_path' => 'recordings/note.mp3',
|
||||
'file_size_bytes' => 1024,
|
||||
'transcription_status' => 'done',
|
||||
'transcript' => 'hello world',
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('recordings.index'))
|
||||
->assertOk()
|
||||
->assertSeeLivewire(Index::class)
|
||||
->assertSee('Pocket note');
|
||||
}
|
||||
|
||||
public function test_search_filters_recordings(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
Recording::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'title' => 'Office chat',
|
||||
'original_filename' => 'office.mp3',
|
||||
'file_path' => 'recordings/office.mp3',
|
||||
'file_size_bytes' => 100,
|
||||
'transcription_status' => 'done',
|
||||
'transcript' => 'talking about the pocket recorder today',
|
||||
]);
|
||||
|
||||
Recording::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'title' => 'Unrelated',
|
||||
'original_filename' => 'other.mp3',
|
||||
'file_path' => 'recordings/other.mp3',
|
||||
'file_size_bytes' => 100,
|
||||
'transcription_status' => 'done',
|
||||
'transcript' => 'nothing useful',
|
||||
]);
|
||||
|
||||
Livewire::test(Index::class)
|
||||
->set('search', 'pocket recorder')
|
||||
->assertSee('Office chat')
|
||||
->assertDontSee('Unrelated');
|
||||
}
|
||||
|
||||
public function test_queue_pending_dispatches_jobs(): void
|
||||
{
|
||||
Bus::fake();
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
Recording::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'title' => 'Needs work',
|
||||
'original_filename' => 'needs.mp3',
|
||||
'file_path' => 'recordings/needs.mp3',
|
||||
'file_size_bytes' => 100,
|
||||
'transcription_status' => 'pending',
|
||||
]);
|
||||
|
||||
Livewire::test(Index::class)
|
||||
->call('queuePending');
|
||||
|
||||
Bus::assertDispatched(TranscribeRecording::class, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Recordings;
|
||||
|
||||
use App\Livewire\Recordings\Show;
|
||||
use App\Models\Recording;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ShowTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_show_page_renders_as_livewire(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$recording = Recording::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'title' => 'Show me',
|
||||
'original_filename' => 'show.mp3',
|
||||
'file_path' => 'recordings/show.mp3',
|
||||
'file_size_bytes' => 100,
|
||||
'transcription_status' => 'done',
|
||||
'transcript' => 'Finished text',
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('recordings.show', $recording))
|
||||
->assertOk()
|
||||
->assertSeeLivewire(Show::class)
|
||||
->assertSee('Show me')
|
||||
->assertSee('Play', false);
|
||||
}
|
||||
|
||||
public function test_user_can_delete_own_recording(): void
|
||||
{
|
||||
Storage::fake('local');
|
||||
Storage::disk('local')->put('recordings/delete-me.mp3', 'bytes');
|
||||
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$recording = Recording::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'title' => 'Delete me',
|
||||
'original_filename' => 'delete-me.mp3',
|
||||
'file_path' => 'recordings/delete-me.mp3',
|
||||
'file_size_bytes' => 5,
|
||||
'transcription_status' => 'done',
|
||||
]);
|
||||
|
||||
Livewire::test(Show::class, ['recording' => $recording])
|
||||
->call('delete')
|
||||
->assertRedirect(route('recordings.index'));
|
||||
|
||||
$this->assertDatabaseMissing('recordings', ['id' => $recording->id]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user