SortTable bug (Test)?

So what I am trying to do is to test whether I can sort countries table.. If i were to test it physically it works as intended but with test it failed. error message:
at vendor\livewire\livewire\src\Features\SupportTesting\MakesAssertions.php:49
45▕ }
46▕
47▕ function assertSeeHtmlInOrder($values)
48▕ {
➜ 49▕ PHPUnit::assertThat(
50▕ $values,
51▕ new SeeInOrder($this->html())
52▕ );
53▕

1 vendor\livewire\livewire\src\Features\SupportTesting\MakesAssertions.php:49
2 vendor\filament\tables\src\Testing\TestsRecords.php:34
at vendor\livewire\livewire\src\Features\SupportTesting\MakesAssertions.php:49
45▕ }
46▕
47▕ function assertSeeHtmlInOrder($values)
48▕ {
➜ 49▕ PHPUnit::assertThat(
50▕ $values,
51▕ new SeeInOrder($this->html())
52▕ );
53▕

1 vendor\livewire\livewire\src\Features\SupportTesting\MakesAssertions.php:49
2 vendor\filament\tables\src\Testing\TestsRecords.php:34
the CountryResourceTest:
describe('can sort countries by: ', function () {
$columnsToTest = collect([
'name',
// 'code',
// 'phonecode',
]);

$columnsToTest->each(function ($columnName) {
it($columnName, function () use ($columnName) {
$countries = Country::limit(10)->get();

livewire(CountryResource\Pages\ListCountries::class)
->loadTable()
->sortTable($columnName)
->assertCanSeeTableRecords($countries->sortBy($columnName), inOrder: true)
->sortTable($columnName, 'desc')
->assertCanSeeTableRecords($countries->sortByDesc($columnName), inOrder: true);
});
});
});
describe('can sort countries by: ', function () {
$columnsToTest = collect([
'name',
// 'code',
// 'phonecode',
]);

$columnsToTest->each(function ($columnName) {
it($columnName, function () use ($columnName) {
$countries = Country::limit(10)->get();

livewire(CountryResource\Pages\ListCountries::class)
->loadTable()
->sortTable($columnName)
->assertCanSeeTableRecords($countries->sortBy($columnName), inOrder: true)
->sortTable($columnName, 'desc')
->assertCanSeeTableRecords($countries->sortByDesc($columnName), inOrder: true);
});
});
});
the CountryResource table:
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->sortable()
->searchable(),
... some other TextColumn
])
->deferLoading();
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->sortable()
->searchable(),
... some other TextColumn
])
->deferLoading();
}
3 Replies
Rolland
RollandOP9mo ago
in addition to this. i do the same test for other resource and the results sometimes Pass and sometimes Failed.
JJSanders
JJSanders9mo ago
Can it be that it is b/c you test with a large dataset and then sometimes it manages to sort within the timeout boundary and sometimes not?
Rolland
RollandOP9mo ago
that could be the reason but i believe i have limited the queries to 10.. hmm. is my code incorrect?
Want results from more Discord servers?
Add your server