106 lines
3.3 KiB
PHP
106 lines
3.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Support\Diff\DiffRow;
|
|
use App\Support\Diff\DiffRowStatus;
|
|
|
|
it('renders changed rows with shared state labels and from or to values', function (): void {
|
|
$this->view('filament.partials.diff.row', [
|
|
'row' => new DiffRow(
|
|
key: 'description',
|
|
label: 'Description',
|
|
status: DiffRowStatus::Changed,
|
|
oldValue: 'Before',
|
|
newValue: 'After',
|
|
),
|
|
'compact' => false,
|
|
'dimUnchanged' => true,
|
|
])
|
|
->assertSee('Changed')
|
|
->assertSee('Description')
|
|
->assertSee('From')
|
|
->assertSee('Before')
|
|
->assertSee('To')
|
|
->assertSee('After');
|
|
});
|
|
|
|
it('renders added removed and unchanged rows through the shared dispatcher', function (): void {
|
|
$added = (string) $this->view('filament.partials.diff.row', [
|
|
'row' => new DiffRow(
|
|
key: 'new_setting',
|
|
label: 'New setting',
|
|
status: DiffRowStatus::Added,
|
|
newValue: 'Enabled',
|
|
),
|
|
'compact' => false,
|
|
'dimUnchanged' => true,
|
|
]);
|
|
|
|
$removed = (string) $this->view('filament.partials.diff.row', [
|
|
'row' => new DiffRow(
|
|
key: 'retired_setting',
|
|
label: 'Retired setting',
|
|
status: DiffRowStatus::Removed,
|
|
oldValue: 'Legacy',
|
|
),
|
|
'compact' => false,
|
|
'dimUnchanged' => true,
|
|
]);
|
|
|
|
$unchanged = (string) $this->view('filament.partials.diff.row', [
|
|
'row' => new DiffRow(
|
|
key: 'display_name',
|
|
label: 'Display name',
|
|
status: DiffRowStatus::Unchanged,
|
|
oldValue: 'TenantPilot',
|
|
newValue: 'TenantPilot',
|
|
),
|
|
'compact' => false,
|
|
'dimUnchanged' => true,
|
|
]);
|
|
|
|
expect($added)->toContain('Added')
|
|
->and($added)->toContain('Enabled')
|
|
->and($removed)->toContain('Removed')
|
|
->and($removed)->toContain('Legacy')
|
|
->and($unchanged)->toContain('Unchanged')
|
|
->and($unchanged)->toContain('TenantPilot');
|
|
});
|
|
|
|
it('delegates list-like rows to the inline list partial and dims unchanged content when requested', function (): void {
|
|
$listRow = (string) $this->view('filament.partials.diff.row', [
|
|
'row' => new DiffRow(
|
|
key: 'scope_tags',
|
|
label: 'Scope tags',
|
|
status: DiffRowStatus::Changed,
|
|
oldValue: ['Default', 'Legacy', 'Shared'],
|
|
newValue: ['Default', 'Shared', 'Workspace'],
|
|
isListLike: true,
|
|
addedItems: ['Workspace'],
|
|
removedItems: ['Legacy'],
|
|
unchangedItems: ['Default', 'Shared'],
|
|
),
|
|
'compact' => false,
|
|
'dimUnchanged' => true,
|
|
]);
|
|
|
|
$unchanged = (string) $this->view('filament.partials.diff.row', [
|
|
'row' => new DiffRow(
|
|
key: 'display_name',
|
|
label: 'Display name',
|
|
status: DiffRowStatus::Unchanged,
|
|
oldValue: 'TenantPilot',
|
|
newValue: 'TenantPilot',
|
|
),
|
|
'compact' => false,
|
|
'dimUnchanged' => true,
|
|
]);
|
|
|
|
expect($listRow)->toContain('Added items')
|
|
->and($listRow)->toContain('Removed items')
|
|
->and($listRow)->toContain('Unchanged items')
|
|
->and($unchanged)->toContain('text-gray-500')
|
|
->and($unchanged)->toContain('dark:text-gray-400');
|
|
});
|