|
| 1 | +<?php |
| 2 | + |
| 3 | +use PowerComponents\LivewirePowerGrid\Button; |
| 4 | +use PowerComponents\LivewirePowerGrid\Tests\Concerns\Components\DishTableBase; |
| 5 | + |
| 6 | +use function PowerComponents\LivewirePowerGrid\Tests\Plugins\livewire; |
| 7 | + |
| 8 | +$component = new class () extends DishTableBase { |
| 9 | + public function actions($row): array |
| 10 | + { |
| 11 | + return [ |
| 12 | + Button::make('confirm-prompt') |
| 13 | + ->slot('confirm-prompt: ' . $row->id) |
| 14 | + ->confirmPrompt("$row->id Are you sure? Enter CONFIRM to confirm", "CONFIRM"), |
| 15 | + ]; |
| 16 | + } |
| 17 | +}; |
| 18 | + |
| 19 | +dataset('action:confirm-prompt', [ |
| 20 | + 'tailwind' => [$component::class, (object) ['theme' => 'tailwind', 'join' => false]], |
| 21 | + 'bootstrap' => [$component::class, (object) ['theme' => 'bootstrap', 'join' => false]], |
| 22 | + 'tailwind join' => [$component::class, (object) ['theme' => 'tailwind', 'join' => true]], |
| 23 | + 'bootstrap join' => [$component::class, (object) ['theme' => 'bootstrap', 'join' => true]], |
| 24 | +]); |
| 25 | + |
| 26 | +it('properly displays "confirm" on button click', function (string $component, object $params) { |
| 27 | + livewire($component, [ |
| 28 | + 'join' => $params->join, |
| 29 | + ]) |
| 30 | + ->call($params->theme) |
| 31 | + ->set('search', 'Pastel de Nata') |
| 32 | + ->assertSeeHtml('wire:confirm.prompt="1 Are you sure? Enter CONFIRM to confirm |CONFIRM"') |
| 33 | + ->assertDontSeeHtml('wire:confirm.prompt="2 Are you sure? Enter CONFIRM to confirm |CONFIRM"') |
| 34 | + ->set('search', 'Peixada da chef Nábia') |
| 35 | + ->assertSeeHtml('wire:confirm.prompt="2 Are you sure? Enter CONFIRM to confirm |CONFIRM"') |
| 36 | + ->assertDontSeeHtml('wire:confirm.prompt="1 Are you sure? Enter CONFIRM to confirm |CONFIRM"'); |
| 37 | +}) |
| 38 | + ->with('action:confirm-prompt') |
| 39 | + ->group('action'); |
0 commit comments