From 080972fc1dd774180ebd90f34537b7e545b31f9b Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 20:33:22 +0200 Subject: [PATCH 01/11] Dispatch an event when params change --- src/Http/Livewire/LivewireCollection.php | 1 + src/Http/Livewire/Traits/HandleParams.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/Http/Livewire/LivewireCollection.php b/src/Http/Livewire/LivewireCollection.php index 6baa4e9..49f3f76 100644 --- a/src/Http/Livewire/LivewireCollection.php +++ b/src/Http/Livewire/LivewireCollection.php @@ -32,6 +32,7 @@ public function mount($params) } else { $this->setParameters(array_merge($params, $this->params)); } + $this->dispatch('params-updated', $this->params); } #[On('filter-mounted')] diff --git a/src/Http/Livewire/Traits/HandleParams.php b/src/Http/Livewire/Traits/HandleParams.php index 775fc23..71ffc20 100644 --- a/src/Http/Livewire/Traits/HandleParams.php +++ b/src/Http/Livewire/Traits/HandleParams.php @@ -119,6 +119,8 @@ protected function runCommand($command, $paramKey, $value) throw new CommandNotFoundException($command); break; } + + $this->dispatch('params-updated', $this->params); } protected function addValueToParam($paramKey, $value) From b104ff08100dbc69839a8d51d23f7ec88b5030a7 Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 20:43:39 +0200 Subject: [PATCH 02/11] Prepare a counts array to hold the count values --- src/Http/Livewire/Traits/IsLivewireFilter.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Http/Livewire/Traits/IsLivewireFilter.php b/src/Http/Livewire/Traits/IsLivewireFilter.php index 8285e44..04f5d2f 100644 --- a/src/Http/Livewire/Traits/IsLivewireFilter.php +++ b/src/Http/Livewire/Traits/IsLivewireFilter.php @@ -48,8 +48,19 @@ public function initiateField() collect($field->config()['taxonomies'])->each(function ($taxonomy) use ($terms) { $terms->push(($this->getTaxonomyTerms($taxonomy)->all())); }); - $field->setConfig(['options' => $terms->collapse()->all()]); + $field->setConfig([ + 'options' => $terms->collapse()->all(), + 'counts' => $terms->collapse()->keys()->flatMap(fn ($slug) => [$slug => null])->all(), + ]); + } else { + if (array_key_exists('options', $field->toArray())) { + $field->setConfig(array_merge( + $field->config(), + ['counts' => collect($field->get('options'))->keys()->flatMap(fn ($option) => [$option => null])->all()] + )); + } } + $this->statamic_field = $field->toArray(); } From 57bfa4c11b0e433c9cc494f0b4314c49d5ff7023 Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 20:43:59 +0200 Subject: [PATCH 03/11] Handle count in a trait --- src/Http/Livewire/LfCheckboxFilter.php | 2 +- src/Http/Livewire/LfRadioFilter.php | 2 +- .../Livewire/Traits/HandleEntriesCount.php | 29 +++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/Http/Livewire/Traits/HandleEntriesCount.php diff --git a/src/Http/Livewire/LfCheckboxFilter.php b/src/Http/Livewire/LfCheckboxFilter.php index 5269a5c..682a658 100644 --- a/src/Http/Livewire/LfCheckboxFilter.php +++ b/src/Http/Livewire/LfCheckboxFilter.php @@ -9,7 +9,7 @@ class LfCheckboxFilter extends Component { - use Traits\IsLivewireFilter; + use Traits\IsLivewireFilter, Traits\HandleEntriesCount;; public $view = 'lf-checkbox'; diff --git a/src/Http/Livewire/LfRadioFilter.php b/src/Http/Livewire/LfRadioFilter.php index d231bca..f75f304 100644 --- a/src/Http/Livewire/LfRadioFilter.php +++ b/src/Http/Livewire/LfRadioFilter.php @@ -9,7 +9,7 @@ class LfRadioFilter extends Component { - use Traits\IsLivewireFilter; + use Traits\IsLivewireFilter, Traits\HandleEntriesCount; public $view = 'lf-radio'; diff --git a/src/Http/Livewire/Traits/HandleEntriesCount.php b/src/Http/Livewire/Traits/HandleEntriesCount.php new file mode 100644 index 0000000..4c48eb5 --- /dev/null +++ b/src/Http/Livewire/Traits/HandleEntriesCount.php @@ -0,0 +1,29 @@ +statamic_field['counts']; + } + + #[On('params-updated')] + public function updateCounts($params) + { + foreach ($this->statamic_field['options'] as $option => $label) { + $params = array_merge($params, [$this->getParamKey() => $option]); + $this->statamic_field['counts'][$option] = (new Entries($this->generateParamsForCount($this->collection, $params)))->count(); + } + } + +} From d2ac383b55a186285bede9019703d891da04ace4 Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 20:45:22 +0200 Subject: [PATCH 04/11] Typo & Pint --- src/Http/Livewire/LfCheckboxFilter.php | 2 +- src/Http/Livewire/LfRadioFilter.php | 2 +- src/Http/Livewire/Traits/HandleEntriesCount.php | 8 +++----- src/Http/Livewire/Traits/HandleParams.php | 2 +- src/Http/Livewire/Traits/IsLivewireFilter.php | 2 +- tests/__fixtures__/content/collections/pages.yaml | 1 + 6 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 tests/__fixtures__/content/collections/pages.yaml diff --git a/src/Http/Livewire/LfCheckboxFilter.php b/src/Http/Livewire/LfCheckboxFilter.php index 682a658..119f723 100644 --- a/src/Http/Livewire/LfCheckboxFilter.php +++ b/src/Http/Livewire/LfCheckboxFilter.php @@ -9,7 +9,7 @@ class LfCheckboxFilter extends Component { - use Traits\IsLivewireFilter, Traits\HandleEntriesCount;; + use Traits\HandleEntriesCount, Traits\IsLivewireFilter; public $view = 'lf-checkbox'; diff --git a/src/Http/Livewire/LfRadioFilter.php b/src/Http/Livewire/LfRadioFilter.php index f75f304..bc216bb 100644 --- a/src/Http/Livewire/LfRadioFilter.php +++ b/src/Http/Livewire/LfRadioFilter.php @@ -9,7 +9,7 @@ class LfRadioFilter extends Component { - use Traits\IsLivewireFilter, Traits\HandleEntriesCount; + use Traits\HandleEntriesCount, Traits\IsLivewireFilter; public $view = 'lf-radio'; diff --git a/src/Http/Livewire/Traits/HandleEntriesCount.php b/src/Http/Livewire/Traits/HandleEntriesCount.php index 4c48eb5..0c3a16a 100644 --- a/src/Http/Livewire/Traits/HandleEntriesCount.php +++ b/src/Http/Livewire/Traits/HandleEntriesCount.php @@ -2,10 +2,9 @@ namespace Reach\StatamicLivewireFilters\Http\Livewire\Traits; -use Statamic\Tags\Collection\Entries; -use Livewire\Attributes\On; use Livewire\Attributes\Computed; - +use Livewire\Attributes\On; +use Statamic\Tags\Collection\Entries; trait HandleEntriesCount { @@ -14,7 +13,7 @@ trait HandleEntriesCount #[Computed] public function counts() { - return $this->statamic_field['counts']; + return $this->statamic_field['counts']; } #[On('params-updated')] @@ -25,5 +24,4 @@ public function updateCounts($params) $this->statamic_field['counts'][$option] = (new Entries($this->generateParamsForCount($this->collection, $params)))->count(); } } - } diff --git a/src/Http/Livewire/Traits/HandleParams.php b/src/Http/Livewire/Traits/HandleParams.php index 71ffc20..d9338ec 100644 --- a/src/Http/Livewire/Traits/HandleParams.php +++ b/src/Http/Livewire/Traits/HandleParams.php @@ -119,7 +119,7 @@ protected function runCommand($command, $paramKey, $value) throw new CommandNotFoundException($command); break; } - + $this->dispatch('params-updated', $this->params); } diff --git a/src/Http/Livewire/Traits/IsLivewireFilter.php b/src/Http/Livewire/Traits/IsLivewireFilter.php index 04f5d2f..0127144 100644 --- a/src/Http/Livewire/Traits/IsLivewireFilter.php +++ b/src/Http/Livewire/Traits/IsLivewireFilter.php @@ -55,7 +55,7 @@ public function initiateField() } else { if (array_key_exists('options', $field->toArray())) { $field->setConfig(array_merge( - $field->config(), + $field->config(), ['counts' => collect($field->get('options'))->keys()->flatMap(fn ($option) => [$option => null])->all()] )); } diff --git a/tests/__fixtures__/content/collections/pages.yaml b/tests/__fixtures__/content/collections/pages.yaml new file mode 100644 index 0000000..7ded12f --- /dev/null +++ b/tests/__fixtures__/content/collections/pages.yaml @@ -0,0 +1 @@ +revisions: false From d76eedc10764e220ac22d5b31db9e2923ee67f87 Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 21:11:40 +0200 Subject: [PATCH 05/11] Query scope support --- src/Http/Livewire/Traits/HandleEntriesCount.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Http/Livewire/Traits/HandleEntriesCount.php b/src/Http/Livewire/Traits/HandleEntriesCount.php index 0c3a16a..3790ee7 100644 --- a/src/Http/Livewire/Traits/HandleEntriesCount.php +++ b/src/Http/Livewire/Traits/HandleEntriesCount.php @@ -20,8 +20,20 @@ public function counts() public function updateCounts($params) { foreach ($this->statamic_field['options'] as $option => $label) { - $params = array_merge($params, [$this->getParamKey() => $option]); + $params = array_merge($params, $this->getOptionParam($option)); $this->statamic_field['counts'][$option] = (new Entries($this->generateParamsForCount($this->collection, $params)))->count(); } } + + protected function getOptionParam($option) + { + if ($this->condition === 'query_scope') { + return [ + 'query_scope' => $this->modifier, + $this->getParamKey() => $option, + ]; + } + + return [$this->getParamKey() => $option]; + } } From e34b0cdc77778039a289a61d04a884229a0b38ab Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 21:27:17 +0200 Subject: [PATCH 06/11] Add config option, make it disabled by default --- config/config.php | 2 ++ src/Http/Livewire/LivewireCollection.php | 2 +- src/Http/Livewire/Traits/HandleParams.php | 10 +++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index f61aa77..444e713 100644 --- a/config/config.php +++ b/config/config.php @@ -13,4 +13,6 @@ // If enabled the addon will preset the term parameters in any taxonomy term routes 'enable_term_routes' => false, + // The addon will calculate the number of entries for each filter value (can be slow for a large number of entries) + 'enable_filter_values_count' => true, ]; diff --git a/src/Http/Livewire/LivewireCollection.php b/src/Http/Livewire/LivewireCollection.php index 49f3f76..38cff61 100644 --- a/src/Http/Livewire/LivewireCollection.php +++ b/src/Http/Livewire/LivewireCollection.php @@ -32,7 +32,7 @@ public function mount($params) } else { $this->setParameters(array_merge($params, $this->params)); } - $this->dispatch('params-updated', $this->params); + $this->dispatchParamsUpdated(); } #[On('filter-mounted')] diff --git a/src/Http/Livewire/Traits/HandleParams.php b/src/Http/Livewire/Traits/HandleParams.php index d9338ec..92792d6 100644 --- a/src/Http/Livewire/Traits/HandleParams.php +++ b/src/Http/Livewire/Traits/HandleParams.php @@ -98,6 +98,7 @@ protected function handleQueryScopeCondition($field, $payload, $command, $modifi default: throw new CommandNotFoundException($command); } + $this->dispatchParamsUpdated(); } protected function runCommand($command, $paramKey, $value) @@ -120,7 +121,7 @@ protected function runCommand($command, $paramKey, $value) break; } - $this->dispatch('params-updated', $this->params); + $this->dispatchParamsUpdated(); } protected function addValueToParam($paramKey, $value) @@ -170,4 +171,11 @@ protected function handlePresetParams() $this->dispatch('preset-params', $restOfParams->all()); } } + + protected function dispatchParamsUpdated() + { + if (config('statamic-livewire-filters.enable_filter_values_count')) { + $this->dispatch('params-updated', $this->params); + } + } } From c45452965e5523c1ba8111b309226374255f6e42 Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 21:32:46 +0200 Subject: [PATCH 07/11] Add to the templates --- resources/views/livewire/filters/lf-checkbox.blade.php | 3 +++ resources/views/livewire/filters/lf-radio.blade.php | 3 +++ resources/views/livewire/filters/lf-select.blade.php | 3 +++ 3 files changed, 9 insertions(+) diff --git a/resources/views/livewire/filters/lf-checkbox.blade.php b/resources/views/livewire/filters/lf-checkbox.blade.php index a165482..e398f7a 100644 --- a/resources/views/livewire/filters/lf-checkbox.blade.php +++ b/resources/views/livewire/filters/lf-checkbox.blade.php @@ -14,6 +14,9 @@ class="form-checkbox w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded f class="ml-2 text-gray-900" > {{ $label }} + @if ($this->counts[$value] !== null) + ({{ $this->counts[$value] }}) + @endif @endforeach diff --git a/resources/views/livewire/filters/lf-radio.blade.php b/resources/views/livewire/filters/lf-radio.blade.php index b610fd7..3cf455f 100644 --- a/resources/views/livewire/filters/lf-radio.blade.php +++ b/resources/views/livewire/filters/lf-radio.blade.php @@ -14,6 +14,9 @@ class="form-radio w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-b class="ml-2 text-gray-900" > {{ $label }} + @if ($this->counts[$value] !== null) + ({{ $this->counts[$value] }}) + @endif @endforeach diff --git a/resources/views/livewire/filters/lf-select.blade.php b/resources/views/livewire/filters/lf-select.blade.php index fbe3181..84a5063 100644 --- a/resources/views/livewire/filters/lf-select.blade.php +++ b/resources/views/livewire/filters/lf-select.blade.php @@ -9,6 +9,9 @@ class="form-select bg-gray-50 border border-gray-300 text-gray-900 text-sm round @endforeach From caf41814c0752042213fb155b9d306ca64a54c25 Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 21:35:34 +0200 Subject: [PATCH 08/11] Update GenerateParams.php --- src/Http/Livewire/Traits/GenerateParams.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Http/Livewire/Traits/GenerateParams.php b/src/Http/Livewire/Traits/GenerateParams.php index e8786c0..7030ddb 100644 --- a/src/Http/Livewire/Traits/GenerateParams.php +++ b/src/Http/Livewire/Traits/GenerateParams.php @@ -20,6 +20,16 @@ protected function generateParams() ); } + protected function generateParamsForCount($collection, $params) + { + return Parameters::make(array_merge( + ['from' => $collection], + $params, + ), + Context::make([]) + ); + } + protected function removeParamsNotInFiltersCollection() { return collect($this->params)->filter(function ($value, $key) { From 4544dae522ba8132bea3cee219098bfe316bb20f Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 23:14:00 +0200 Subject: [PATCH 09/11] Make it disabled --- config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.php b/config/config.php index 444e713..a173d2b 100644 --- a/config/config.php +++ b/config/config.php @@ -14,5 +14,5 @@ 'enable_term_routes' => false, // The addon will calculate the number of entries for each filter value (can be slow for a large number of entries) - 'enable_filter_values_count' => true, + 'enable_filter_values_count' => false, ]; From 61116c2308b2c2ecde086379fbc25d1137c46f3f Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 23:43:16 +0200 Subject: [PATCH 10/11] Add tests --- tests/Feature/LfCheckboxFilterTest.php | 19 ++++-- tests/Feature/LfRadioFilterTest.php | 18 +++++- .../LivewireCollectionComponentTest.php | 58 +++++++++++++++++++ 3 files changed, 88 insertions(+), 7 deletions(-) diff --git a/tests/Feature/LfCheckboxFilterTest.php b/tests/Feature/LfCheckboxFilterTest.php index 19ae6ec..88956f5 100644 --- a/tests/Feature/LfCheckboxFilterTest.php +++ b/tests/Feature/LfCheckboxFilterTest.php @@ -38,7 +38,7 @@ public function setUp(): void 'handle' => 'item_options', 'field' => [ - 'type' => 'checkbox', + 'type' => 'checkboxes', 'display' => 'Checkbox', 'listable' => 'hidden', 'options' => [ @@ -54,9 +54,9 @@ public function setUp(): void ]); $this->blueprint->setHandle('pages')->setNamespace('collections.'.$this->collection->handle())->save(); - $this->makeEntry($this->collection, 'a')->set('title', 'I Love Guitars')->save(); - $this->makeEntry($this->collection, 'b')->set('title', 'I Love Drums')->save(); - $this->makeEntry($this->collection, 'c')->set('title', 'I Hate Flutes')->save(); + $this->makeEntry($this->collection, 'a')->set('title', 'I Love Guitars')->set('item_options', 'option1')->save(); + $this->makeEntry($this->collection, 'b')->set('title', 'I Love Drums')->set('item_options', 'option1')->save(); + $this->makeEntry($this->collection, 'c')->set('title', 'I Hate Flutes')->set('item_options', 'option2')->save(); Facades\Taxonomy::make('colors')->save(); Facades\Term::make()->taxonomy('colors')->inDefaultLocale()->slug('red')->data(['title' => 'Red'])->save(); @@ -228,6 +228,17 @@ public function it_loads_a_param_that_is_preset_for_a_query_scope() ->assertSet('selected', ['option1']); } + /** @test */ + public function it_calculates_the_count_for_each_entry() + { + Livewire::test(LfCheckboxFilter::class, ['field' => 'item_options', 'blueprint' => 'pages.pages', 'condition' => 'is']) + ->assertSet('selected', []) + ->dispatch('params-updated', ['item_options:is' => 'option1']) + ->assertViewHas('statamic_field', function ($statamic_field) { + return $statamic_field['counts'] === ['option1' => 2, 'option2' => 1, 'option3' => 0]; + }); + } + protected function makeEntry($collection, $slug) { return EntryFactory::id($slug)->collection($collection)->slug($slug)->make(); diff --git a/tests/Feature/LfRadioFilterTest.php b/tests/Feature/LfRadioFilterTest.php index 3d99c0b..026603e 100644 --- a/tests/Feature/LfRadioFilterTest.php +++ b/tests/Feature/LfRadioFilterTest.php @@ -54,9 +54,9 @@ public function setUp(): void ]); $this->blueprint->setHandle('pages')->setNamespace('collections.'.$this->collection->handle())->save(); - $this->makeEntry($this->collection, 'a')->set('title', 'I Love Guitars')->save(); - $this->makeEntry($this->collection, 'b')->set('title', 'I Love Drums')->save(); - $this->makeEntry($this->collection, 'c')->set('title', 'I Hate Flutes')->save(); + $this->makeEntry($this->collection, 'a')->set('title', 'I Love Guitars')->set('item_options', 'option1')->save(); + $this->makeEntry($this->collection, 'b')->set('title', 'I Love Drums')->set('item_options', 'option1')->save(); + $this->makeEntry($this->collection, 'c')->set('title', 'I Hate Flutes')->set('item_options', 'option2')->save(); } /** @test */ @@ -143,6 +143,18 @@ public function it_loads_a_param_that_is_preset() ->assertSet('selected', 'option1'); } + /** @test */ + public function it_calculates_the_count_for_each_entry() + { + Livewire::test(LfRadioFilter::class, ['field' => 'item_options', 'blueprint' => 'pages.pages', 'condition' => 'is']) + ->assertSet('selected', '') + ->dispatch('params-updated', ['item_options:is' => 'option1']) + ->assertViewHas('statamic_field', function ($statamic_field) { + return $statamic_field['counts'] === ['option1' => 2, 'option2' => 1, 'option3' => 0]; + }); + + } + protected function makeEntry($collection, $slug) { return EntryFactory::id($slug)->collection($collection)->slug($slug)->make(); diff --git a/tests/Feature/LivewireCollectionComponentTest.php b/tests/Feature/LivewireCollectionComponentTest.php index 23cc1d6..f3bf5bd 100644 --- a/tests/Feature/LivewireCollectionComponentTest.php +++ b/tests/Feature/LivewireCollectionComponentTest.php @@ -410,4 +410,62 @@ public function it_gets_a_list_of_active_filters_on_the_page() return true; }); } + + /** @test */ + public function it_does_not_dispatch_the_params_updated_event_by_default() + { + //Config::set('statamic-livewire-filters.only_allow_active_filters', false); + $params = [ + 'from' => 'clothes', + ]; + + Livewire::test(LivewireCollectionComponent::class, ['params' => $params]) + ->dispatch('filter-updated', + field: 'colors', + condition: 'taxonomy', + payload: 'yellow', + command: 'add', + modifier: 'any', + ) + ->assertNotDispatched('params-updated'); + } + + /** @test */ + public function it_dispatches_the_params_updated_event_if_enabled() + { + Config::set('statamic-livewire-filters.enable_filter_values_count', true); + + $params = [ + 'from' => 'clothes', + ]; + + // Also add some tests to make sure it's not dispatched when it's not needed + Livewire::test(LivewireCollectionComponent::class, ['params' => $params]) + ->dispatch('filter-updated', + field: 'colors', + condition: 'taxonomy', + payload: 'yellow', + command: 'add', + modifier: 'any', + ) + ->assertDispatched('params-updated') + ->dispatch('filter-mounted', + field: 'colors', + condition: 'taxonomy', + modifier: 'any', + ) + ->assertNotDispatched('params-updated') + ->dispatch('filter-updated', + field: 'colors', + condition: 'taxonomy', + payload: 'yellow', + command: 'remove', + modifier: 'any', + ) + ->assertDispatched('params-updated') + ->dispatch('sort-updated', + sort: 'title:asc' + ) + ->assertNotDispatched('params-updated'); + } } From ecb295fdf7da1a86ef2d10e94e8598da04ea941a Mon Sep 17 00:00:00 2001 From: Iosif Chatzimichail Date: Wed, 28 Feb 2024 23:52:37 +0200 Subject: [PATCH 11/11] Some extra testing for peace of mind --- tests/Feature/LfCheckboxFilterTest.php | 3 ++- tests/Feature/LfRadioFilterTest.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Feature/LfCheckboxFilterTest.php b/tests/Feature/LfCheckboxFilterTest.php index 88956f5..7fc2734 100644 --- a/tests/Feature/LfCheckboxFilterTest.php +++ b/tests/Feature/LfCheckboxFilterTest.php @@ -236,7 +236,8 @@ public function it_calculates_the_count_for_each_entry() ->dispatch('params-updated', ['item_options:is' => 'option1']) ->assertViewHas('statamic_field', function ($statamic_field) { return $statamic_field['counts'] === ['option1' => 2, 'option2' => 1, 'option3' => 0]; - }); + }) + ->assertSeeHtml('(2)'); } protected function makeEntry($collection, $slug) diff --git a/tests/Feature/LfRadioFilterTest.php b/tests/Feature/LfRadioFilterTest.php index 026603e..a894c16 100644 --- a/tests/Feature/LfRadioFilterTest.php +++ b/tests/Feature/LfRadioFilterTest.php @@ -151,7 +151,8 @@ public function it_calculates_the_count_for_each_entry() ->dispatch('params-updated', ['item_options:is' => 'option1']) ->assertViewHas('statamic_field', function ($statamic_field) { return $statamic_field['counts'] === ['option1' => 2, 'option2' => 1, 'option3' => 0]; - }); + }) + ->assertSeeHtml('(2)'); }