48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Support\Diff\DiffRow;
|
|
use App\Support\Diff\DiffRowStatus;
|
|
|
|
it('renders inline list fragments with semantic labels muted unchanged items and stable reading order', function (): void {
|
|
$baseline = array_map(
|
|
static fn (int $index): string => sprintf('Group %02d', $index),
|
|
range(1, 24),
|
|
);
|
|
|
|
$current = array_map(
|
|
static fn (int $index): string => sprintf('Group %02d', $index),
|
|
range(2, 25),
|
|
);
|
|
|
|
$html = (string) $this->view('filament.partials.diff.inline-list', [
|
|
'row' => new DiffRow(
|
|
key: 'group_assignments',
|
|
label: 'Group assignments',
|
|
status: DiffRowStatus::Changed,
|
|
oldValue: $baseline,
|
|
newValue: $current,
|
|
isListLike: true,
|
|
addedItems: ['Group 25'],
|
|
removedItems: ['Group 01'],
|
|
unchangedItems: array_values(array_intersect($current, $baseline)),
|
|
),
|
|
'compact' => false,
|
|
'dimUnchanged' => true,
|
|
]);
|
|
|
|
expect($html)->toContain('Added items')
|
|
->and($html)->toContain('Removed items')
|
|
->and($html)->toContain('Unchanged items')
|
|
->and($html)->toContain('Group 25')
|
|
->and($html)->toContain('Group 01')
|
|
->and($html)->toContain('Group 12')
|
|
->and($html)->toContain('text-gray-500')
|
|
->and($html)->toContain('dark:text-gray-400')
|
|
->and(substr_count($html, 'rounded-full'))->toBe(25);
|
|
|
|
expect(strpos($html, 'Added items'))->toBeLessThan(strpos($html, 'Removed items'));
|
|
expect(strpos($html, 'Removed items'))->toBeLessThan(strpos($html, 'Unchanged items'));
|
|
});
|