Closed CodeWithDennis closed 2 months ago
This same bug appears to be present for sorting columns too
@CodeWithDennis A potential fix would be to check if $search
is an enum. And additional to check if it hasLabel().
But there remains a few unknowns. What about non backed enumns, what if you dont use the HasLabel
trait? 🤔
it('can search column', function (string $column) {
$records = Group::factory(3)->for($this->club)->create();
$search = $records->first()->{$column};
if ($search instanceof UnitEnum) {
if (method_exists($search, 'getLabel')) {
$search = $search->getLabel();
}
}
livewire(ListGroups::class)
->searchTable($search)
->assertCanSeeTableRecords($records->where($column, $search))
->assertCanNotSeeTableRecords($records->where($column, '!=', $search));
})->with(['status'])->group('columns', 'index', 'page', 'resource', 'table');
Anyway, this potentially requires logic inside the stub.
Additional refs: https://stackoverflow.com/questions/70237057/how-to-check-if-enum-type