diff --git a/src/Handlers/StubHandler.php b/src/Handlers/StubHandler.php index 58cdd171..63a55e09 100644 --- a/src/Handlers/StubHandler.php +++ b/src/Handlers/StubHandler.php @@ -61,6 +61,11 @@ public function getStubs(): Collection \CodeWithDennis\FilamentTests\Stubs\Page\Index\Table\Columns\Select::make($resource)->get(), \CodeWithDennis\FilamentTests\Stubs\Page\Index\Table\Columns\ExtraAttributes::make($resource)->get(), + \CodeWithDennis\FilamentTests\Stubs\Page\Index\Table\Summaries\Average::make($resource)->get(), + \CodeWithDennis\FilamentTests\Stubs\Page\Index\Table\Summaries\Count::make($resource)->get(), + \CodeWithDennis\FilamentTests\Stubs\Page\Index\Table\Summaries\Range::make($resource)->get(), + \CodeWithDennis\FilamentTests\Stubs\Page\Index\Table\Summaries\Sum::make($resource)->get(), + \CodeWithDennis\FilamentTests\Stubs\Page\Index\Table\Filters\Reset::make($resource)->get(), \CodeWithDennis\FilamentTests\Stubs\Page\Index\Table\Filters\Add::make($resource)->get(), \CodeWithDennis\FilamentTests\Stubs\Page\Index\Table\Filters\Remove::make($resource)->get(), diff --git a/src/Stubs/Base.php b/src/Stubs/Base.php index ed7a98aa..081303b4 100644 --- a/src/Stubs/Base.php +++ b/src/Stubs/Base.php @@ -400,6 +400,11 @@ public function getTableSelectColumnsWithOptions(Resource $resource): array ])->toArray(); } + public function getResourceTableColumnsWithSummarizers(Resource $resource): Collection + { + return $this->getTableColumns($resource)->filter(fn($column) => $column->getSummarizers()); + } + public function hasSoftDeletes(Resource $resource): bool { return method_exists($resource->getModel(), 'bootSoftDeletes'); diff --git a/src/Stubs/Page/Index/Table/Summaries/Average.php b/src/Stubs/Page/Index/Table/Summaries/Average.php new file mode 100644 index 00000000..0394cdf8 --- /dev/null +++ b/src/Stubs/Page/Index/Table/Summaries/Average.php @@ -0,0 +1,20 @@ +getResourceTableColumnsWithSummarizers($this->resource) + ->filter(fn($column) => collect($column->getSummarizers()) + ->filter(fn($summarizer) => $summarizer::class === \Filament\Tables\Columns\Summarizers\Average::class) + ->count()) + ->isNotEmpty(); + } +} diff --git a/src/Stubs/Page/Index/Table/Summaries/Count.php b/src/Stubs/Page/Index/Table/Summaries/Count.php new file mode 100644 index 00000000..ce609198 --- /dev/null +++ b/src/Stubs/Page/Index/Table/Summaries/Count.php @@ -0,0 +1,20 @@ +getResourceTableColumnsWithSummarizers($this->resource) + ->filter(fn($column) => collect($column->getSummarizers()) + ->filter(fn($summarizer) => $summarizer::class === \Filament\Tables\Columns\Summarizers\Count::class) + ->count()) + ->isNotEmpty(); + } +} diff --git a/src/Stubs/Page/Index/Table/Summaries/Range.php b/src/Stubs/Page/Index/Table/Summaries/Range.php new file mode 100644 index 00000000..250e1e64 --- /dev/null +++ b/src/Stubs/Page/Index/Table/Summaries/Range.php @@ -0,0 +1,20 @@ +getResourceTableColumnsWithSummarizers($this->resource) + ->filter(fn($column) => collect($column->getSummarizers()) + ->filter(fn($summarizer) => $summarizer::class === \Filament\Tables\Columns\Summarizers\Range::class) + ->count()) + ->isNotEmpty(); + } +} diff --git a/src/Stubs/Page/Index/Table/Summaries/Sum.php b/src/Stubs/Page/Index/Table/Summaries/Sum.php new file mode 100644 index 00000000..dd1dc0aa --- /dev/null +++ b/src/Stubs/Page/Index/Table/Summaries/Sum.php @@ -0,0 +1,17 @@ +getResourceTableColumnsWithSummarizers($this->resource)->isNotEmpty(); + } +} diff --git a/stubs/Page/Index/Table/Filters/Add.stub b/stubs/Page/Index/Table/Filters/Add.stub index 15f24eca..b1591b13 100644 --- a/stubs/Page/Index/Table/Filters/Add.stub +++ b/stubs/Page/Index/Table/Filters/Add.stub @@ -1,3 +1,3 @@ it('can add a table filter', function () { - -})->group('filters', 'table')->todo(); + // +}){{ RESOLVED_GROUP_METHOD }}->todo(); diff --git a/stubs/Page/Index/Table/Filters/Remove.stub b/stubs/Page/Index/Table/Filters/Remove.stub index 53602138..ae63effa 100644 --- a/stubs/Page/Index/Table/Filters/Remove.stub +++ b/stubs/Page/Index/Table/Filters/Remove.stub @@ -1,3 +1,3 @@ it('can remove a table filter', function () { - -})->group('filters', 'table')->todo(); + // +}){{ RESOLVED_GROUP_METHOD }}->todo(); diff --git a/stubs/Page/Index/Table/Filters/Reset.stub b/stubs/Page/Index/Table/Filters/Reset.stub index fb45d8a0..c4eef9dd 100644 --- a/stubs/Page/Index/Table/Filters/Reset.stub +++ b/stubs/Page/Index/Table/Filters/Reset.stub @@ -4,4 +4,4 @@ it('can reset table filters', function () { livewire(List{{ MODEL_PLURAL_NAME }}::class) ->resetTableFilters(){{ LOAD_TABLE_METHOD_IF_DEFERRED }} ->assertCanSeeTableRecords($records); -})->group('filters', 'table'); +}){{ RESOLVED_GROUP_METHOD }}; diff --git a/stubs/Page/Index/Table/Summaries/Average.stub b/stubs/Page/Index/Table/Summaries/Average.stub new file mode 100644 index 00000000..ba6f1819 --- /dev/null +++ b/stubs/Page/Index/Table/Summaries/Average.stub @@ -0,0 +1,3 @@ +it('can average values in a column', function () { + // +}){{ RESOLVED_GROUP_METHOD }}->todo(); diff --git a/stubs/Page/Index/Table/Summaries/Count.stub b/stubs/Page/Index/Table/Summaries/Count.stub new file mode 100644 index 00000000..2c17b2e9 --- /dev/null +++ b/stubs/Page/Index/Table/Summaries/Count.stub @@ -0,0 +1,3 @@ +it('can count values in a column', function () { + // +}){{ RESOLVED_GROUP_METHOD }}->todo(); diff --git a/stubs/Page/Index/Table/Summaries/Range.stub b/stubs/Page/Index/Table/Summaries/Range.stub new file mode 100644 index 00000000..df4c038d --- /dev/null +++ b/stubs/Page/Index/Table/Summaries/Range.stub @@ -0,0 +1,3 @@ +it('can range values in a column', function () { + // +}){{ RESOLVED_GROUP_METHOD }}->todo(); diff --git a/stubs/Page/Index/Table/Summaries/Sum.stub b/stubs/Page/Index/Table/Summaries/Sum.stub new file mode 100644 index 00000000..73c52e3e --- /dev/null +++ b/stubs/Page/Index/Table/Summaries/Sum.stub @@ -0,0 +1,3 @@ +it('can sum values in a column', function () { + // +}){{ RESOLVED_GROUP_METHOD }}->todo();