From efb2cf8635c4b78974ad5a2daeb7c3d89f9f0687 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Mon, 29 Sep 2025 20:32:05 +0700 Subject: [PATCH] feat(test): menambahkan assertHasNoErrors() dan assertDispatched('refreshDatatable') --- tests/Feature/Livewire/Studio/Catalog/CategoryTest.php | 3 +++ tests/Feature/Livewire/Studio/Loyalty/MembershipTest.php | 3 +++ tests/Feature/Livewire/Studio/Loyalty/Voucher/CreateTest.php | 1 + tests/Feature/Livewire/Studio/Loyalty/Voucher/EditTest.php | 1 + tests/Feature/Livewire/Studio/Loyalty/Voucher/IndexTest.php | 1 + tests/Feature/Livewire/Studio/Master/Outlet/CreateTest.php | 2 ++ tests/Feature/Livewire/Studio/Master/Outlet/EditTest.php | 1 + tests/Feature/Livewire/Studio/Master/Outlet/IndexTest.php | 1 + tests/Feature/Livewire/Studio/Master/User/IndexTest.php | 1 + 9 files changed, 14 insertions(+) diff --git a/tests/Feature/Livewire/Studio/Catalog/CategoryTest.php b/tests/Feature/Livewire/Studio/Catalog/CategoryTest.php index 3cf1f18..ec22577 100644 --- a/tests/Feature/Livewire/Studio/Catalog/CategoryTest.php +++ b/tests/Feature/Livewire/Studio/Catalog/CategoryTest.php @@ -31,6 +31,7 @@ ->set('form.description', $data['description']) ->set('form.sort_order', $data['sort_order']) ->call('create') + ->assertHasNoErrors() ->assertDispatched('refreshDatatable'); expect(CategoryModel::count())->toBe(1); @@ -48,6 +49,7 @@ ->set('form.description', $data['description']) ->set('form.sort_order', $data['sort_order']) ->call('update') + ->assertHasNoErrors() ->assertDispatched('refreshDatatable'); $category->refresh(); @@ -61,6 +63,7 @@ Livewire::test(Category::class) ->call('delete', $category) + ->assertHasNoErrors() ->assertDispatched('refreshDatatable'); expect(CategoryModel::count())->toBe(0); diff --git a/tests/Feature/Livewire/Studio/Loyalty/MembershipTest.php b/tests/Feature/Livewire/Studio/Loyalty/MembershipTest.php index bfc46bf..1e0f6b6 100644 --- a/tests/Feature/Livewire/Studio/Loyalty/MembershipTest.php +++ b/tests/Feature/Livewire/Studio/Loyalty/MembershipTest.php @@ -30,6 +30,7 @@ ->set('form.discount_percentage', $data['discount_percentage']) ->set('form.terms_conditions', $data['terms_conditions']) ->call('create') + ->assertHasNoErrors() ->assertDispatched('refreshDatatable'); expect(MembershipModel::count())->toBe(1); @@ -48,6 +49,7 @@ ->set('form.discount_percentage', $data['discount_percentage']) ->set('form.terms_conditions', $data['terms_conditions']) ->call('update') + ->assertHasNoErrors() ->assertDispatched('refreshDatatable'); $membership->refresh(); @@ -62,6 +64,7 @@ Livewire::test(Membership::class) ->call('delete', $membership) + ->assertHasNoErrors() ->assertDispatched('refreshDatatable'); expect(MembershipModel::count())->toBe(0); diff --git a/tests/Feature/Livewire/Studio/Loyalty/Voucher/CreateTest.php b/tests/Feature/Livewire/Studio/Loyalty/Voucher/CreateTest.php index a19ec94..3b98514 100644 --- a/tests/Feature/Livewire/Studio/Loyalty/Voucher/CreateTest.php +++ b/tests/Feature/Livewire/Studio/Loyalty/Voucher/CreateTest.php @@ -34,6 +34,7 @@ ->set('form.is_active', $data['is_active']->value) ->call('save') ->assertHasNoErrors() + ->assertDispatched('refreshDatatable') ->assertRedirect(Index::class); $this->assertDatabaseHas('vouchers', [ diff --git a/tests/Feature/Livewire/Studio/Loyalty/Voucher/EditTest.php b/tests/Feature/Livewire/Studio/Loyalty/Voucher/EditTest.php index c34e655..39dffd2 100644 --- a/tests/Feature/Livewire/Studio/Loyalty/Voucher/EditTest.php +++ b/tests/Feature/Livewire/Studio/Loyalty/Voucher/EditTest.php @@ -40,6 +40,7 @@ ->set('form.max_discount', $data['max_discount']) ->set('form.is_active', $data['is_active']->value) ->call('save') + ->assertHasNoErrors() ->assertDispatched('refreshDatatable') ->assertRedirect(Index::class); diff --git a/tests/Feature/Livewire/Studio/Loyalty/Voucher/IndexTest.php b/tests/Feature/Livewire/Studio/Loyalty/Voucher/IndexTest.php index 80de996..0c6ca6b 100644 --- a/tests/Feature/Livewire/Studio/Loyalty/Voucher/IndexTest.php +++ b/tests/Feature/Livewire/Studio/Loyalty/Voucher/IndexTest.php @@ -36,6 +36,7 @@ Livewire::test(Index::class) ->call('delete', $voucher) + ->assertHasNoErrors() ->assertDispatched('refreshDatatable'); expect(Voucher::count())->toBe(0); diff --git a/tests/Feature/Livewire/Studio/Master/Outlet/CreateTest.php b/tests/Feature/Livewire/Studio/Master/Outlet/CreateTest.php index e2ce11a..fa6a36c 100644 --- a/tests/Feature/Livewire/Studio/Master/Outlet/CreateTest.php +++ b/tests/Feature/Livewire/Studio/Master/Outlet/CreateTest.php @@ -28,6 +28,8 @@ ->set('form.opened_date', $data['opened_date']) ->set('form.status', $data['status']->value) ->call('save') + ->assertHasNoErrors() + ->assertDispatched('refreshDatatable') ->assertRedirect(Index::class); $this->assertDatabaseHas('outlets', [ diff --git a/tests/Feature/Livewire/Studio/Master/Outlet/EditTest.php b/tests/Feature/Livewire/Studio/Master/Outlet/EditTest.php index 5d10d0c..c5e03b2 100644 --- a/tests/Feature/Livewire/Studio/Master/Outlet/EditTest.php +++ b/tests/Feature/Livewire/Studio/Master/Outlet/EditTest.php @@ -32,6 +32,7 @@ ->set('form.opened_date', $data['opened_date']) ->set('form.status', $data['status']->value) ->call('save') + ->assertHasNoErrors() ->assertDispatched('refreshDatatable') ->assertRedirect(Index::class); diff --git a/tests/Feature/Livewire/Studio/Master/Outlet/IndexTest.php b/tests/Feature/Livewire/Studio/Master/Outlet/IndexTest.php index a69922c..7456814 100644 --- a/tests/Feature/Livewire/Studio/Master/Outlet/IndexTest.php +++ b/tests/Feature/Livewire/Studio/Master/Outlet/IndexTest.php @@ -32,6 +32,7 @@ Livewire::test(Index::class) ->call('delete', $outlet) + ->assertHasNoErrors() ->assertDispatched('refreshDatatable'); expect(Outlet::count())->toBe(0); diff --git a/tests/Feature/Livewire/Studio/Master/User/IndexTest.php b/tests/Feature/Livewire/Studio/Master/User/IndexTest.php index ef33b24..1b4cea0 100644 --- a/tests/Feature/Livewire/Studio/Master/User/IndexTest.php +++ b/tests/Feature/Livewire/Studio/Master/User/IndexTest.php @@ -32,6 +32,7 @@ Livewire::test(Index::class) ->call('delete', $user) + ->assertHasNoErrors() ->assertDispatched('refreshDatatable'); expect(User::count())->toBe(0);