groenewege
groenewege
FFilament
Created by jaocero on 11/2/2023 in #❓┊help
How to test a simple resource CRUD functionality?
This is how I test modal actions on a relation page, which is similar to a simple (modal) resource :
test('superadmin can create sub-tag', function () {
$this->signInAsSuperAdmin();
$tag = Tag::where('name', 'Prévention')->first();
livewire(ManageTagChildren::class, ['record' => $tag->id])
->callTableAction('create', null, [
'name' => 'tag bis',
]);

$this->assertDatabaseHas(Tag::class, [
'name' => 'tag bis',
]);
});

test('superadmin can edit sub-tag', function () {
$this->signInAsSuperAdmin();
$tag = Tag::where('name', 'Prévention')->first();
$subTag = Tag::where('name', 'Vaccination')->first();
livewire(ManageTagChildren::class, ['record' => $tag->id])
->callTableAction('edit', $subTag, [
'name' => 'tag ter',
]);

$this->assertDatabaseHas(Tag::class, [
'name' => 'tag ter',
]);
});
test('superadmin can create sub-tag', function () {
$this->signInAsSuperAdmin();
$tag = Tag::where('name', 'Prévention')->first();
livewire(ManageTagChildren::class, ['record' => $tag->id])
->callTableAction('create', null, [
'name' => 'tag bis',
]);

$this->assertDatabaseHas(Tag::class, [
'name' => 'tag bis',
]);
});

test('superadmin can edit sub-tag', function () {
$this->signInAsSuperAdmin();
$tag = Tag::where('name', 'Prévention')->first();
$subTag = Tag::where('name', 'Vaccination')->first();
livewire(ManageTagChildren::class, ['record' => $tag->id])
->callTableAction('edit', $subTag, [
'name' => 'tag ter',
]);

$this->assertDatabaseHas(Tag::class, [
'name' => 'tag ter',
]);
});
6 replies
FFilament
Created by groenewege on 9/12/2023 in #❓┊help
How to test with multi-tenancy ?
@pboivin thank you that works ! However, the call must be made after loging in a user.
5 replies