#Creating a test for ToggleColumn
13 messages · Page 1 of 1 (latest)
bump
this is what i have so far:
// T7. Test visibility toggle column functionality
it('has functioning visibility toggle column', function () {
$category = Category::factory()->create(['is_active' => true]);
livewire(ListCategories::class)
->assertCanRenderTableColumn('is_active')
->assertTableColumnStateSet('is_active', true, $category)
->callTableColumnAction('is_active', $category)
->assertTableColumnStateSet('is_active', false, $category);
$category->refresh();
expect($category->is_active)->toBeFalse();
})->group('table');
bump
bump
the output:
FAILED Tests\Feature\Filament\CategoryResource\ListTest > `Category Table` → it has functioning visibility toggle column
Failed asserting that a table column with name [is_active] has value of [] for record [11] on the [App\Filament\Resources\CategoryResource\Pages\ListCategories] component.
Failed asserting that false is true.
at vendor\filament\tables\src\Testing\TestsColumns.php:193
189▕ if (is_array($value)) {
190▕ $value = json_encode($value);
191▕ }
192▕
➜ 193▕ Assert::assertTrue(
194▕ $state == $value,
195▕ message: "Failed asserting that a table column with name [{$name}] has value of [{$value}] for record [{$record->getKey()}] on the [{$livewireClass}] component.",
196▕ );
197▕
1 vendor\filament\tables\src\Testing\TestsColumns.php:193
2 vendor\laravel\framework\src\Illuminate\Macroable\Traits\Macroable.php:123
Is ‘is_active’ an action?
i would assume so, cause its a ToggleColumn.