group('admin-components');
describe('Admin Manager Table Component', function () {
it('renders table with columns and rows', function () {
$columns = ['Name', 'Email', 'Status'];
$rows = [
['John Doe', 'john@example.com', 'Active'],
['Jane Smith', 'jane@example.com', 'Pending'],
];
$html = Blade::render('', [
'columns' => $columns,
'rows' => $rows,
]);
expect($html)
->toContain('Name')
->toContain('Email')
->toContain('Status')
->toContain('John Doe')
->toContain('john@example.com')
->toContain('Jane Smith');
});
it('renders empty state when no rows', function () {
$columns = ['Name', 'Email'];
$rows = [];
$empty = 'No users found.';
$html = Blade::render('', [
'columns' => $columns,
'rows' => $rows,
'empty' => $empty,
]);
expect($html)->toContain('No users found.');
});
it('renders bold cell type', function () {
$columns = ['Name'];
$rows = [
[['bold' => 'Important Name']],
];
$html = Blade::render('', [
'columns' => $columns,
'rows' => $rows,
]);
expect($html)
->toContain('Important Name')
->toContain('font-medium');
});
it('renders badge cell type', function () {
$columns = ['Status'];
$rows = [
[['badge' => 'Active', 'color' => 'green']],
];
$html = Blade::render('', [
'columns' => $columns,
'rows' => $rows,
]);
expect($html)
->toContain('Active')
->toContain('rounded-full');
});
it('renders multi-line cells', function () {
$columns = ['User'];
$rows = [
[['lines' => [
['bold' => 'John Doe'],
['muted' => 'john@example.com'],
]]],
];
$html = Blade::render('', [
'columns' => $columns,
'rows' => $rows,
]);
expect($html)
->toContain('John Doe')
->toContain('john@example.com');
});
it('renders action buttons', function () {
$columns = ['Name', 'Actions'];
$rows = [
[
'Test Item',
['actions' => [
['icon' => 'pencil', 'click' => 'edit(1)', 'title' => 'Edit'],
['icon' => 'trash', 'click' => 'delete(1)', 'confirm' => 'Are you sure?'],
]],
],
];
$html = Blade::render('', [
'columns' => $columns,
'rows' => $rows,
]);
expect($html)
->toContain('wire:click="edit(1)"')
->toContain('wire:click="delete(1)"')
->toContain('wire:confirm="Are you sure?"');
});
it('supports column alignment', function () {
$columns = [
'Name',
['label' => 'Count', 'align' => 'right'],
['label' => 'Actions', 'align' => 'center'],
];
$rows = [['Test', '10', 'Action']];
$html = Blade::render('', [
'columns' => $columns,
'rows' => $rows,
]);
expect($html)
->toContain('text-right')
->toContain('text-center');
});
});
describe('Admin Flash Component', function () {
it('renders success message from session', function () {
session()->flash('message', 'Operation successful!');
$html = Blade::render('');
expect($html)
->toContain('Operation successful!')
->toContain('bg-green-100');
});
it('renders error message from session', function () {
session()->flash('error', 'Something went wrong!');
$html = Blade::render('');
expect($html)
->toContain('Something went wrong!')
->toContain('bg-red-100');
});
it('renders nothing when no session messages', function () {
session()->forget(['message', 'error']);
$html = Blade::render('');
expect(trim($html))->toBe('');
});
it('supports custom session keys', function () {
session()->flash('custom_key', 'Custom message');
$html = Blade::render('');
expect($html)->toContain('Custom message');
});
});
describe('Admin Filter Bar Component', function () {
it('renders with default 4 columns', function () {
$html = Blade::render('Filter content
');
expect($html)
->toContain('sm:grid-cols-4')
->toContain('Filter content');
});
it('renders with custom column count', function () {
$html = Blade::render('Content
');
expect($html)->toContain('sm:grid-cols-3');
});
it('renders with 2 columns', function () {
$html = Blade::render('Content
');
expect($html)->toContain('sm:grid-cols-2');
});
it('renders with 5 columns', function () {
$html = Blade::render('Content
');
expect($html)->toContain('sm:grid-cols-5');
});
});
describe('Admin Search Component', function () {
it('renders search input', function () {
$html = Blade::render('');
expect($html)
->toContain('type="text"')
->toContain('magnifying-glass');
});
it('renders with custom placeholder', function () {
$html = Blade::render('');
expect($html)->toContain('placeholder="Search users..."');
});
it('renders with wire:model binding', function () {
$html = Blade::render('');
expect($html)->toContain('wire:model.live.debounce.300ms="searchTerm"');
});
});
describe('Admin Filter Component', function () {
it('renders select with placeholder', function () {
$html = Blade::render('');
expect($html)
->toContain('