Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
luanfreitasdev committed Dec 28, 2023
1 parent f9f6f9d commit 8d7f27f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
8 changes: 5 additions & 3 deletions resources/views/components/row.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
<div class="pg-actions">
@if (filled(data_get($row, 'actions')) && $column->isAction)
@foreach (data_get($row, 'actions') as $key => $action)
<div wire:key="action-{{ data_get($row, $primaryKey) }}-{{ $key }}">
{!! $action !!}
</div>
@if(filled($action))
<div wire:key="action-{{ data_get($row, $primaryKey) }}-{{ $key }}">
{!! $action !!}
</div>
@endif
@endforeach
@endif
</div>
Expand Down
37 changes: 29 additions & 8 deletions tests/Feature/ActionRules/HideTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ public function actionRules($row): array
}
};

$hidePreventShowHtml = new class () extends DishTableBase {
public function actions($row): array
{
return [
Button::add('edit')
->slot('test')
->id()
->dispatch('edit', ['dishId' => $row->id]),
];
}

public function actionRules($row): array
{
return [
Rule::button('edit')
->when(fn ($row) => $row->id === 1)
->hide(),
];
}
};

it('properly displays "hide" on edit button', function (string $component, object $params) {
livewire($component, [
'join' => $params->join,
Expand All @@ -66,20 +87,20 @@ public function actionRules($row): array
])
->group('action');

it('properly displays "hide" on render button', function (string $component, object $params) {
it('does not show the html of actions when hide is activated', function (string $component, object $params) {
livewire($component, [
'join' => $params->join,
])
->call($params->theme)
->set('setUp.footer.perPage', 3)
->assertSeeHtml("render - 1")
->assertSeeHtml("render - 2")
->assertDontSeeHtml("render - 3");
->assertDontSeeHtml("action-1-render-action.0.edit")
->assertSeeHtml("action-2-render-action.0.edit")
->assertSeeHtml("action-3-render-action.0.edit");
})
->with([
'tailwind' => [$hideWithRender::class, (object) ['theme' => 'tailwind', 'join' => false]],
'bootstrap' => [$hideWithRender::class, (object) ['theme' => 'bootstrap', 'join' => false]],
'tailwind join' => [$hideWithRender::class, (object) ['theme' => 'tailwind', 'join' => true]],
'bootstrap join' => [$hideWithRender::class, (object) ['theme' => 'bootstrap', 'join' => true]],
'tailwind' => [$hidePreventShowHtml::class, (object) ['theme' => 'tailwind', 'join' => false]],
'bootstrap' => [$hidePreventShowHtml::class, (object) ['theme' => 'bootstrap', 'join' => false]],
'tailwind join' => [$hidePreventShowHtml::class, (object) ['theme' => 'tailwind', 'join' => true]],
'bootstrap join' => [$hidePreventShowHtml::class, (object) ['theme' => 'bootstrap', 'join' => true]],
])
->group('action');

0 comments on commit 8d7f27f

Please sign in to comment.