diff --git a/app/Livewire/Dashboard/DashboardConverter.php b/app/Livewire/Dashboard/DashboardConverter.php index 1c8e6fa..d72bf49 100644 --- a/app/Livewire/Dashboard/DashboardConverter.php +++ b/app/Livewire/Dashboard/DashboardConverter.php @@ -152,6 +152,25 @@ public function selectTargetFormat(string $targetFormat): void $this->step = 'settings'; } + public function continueFromSettings(): void + { + if ($this->currentFile === null || $this->selectedTargetFormat === null) { + $this->goToSettingsStep(); + + return; + } + + if (! $this->validateSettings()) { + $this->step = 'settings'; + + return; + } + + // Phase 8 stops at a convert placeholder. CreateConversionJobAction and + // the real conversion flow arrive in Phase 9. + $this->step = 'convert'; + } + public function validateSettings(): bool { $this->resetErrorBag(); diff --git a/resources/views/livewire/dashboard/dashboard-converter.blade.php b/resources/views/livewire/dashboard/dashboard-converter.blade.php index c793c18..9bca031 100644 --- a/resources/views/livewire/dashboard/dashboard-converter.blade.php +++ b/resources/views/livewire/dashboard/dashboard-converter.blade.php @@ -1,6 +1,11 @@
- + @if ($step === 'upload' && $this->currentFile) @php($file = $this->currentFile)
@@ -161,6 +166,26 @@ class="flex items-start gap-3 rounded-[var(--ca-radius-md)] border border-[var(-
@include('livewire.dashboard.dashboard-converter.partials.dynamic-options-form') + +
+ Continue +
+
+ @endif + + @if ($step === 'convert' && $this->currentFile) + @php($file = $this->currentFile) +
+
+ ← Back +
+ +
+

+ Ready to convert {{ strtoupper($file->extension) }} to {{ strtoupper($selectedTargetFormat) }} +

+

Conversion will be available in Phase 9.

+
@endif diff --git a/tests/Feature/Livewire/DashboardConverterSettingsValidationTest.php b/tests/Feature/Livewire/DashboardConverterSettingsValidationTest.php index 026e242..f720c23 100644 --- a/tests/Feature/Livewire/DashboardConverterSettingsValidationTest.php +++ b/tests/Feature/Livewire/DashboardConverterSettingsValidationTest.php @@ -43,6 +43,47 @@ ->assertHasErrors(['options.bogus']); }); +it('moves to the convert step when settings are valid', function () { + $user = User::factory()->create(); + $file = FileRecord::factory()->for($user)->create(['extension' => 'png']); + + Livewire::actingAs($user) + ->test(DashboardConverter::class) + ->set('currentFileId', $file->id) + ->call('selectTargetFormat', 'jpg') + ->call('continueFromSettings') + ->assertSet('step', 'convert') + ->assertHasNoErrors(); +}); + +it('stays on the settings step when settings are invalid', function () { + $user = User::factory()->create(); + $file = FileRecord::factory()->for($user)->create(['extension' => 'png']); + + Livewire::actingAs($user) + ->test(DashboardConverter::class) + ->set('currentFileId', $file->id) + ->call('selectTargetFormat', 'jpg') + ->set('options.quality', 'bad') + ->call('continueFromSettings') + ->assertSet('step', 'settings') + ->assertHasErrors(['options.quality']); +}); + +it('does not create any extra records when continuing to the convert step', function () { + $user = User::factory()->create(); + $file = FileRecord::factory()->for($user)->create(['extension' => 'png']); + + Livewire::actingAs($user) + ->test(DashboardConverter::class) + ->set('currentFileId', $file->id) + ->call('selectTargetFormat', 'jpg') + ->call('continueFromSettings') + ->assertSet('step', 'convert'); + + expect(FileRecord::query()->where('user_id', $user->id)->count())->toBe(1); +}); + it('does not create any extra records during settings validation', function () { $user = User::factory()->create(); $file = FileRecord::factory()->for($user)->create(['extension' => 'png']);