F
Filament11mo ago
nät

Testing

My test 'it can display a page' does not count the one's that are created in factory
beforeEach(function () {
$org = Organization::factory()->create();
$users = User::factory()->create();
$adminRole = Role::create(['name' => 'super_admin', 'organization_id' => 1]);

setPermissionsTeamId($org->id);

$users->organization()->associate($org);
$users->assignRole($adminRole);

Filament::setCurrentPanel(Filament::getPanel('admin'));

actingAs(User::first());

Gate::before(function (User $user) {
return $user->where('super_admin') ? true : null;
});
});

it('can display a page', function () {
$user = User::factory()->count(3)->create();
// dd($user->count());
livewire(ListUsers::class)
->assertCanSeeTableRecords($user)
->assertCountTableRecords($user->count())
->assertOk();
});
beforeEach(function () {
$org = Organization::factory()->create();
$users = User::factory()->create();
$adminRole = Role::create(['name' => 'super_admin', 'organization_id' => 1]);

setPermissionsTeamId($org->id);

$users->organization()->associate($org);
$users->assignRole($adminRole);

Filament::setCurrentPanel(Filament::getPanel('admin'));

actingAs(User::first());

Gate::before(function (User $user) {
return $user->where('super_admin') ? true : null;
});
});

it('can display a page', function () {
$user = User::factory()->count(3)->create();
// dd($user->count());
livewire(ListUsers::class)
->assertCanSeeTableRecords($user)
->assertCountTableRecords($user->count())
->assertOk();
});
5 Replies
LeandroFerreira
LeandroFerreira11mo ago
you are creating users before each What is dd(User::count()) showing?
nät
nätOP11mo ago
It's showing
4
4
LeandroFerreira
LeandroFerreira11mo ago
livewire(ListUsers::class)
->assertOk();
livewire(ListUsers::class)
->assertOk();
What is the output?
nät
nätOP11mo ago
the output is this
No description
LeandroFerreira
LeandroFerreira11mo ago
What happens if you ->skip() this test?
Want results from more Discord servers?
Add your server