Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions resources/views/livewire/dashboard/dashboard-converter.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,19 @@ class="flex flex-col items-center justify-center gap-4 rounded-[var(--ca-radius-
</div>

@if ($targetFormatError)
<p class="text-sm text-[var(--ca-danger)]">{{ $targetFormatError }}</p>
<div class="rounded-[var(--ca-radius-md)] border border-[var(--ca-danger)]/30 bg-[var(--ca-danger)]/5 px-4 py-3 text-sm text-[var(--ca-danger)]">
{{ $targetFormatError }}
</div>
@endif

<div wire:loading wire:target="selectTargetFormat" class="flex items-center gap-2 text-sm text-[var(--ca-muted)]">
<svg class="h-4 w-4 animate-spin" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"></path>
</svg>
Loading converter settings…
</div>

@if (empty($this->targetFormatCards))
<div class="rounded-[var(--ca-radius-md)] border border-dashed border-[var(--ca-border)] bg-[var(--ca-surface-muted)]/40 px-6 py-8 text-center">
<p class="text-base font-semibold text-[var(--ca-text)]">No conversion targets available</p>
Expand All @@ -115,7 +125,9 @@ class="flex flex-col items-center justify-center gap-4 rounded-[var(--ca-radius-
<button
type="button"
wire:click="selectTargetFormat('{{ $card->targetFormat }}')"
class="flex items-start gap-3 rounded-[var(--ca-radius-md)] border border-[var(--ca-border)] bg-white p-4 text-left transition hover:border-[var(--ca-primary)] hover:bg-[var(--ca-primary)]/5 ca-focus-ring">
wire:loading.attr="disabled"
wire:target="selectTargetFormat"
class="flex items-start gap-3 rounded-[var(--ca-radius-md)] border border-[var(--ca-border)] bg-white p-4 text-left transition hover:border-[var(--ca-primary)] hover:bg-[var(--ca-primary)]/5 ca-focus-ring disabled:opacity-50 disabled:cursor-not-allowed">
<x-file-icon :format="$card->targetFormat" />
<span class="flex flex-col gap-0.5">
<span class="flex items-center gap-2">
Expand Down
24 changes: 24 additions & 0 deletions tests/Feature/Livewire/DashboardConverterTargetFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@
->assertSet('step', 'upload');
});

it('shows the unsupported conversion error message on invalid target selection', function () {
$user = User::factory()->create();
$file = FileRecord::factory()->for($user)->create(['extension' => 'png']);

Livewire::actingAs($user)
->test(DashboardConverter::class)
->set('currentFileId', $file->id)
->call('goToFormatStep')
->call('selectTargetFormat', 'mp3')
->assertSee('This conversion is not supported yet.');
});

it('renders a loading indicator targeting target selection', function () {
$user = User::factory()->create();
$file = FileRecord::factory()->for($user)->create(['extension' => 'png']);

Livewire::actingAs($user)
->test(DashboardConverter::class)
->set('currentFileId', $file->id)
->call('goToFormatStep')
->assertSeeHtml('wire:loading')
->assertSeeHtml('wire:target="selectTargetFormat"');
});

it('clears a previous target error when a valid target is chosen', function () {
$user = User::factory()->create();
$file = FileRecord::factory()->for($user)->create(['extension' => 'png']);
Expand Down