Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta 6 - Dev to Master #1444

Merged
merged 43 commits into from
Oct 25, 2023
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1d1da19
Beta Fixes - Publishing Views/Localizations. Beta Improvements - Sea…
lrljoe Aug 31, 2023
135297e
Bulk Actions Fix - v3 (#1326)
lrljoe Sep 3, 2023
3967e15
Fix Column Select - Select All state (#1333)
lrljoe Sep 3, 2023
648a6ca
Merge branch 'v3-master' into v3-develop
lrljoe Sep 3, 2023
4ee351e
Add NonArray setAdditionalSelects Test (#1337)
lrljoe Sep 3, 2023
32556cd
Test Additions (#1339)
lrljoe Sep 3, 2023
9ec84f1
Add Third Party Tests (#1340)
lrljoe Sep 3, 2023
74b547c
Third Party Asset Tests (#1341)
lrljoe Sep 4, 2023
b68ab26
Lazy Loading Fix (#1355)
lrljoe Sep 17, 2023
e609f13
Spacing fixes
rappasoft Sep 18, 2023
d6e6512
v3 - Missing Tests - Pagination Related Tests (#1363)
lrljoe Sep 21, 2023
ae87ac2
v3 - Missing Tests - Broken Tables (Missing Primary Key/Builder) (#1362)
lrljoe Sep 21, 2023
e2a3199
v3 - Add setSearchFieldAttribute Options (#1361)
lrljoe Sep 22, 2023
e7c10c1
v3 - Column Select Fixes & Tweaks (#1360)
lrljoe Sep 22, 2023
62db217
Fix ServiceProvider Fault (#1366)
lrljoe Sep 23, 2023
65ce494
V3 Frontend Asset Tweaks (#1371)
lrljoe Sep 26, 2023
19b79b2
V3 - Reordering Fixes (#1373)
lrljoe Sep 26, 2023
9cdf451
Bundler Import Options (#1377)
lrljoe Sep 28, 2023
6c977c4
V3 Restore setTrAttributes (#1378)
lrljoe Oct 1, 2023
1e6c159
Update Reorder Documentation (#1381)
lrljoe Oct 3, 2023
32de139
Merge branch 'v3-master' into v3-develop
lrljoe Oct 3, 2023
66ece40
Update Docs - Advanced Example, Add Including Assets (#1383)
lrljoe Oct 4, 2023
154f726
Fix DateRangeFilter Blade Items (#1394)
lrljoe Oct 6, 2023
16ccfe1
Add setFilterLabelAttributes Capability (#1397)
lrljoe Oct 8, 2023
323deee
Merge branch 'v3-master' into v3-develop
lrljoe Oct 8, 2023
429b54f
v3 - Apply Reorder Sorting When Reordering (#1402)
lrljoe Oct 8, 2023
eff02e4
v3 - Fix Unrequired Update Call (#1407)
lrljoe Oct 13, 2023
1b1d574
v3 - Adding CollapseAlways Option for Columns (#1403)
lrljoe Oct 13, 2023
9d42d0f
Merge branch 'v3-master' into v3-develop
lrljoe Oct 13, 2023
31ae8fe
Minor tweaks to blades for reorder cols (#1411)
lrljoe Oct 13, 2023
c0f00ea
V3 - Fix Reorder For Bootstrap (#1412)
lrljoe Oct 13, 2023
bbd73cd
Add DiscordBot (#1413)
lrljoe Oct 13, 2023
94df54c
Docs livewire namespace fix (#1420)
amshehzad Oct 14, 2023
1cab8c4
V3 - Fix Localisation (#1424)
lrljoe Oct 17, 2023
cb2d9c9
v3 - Add Loading Placeholder (#1421)
lrljoe Oct 17, 2023
c972b20
Merge branch 'v3-master' into v3-develop
lrljoe Oct 17, 2023
b4c07dc
v3 - Column - Allow Enum in ReturnType for Column getContent/renderCo…
lrljoe Oct 23, 2023
5dffbe3
v3 - Add "Confirmation" Option to Bulk Actions (#1437)
lrljoe Oct 25, 2023
be31564
Merge branch 'v3-master' into v3-develop
lrljoe Oct 25, 2023
4396c44
Collapsing Header Fix (#1441)
lrljoe Oct 25, 2023
87cc153
Merge branch 'v3-master' into v3-develop
lrljoe Oct 25, 2023
53ec8d8
V3 - Additional Fixes for Collapsing header (#1443)
lrljoe Oct 25, 2023
6fbd20e
Merge branch 'v3-master' into v3-develop
lrljoe Oct 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
v3 - Missing Tests - Broken Tables (Missing Primary Key/Builder) (#1362)
* Add missing component visuals tests & failed tables

* Update Exception Expectation

* Temporary test swapping to check Exception throwing

---------

Co-authored-by: lrljoe <lrljoe@users.noreply.github.com>
lrljoe and lrljoe authored Sep 21, 2023
commit ae87ac29172b3dd505f01b27a613c6cd370b0013
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

All notable changes to `laravel-livewire-tables` will be documented in this file

## [Unreleased] - 3.x - Missing Tests

## [Unreleased] - 3.x - Missing pagination tests
- Add missing pagination tests

146 changes: 146 additions & 0 deletions tests/Http/Livewire/FailingTables/NoBuildMethodTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\FailingTables;

use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Tests\Models\Breed;
use Rappasoft\LaravelLivewireTables\Tests\Models\Species;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn;
use Rappasoft\LaravelLivewireTables\Views\Columns\LinkColumn;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateTimeFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectDropdownFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\NumberFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;

class NoBuildMethodTable extends DataTableComponent
{
public function configure(): void
{
$this->setPrimaryKey('id');

}

public function columns(): array
{
return [
Column::make('ID', 'id')
->sortable()
->setSortingPillTitle('Key')
->setSortingPillDirections('0-9', '9-0'),
Column::make('Sort')
->sortable()
->excludeFromColumnSelect(),
Column::make('Name')
->sortable()
->secondaryHeader($this->getFilterByKey('pet_name_filter'))
->footerFilter('pet_name_filter')
->searchable(),

Column::make('Age'),

Column::make('Breed', 'breed.name')
->secondaryHeaderFilter('breed')
->footer($this->getFilterByKey('breed'))
->sortable(
fn (Builder $query, string $direction) => $query->orderBy('pets.id', $direction)
)
->searchable(
fn (Builder $query, $searchTerm) => $query->orWhere('breed.name', $searchTerm)
),

Column::make('Other')
->label(function ($row, Column $column) {
return 'Other';
})
->footer(function ($rows) {
return 'Count: '.$rows->count();
}),

LinkColumn::make('Link')
->title(fn ($row) => 'Edit')
->location(fn ($row) => 'http://www.google.com')
->attributes(fn ($row) => [
'class' => 'rounded-full',
'alt' => $row->name.' Avatar',
]),
ImageColumn::make('RowImg')
->location(fn ($row) => 'test'.$row->id)
->attributes(fn ($row) => [
'class' => 'rounded-full',
'alt' => $row->name.' Avatar',
]),
Column::make('Last Visit', 'last_visit')
->sortable()
->deselected(),
];
}

public function filters(): array
{
return [
MultiSelectFilter::make('Breed')
->options(
Breed::query()
->orderBy('name')
->get()
->keyBy('id')
->map(fn ($breed) => $breed->name)
->toArray()
)
->filter(function (Builder $builder, array $values) {
return $builder->whereIn('breed_id', $values);
}),
MultiSelectDropdownFilter::make('Species')
->options(
Species::query()
->orderBy('name')
->get()
->keyBy('id')
->map(fn ($species) => $species->name)
->toArray()
)
->filter(function (Builder $builder, array $values) {
return $builder->whereIn('species_id', $values);
}),
NumberFilter::make('Breed ID', 'breed_id_filter')
->filter(function (Builder $builder, string $value) {
return $builder->where('breed_id', '=', $value);
}),

TextFilter::make('Pet Name', 'pet_name_filter')
->filter(function (Builder $builder, string $value) {
return $builder->where('pets.name', '=', $value);
}),

DateFilter::make('Last Visit After Date', 'last_visit_date_filter')
->filter(function (Builder $builder, string $value) {
return $builder->whereDate('pets.last_visit', '=>', $value);
}),

DateTimeFilter::make('Last Visit Before DateTime', 'last_visit_datetime_filter')
->filter(function (Builder $builder, string $value) {
return $builder->whereDate('pets.last_visit', '<=', $value);
}),

SelectFilter::make('Breed SelectFilter', 'breed_select_filter')
->options(
Breed::query()
->orderBy('name')
->get()
->keyBy('id')
->map(fn ($breed) => $breed->name)
->toArray()
)
->filter(function (Builder $builder, string $value) {
return $builder->where('breed_id', $value);
})
->setCustomFilterLabel('livewire-tables::tests.testFilterLabel')
->setFilterPillBlade('livewire-tables::tests.testFilterPills'),
];
}
}
147 changes: 147 additions & 0 deletions tests/Http/Livewire/FailingTables/NoPrimaryKeyTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\FailingTables;

use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Tests\Models\Breed;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
use Rappasoft\LaravelLivewireTables\Tests\Models\Species;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn;
use Rappasoft\LaravelLivewireTables\Views\Columns\LinkColumn;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateTimeFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectDropdownFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\NumberFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;

class NoPrimaryKeyTable extends DataTableComponent
{
public $model = Pet::class;

public function configure(): void
{
}

public function columns(): array
{
return [
Column::make('ID', 'id')
->sortable()
->setSortingPillTitle('Key')
->setSortingPillDirections('0-9', '9-0'),
Column::make('Sort')
->sortable()
->excludeFromColumnSelect(),
Column::make('Name')
->sortable()
->secondaryHeader($this->getFilterByKey('pet_name_filter'))
->footerFilter('pet_name_filter')
->searchable(),

Column::make('Age'),

Column::make('Breed', 'breed.name')
->secondaryHeaderFilter('breed')
->footer($this->getFilterByKey('breed'))
->sortable(
fn (Builder $query, string $direction) => $query->orderBy('pets.id', $direction)
)
->searchable(
fn (Builder $query, $searchTerm) => $query->orWhere('breed.name', $searchTerm)
),

Column::make('Other')
->label(function ($row, Column $column) {
return 'Other';
})
->footer(function ($rows) {
return 'Count: '.$rows->count();
}),

LinkColumn::make('Link')
->title(fn ($row) => 'Edit')
->location(fn ($row) => 'http://www.google.com')
->attributes(fn ($row) => [
'class' => 'rounded-full',
'alt' => $row->name.' Avatar',
]),
ImageColumn::make('RowImg')
->location(fn ($row) => 'test'.$row->id)
->attributes(fn ($row) => [
'class' => 'rounded-full',
'alt' => $row->name.' Avatar',
]),
Column::make('Last Visit', 'last_visit')
->sortable()
->deselected(),
];
}

public function filters(): array
{
return [
MultiSelectFilter::make('Breed')
->options(
Breed::query()
->orderBy('name')
->get()
->keyBy('id')
->map(fn ($breed) => $breed->name)
->toArray()
)
->filter(function (Builder $builder, array $values) {
return $builder->whereIn('breed_id', $values);
}),
MultiSelectDropdownFilter::make('Species')
->options(
Species::query()
->orderBy('name')
->get()
->keyBy('id')
->map(fn ($species) => $species->name)
->toArray()
)
->filter(function (Builder $builder, array $values) {
return $builder->whereIn('species_id', $values);
}),
NumberFilter::make('Breed ID', 'breed_id_filter')
->filter(function (Builder $builder, string $value) {
return $builder->where('breed_id', '=', $value);
}),

TextFilter::make('Pet Name', 'pet_name_filter')
->filter(function (Builder $builder, string $value) {
return $builder->where('pets.name', '=', $value);
}),

DateFilter::make('Last Visit After Date', 'last_visit_date_filter')
->filter(function (Builder $builder, string $value) {
return $builder->whereDate('pets.last_visit', '=>', $value);
}),

DateTimeFilter::make('Last Visit Before DateTime', 'last_visit_datetime_filter')
->filter(function (Builder $builder, string $value) {
return $builder->whereDate('pets.last_visit', '<=', $value);
}),

SelectFilter::make('Breed SelectFilter', 'breed_select_filter')
->options(
Breed::query()
->orderBy('name')
->get()
->keyBy('id')
->map(fn ($breed) => $breed->name)
->toArray()
)
->filter(function (Builder $builder, string $value) {
return $builder->where('breed_id', $value);
})
->setCustomFilterLabel('livewire-tables::tests.testFilterLabel')
->setFilterPillBlade('livewire-tables::tests.testFilterPills'),
];
}
}
56 changes: 56 additions & 0 deletions tests/Traits/Visuals/ComponentVisualsTest.php
Original file line number Diff line number Diff line change
@@ -2,12 +2,19 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals;

use Exception;
use Illuminate\View\ViewException;
use Livewire\Livewire;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\FailingTables\NoBuildMethodTable;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\FailingTables\NoPrimaryKeyTable;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;

class ComponentVisualsTest extends TestCase
{
private $testErrors;

/** @test */
public function empty_message_does_not_show_with_results(): void
{
@@ -38,4 +45,53 @@ public function offline_message_is_available_when_needed(): void
Livewire::test(PetsTable::class)
->assertSeeHtml('<div wire:offline.class.remove="hidden" class="hidden">');
}

/** @test */
public function fails_when_table_has_no_pk(): void
{
$this->testErrors = false;
try {
Livewire::test(NoPrimaryKeyTable::class);
} catch (DataTableConfigurationException $DataTableConfigurationException) {
$this->testErrors = true;
$this->assertSame('You must set a primary key using setPrimaryKey in the configure method.', substr($DataTableConfigurationException->getMessage(), 0, 71));
} catch (ViewException $ViewException) {
$this->testErrors = true;

// Temporary swapping to check exception throwing
//$this->assertSame('You must set a primary key using setPrimaryKey in the configure method.', substr($ViewException->getMessage(), 0, 71));
$this->assertSame('Typed property Rappasoft\LaravelLivewireTables\DataTableComponent::$pri', substr($ViewException->getMessage(), 0, 71));

} catch (Exception $standardException) {
$this->testErrors = true;

$this->assertSame('You must set a primary key using setPrimaryKey in the configure method.', substr($standardException->getMessage(), 0, 71));
}
if (! $this->testErrors) {
$this->fail('Did Not Throw Error - Missing Primary Key');
}
}

/** @test */
public function fails_when_table_has_no_model_or_builder(): void
{
$this->testErrors = false;
try {
$test = Livewire::test(NoBuildMethodTable::class);
} catch (DataTableConfigurationException $DataTableConfigurationException) {
$this->testErrors = true;
$this->assertSame('You must either specify a model or implement the builder method.', substr($DataTableConfigurationException->getMessage(), 0, 64));

} catch (ViewException $ViewException) {
$this->testErrors = true;
$this->assertSame('You must either specify a model or implement the builder method.', substr($ViewException->getMessage(), 0, 64));
} catch (Exception $standardException) {
$this->testErrors = true;
$this->assertSame('You must either specify a model or implement the builder method.', substr($standardException->getMessage(), 0, 64));
}

if (! $this->testErrors) {
$this->fail('Did Not Throw Error - Missing Model/Builder');
}
}
}